diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index a625ae7a7684277e5af2ecb2e63c775fd8655131..0d9c5f30522c3dc5536727b784675d7564a76ab9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -947,23 +947,23 @@ virQEMUCloseCallbacksRun(virQEMUCloseCallbacksPtr closeCallbacks, VIR_FREE(list); } -struct _qemuSharedDiskEntry { +struct _qemuSharedDeviceEntry { size_t ref; char **domains; /* array of domain names */ }; -/* Construct the hash key for sharedDisks as "major:minor" */ +/* Construct the hash key for sharedDevices as "major:minor" */ char * -qemuGetSharedDiskKey(const char *disk_path) +qemuGetSharedDeviceKey(const char *device_path) { int maj, min; char *key = NULL; int rc; - if ((rc = virGetDeviceID(disk_path, &maj, &min)) < 0) { + if ((rc = virGetDeviceID(device_path, &maj, &min)) < 0) { virReportSystemError(-rc, _("Unable to get minor number of device '%s'"), - disk_path); + device_path); return NULL; } @@ -983,7 +983,7 @@ qemuGetSharedDiskKey(const char *disk_path) * Returns 0 if no conflicts, otherwise returns -1. */ static int -qemuCheckSharedDisk(virHashTablePtr sharedDisks, +qemuCheckSharedDisk(virHashTablePtr sharedDevices, virDomainDiskDefPtr disk) { char *sysfs_path = NULL; @@ -1008,7 +1008,7 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks, if (!virFileExists(sysfs_path)) goto cleanup; - if (!(key = qemuGetSharedDiskKey(disk->src))) { + if (!(key = qemuGetSharedDeviceKey(disk->src))) { ret = -1; goto cleanup; } @@ -1016,7 +1016,7 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks, /* It can't be conflict if no other domain is * is sharing it. */ - if (!(virHashLookup(sharedDisks, key))) + if (!(virHashLookup(sharedDevices, key))) goto cleanup; if (virGetDeviceUnprivSGIO(disk->src, NULL, &val) < 0) { @@ -1052,9 +1052,9 @@ cleanup: } bool -qemuSharedDiskEntryDomainExists(qemuSharedDiskEntryPtr entry, - const char *name, - int *idx) +qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry, + const char *name, + int *idx) { size_t i; @@ -1070,9 +1070,9 @@ qemuSharedDiskEntryDomainExists(qemuSharedDiskEntryPtr entry, } void -qemuSharedDiskEntryFree(void *payload, const void *name ATTRIBUTE_UNUSED) +qemuSharedDeviceEntryFree(void *payload, const void *name ATTRIBUTE_UNUSED) { - qemuSharedDiskEntryPtr entry = payload; + qemuSharedDeviceEntryPtr entry = payload; size_t i; if (!entry) @@ -1085,10 +1085,10 @@ qemuSharedDiskEntryFree(void *payload, const void *name ATTRIBUTE_UNUSED) VIR_FREE(entry); } -static qemuSharedDiskEntryPtr -qemuSharedDiskEntryCopy(const qemuSharedDiskEntryPtr entry) +static qemuSharedDeviceEntryPtr +qemuSharedDeviceEntryCopy(const qemuSharedDeviceEntryPtr entry) { - qemuSharedDiskEntryPtr ret = NULL; + qemuSharedDeviceEntryPtr ret = NULL; size_t i; if (VIR_ALLOC(ret) < 0) { @@ -1112,7 +1112,7 @@ qemuSharedDiskEntryCopy(const qemuSharedDiskEntryPtr entry) return ret; cleanup: - qemuSharedDiskEntryFree(ret, NULL); + qemuSharedDeviceEntryFree(ret, NULL); return NULL; } @@ -1130,8 +1130,8 @@ qemuAddSharedDisk(virQEMUDriverPtr driver, virDomainDiskDefPtr disk, const char *name) { - qemuSharedDiskEntry *entry = NULL; - qemuSharedDiskEntry *new_entry = NULL; + qemuSharedDeviceEntry *entry = NULL; + qemuSharedDeviceEntry *new_entry = NULL; char *key = NULL; int ret = -1; @@ -1148,47 +1148,47 @@ qemuAddSharedDisk(virQEMUDriverPtr driver, return 0; qemuDriverLock(driver); - if (qemuCheckSharedDisk(driver->sharedDisks, disk) < 0) + if (qemuCheckSharedDisk(driver->sharedDevices, disk) < 0) goto cleanup; - if (!(key = qemuGetSharedDiskKey(disk->src))) + if (!(key = qemuGetSharedDeviceKey(disk->src))) goto cleanup; - if ((entry = virHashLookup(driver->sharedDisks, key))) { + if ((entry = virHashLookup(driver->sharedDevices, key))) { /* Nothing to do if the shared disk is already recorded * in the table. */ - if (qemuSharedDiskEntryDomainExists(entry, name, NULL)) { + if (qemuSharedDeviceEntryDomainExists(entry, name, NULL)) { ret = 0; goto cleanup; } - if (!(new_entry = qemuSharedDiskEntryCopy(entry))) + if (!(new_entry = qemuSharedDeviceEntryCopy(entry))) goto cleanup; if ((VIR_EXPAND_N(new_entry->domains, new_entry->ref, 1) < 0) || !(new_entry->domains[new_entry->ref - 1] = strdup(name))) { - qemuSharedDiskEntryFree(new_entry, NULL); + qemuSharedDeviceEntryFree(new_entry, NULL); virReportOOMError(); goto cleanup; } - if (virHashUpdateEntry(driver->sharedDisks, key, new_entry) < 0) { - qemuSharedDiskEntryFree(new_entry, NULL); + if (virHashUpdateEntry(driver->sharedDevices, key, new_entry) < 0) { + qemuSharedDeviceEntryFree(new_entry, NULL); goto cleanup; } } else { if ((VIR_ALLOC(entry) < 0) || (VIR_ALLOC_N(entry->domains, 1) < 0) || !(entry->domains[0] = strdup(name))) { - qemuSharedDiskEntryFree(entry, NULL); + qemuSharedDeviceEntryFree(entry, NULL); virReportOOMError(); goto cleanup; } entry->ref = 1; - if (virHashAddEntry(driver->sharedDisks, key, entry)) + if (virHashAddEntry(driver->sharedDevices, key, entry)) goto cleanup; } @@ -1213,8 +1213,8 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver, virDomainDiskDefPtr disk, const char *name) { - qemuSharedDiskEntryPtr entry = NULL; - qemuSharedDiskEntryPtr new_entry = NULL; + qemuSharedDeviceEntryPtr entry = NULL; + qemuSharedDeviceEntryPtr new_entry = NULL; char *key = NULL; int ret = -1; int idx; @@ -1228,22 +1228,22 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver, return 0; qemuDriverLock(driver); - if (!(key = qemuGetSharedDiskKey(disk->src))) + if (!(key = qemuGetSharedDeviceKey(disk->src))) goto cleanup; - if (!(entry = virHashLookup(driver->sharedDisks, key))) + if (!(entry = virHashLookup(driver->sharedDevices, key))) goto cleanup; /* Nothing to do if the shared disk is not recored in * the table. */ - if (!qemuSharedDiskEntryDomainExists(entry, name, &idx)) { + if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx)) { ret = 0; goto cleanup; } if (entry->ref != 1) { - if (!(new_entry = qemuSharedDiskEntryCopy(entry))) + if (!(new_entry = qemuSharedDeviceEntryCopy(entry))) goto cleanup; if (idx != new_entry->ref - 1) @@ -1253,12 +1253,12 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver, VIR_SHRINK_N(new_entry->domains, new_entry->ref, 1); - if (virHashUpdateEntry(driver->sharedDisks, key, new_entry) < 0){ - qemuSharedDiskEntryFree(new_entry, NULL); + if (virHashUpdateEntry(driver->sharedDevices, key, new_entry) < 0){ + qemuSharedDeviceEntryFree(new_entry, NULL); goto cleanup; } } else { - if (virHashRemoveEntry(driver->sharedDisks, key) < 0) + if (virHashRemoveEntry(driver->sharedDevices, key) < 0) goto cleanup; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index cdfb98559484c84e241512ec75a2e12f50a603f0..ccb3e6c36219e3d6557b0fc5c151b359a939e7c5 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -210,7 +210,7 @@ struct _virQEMUDriver { virSCSIDeviceListPtr activeScsiHostdevs; /* Immutable pointer. Unsafe APIs. XXX */ - virHashTablePtr sharedDisks; + virHashTablePtr sharedDevices; /* Immutable pointer, self-locking APIs */ virPortAllocatorPtr remotePorts; @@ -281,12 +281,12 @@ void virQEMUCloseCallbacksRun(virQEMUCloseCallbacksPtr closeCallbacks, virConnectPtr conn, virQEMUDriverPtr driver); -typedef struct _qemuSharedDiskEntry qemuSharedDiskEntry; -typedef qemuSharedDiskEntry *qemuSharedDiskEntryPtr; +typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry; +typedef qemuSharedDeviceEntry *qemuSharedDeviceEntryPtr; -bool qemuSharedDiskEntryDomainExists(qemuSharedDiskEntryPtr entry, - const char *name, - int *index) +bool qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry, + const char *name, + int *index) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuAddSharedDisk(virQEMUDriverPtr driver, @@ -299,10 +299,10 @@ int qemuRemoveSharedDisk(virQEMUDriverPtr driver, const char *name) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -char * qemuGetSharedDiskKey(const char *disk_path) +char * qemuGetSharedDeviceKey(const char *disk_path) ATTRIBUTE_NONNULL(1); -void qemuSharedDiskEntryFree(void *payload, const void *name) +void qemuSharedDeviceEntryFree(void *payload, const void *name) ATTRIBUTE_NONNULL(1); int qemuDriverAllocateID(virQEMUDriverPtr driver); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b1630f8694716201a4ad3e62eca56bed42155a42..3e353fdcdf9ea2910eb3642f46b9ce5199f02b96 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -683,7 +683,7 @@ qemuStateInitialize(bool privileged, if ((qemu_driver->activeScsiHostdevs = virSCSIDeviceListNew()) == NULL) goto error; - if (!(qemu_driver->sharedDisks = virHashCreate(30, qemuSharedDiskEntryFree))) + if (!(qemu_driver->sharedDevices = virHashCreate(30, qemuSharedDeviceEntryFree))) goto error; if (privileged) { @@ -954,7 +954,7 @@ qemuStateCleanup(void) { virObjectUnref(qemu_driver->activePciHostdevs); virObjectUnref(qemu_driver->inactivePciHostdevs); virObjectUnref(qemu_driver->activeUsbHostdevs); - virHashFree(qemu_driver->sharedDisks); + virHashFree(qemu_driver->sharedDevices); virObjectUnref(qemu_driver->caps); virQEMUCapsCacheFree(qemu_driver->qemuCapsCache); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dbbb7bf983363c5c573b65c8243733fa2a6a075d..976a8e87d5f3224f498cb721f8c5efc2df9cb0f4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2979,7 +2979,7 @@ qemuProcessReconnect(void *opaque) goto error; /* XXX: Need to change as long as lock is introduced for - * qemu_driver->sharedDisks. + * qemu_driver->sharedDevices. */ for (i = 0; i < obj->def->ndisks; i++) { if (qemuTranslateDiskSourcePool(conn, obj->def->disks[i]) < 0)