"Shared disk" is not only the thing we should care about after "scsi
hostdev" is introduced. A same scsi device can be used as "disk" for
one domain, and as "scsi hostdev" for another domain at the same time.
That's why this patch renames qemu_driver->sharedDisks. Related functions
and structs are also renamed.
---
src/qemu/qemu_conf.c | 76 ++++++++++++++++++++++++-------------------------
src/qemu/qemu_conf.h | 16 +++++------
src/qemu/qemu_driver.c | 4 +--
src/qemu/qemu_process.c | 2 +-
4 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c16b90d..244795d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -915,23 +915,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;
}
@@ -951,7 +951,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;
@@ -976,7 +976,7 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks,
if (!virFileExists(sysfs_path))
goto cleanup;
- if (!(key = qemuGetSharedDiskKey(disk->src))) {
+ if (!(key = qemuGetSharedDeviceKey(disk->src))) {
ret = -1;
goto cleanup;
}
@@ -984,7 +984,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) {
@@ -1020,9 +1020,9 @@ cleanup:
}
bool
-qemuSharedDiskEntryDomainExists(qemuSharedDiskEntryPtr entry,
- const char *name,
- int *idx)
+qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry,
+ const char *name,
+ int *idx)
{
size_t i;
@@ -1038,9 +1038,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)
@@ -1053,10 +1053,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) {
@@ -1080,7 +1080,7 @@ qemuSharedDiskEntryCopy(const qemuSharedDiskEntryPtr entry)
return ret;
cleanup:
- qemuSharedDiskEntryFree(ret, NULL);
+ qemuSharedDeviceEntryFree(ret, NULL);
return NULL;
}
@@ -1098,8 +1098,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;
@@ -1116,47 +1116,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;
}
@@ -1181,8 +1181,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;
@@ -1196,22 +1196,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)
@@ -1221,12 +1221,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 30a2a22..d4a54a0 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -207,7 +207,7 @@ struct _virQEMUDriver {
virSCSIDeviceListPtr activeScsiHostdevs;
/* Immutable pointer. Unsafe APIs. XXX */
- virHashTablePtr sharedDisks;
+ virHashTablePtr sharedDevices;
/* Immutable pointer, self-locking APIs */
virPortAllocatorPtr remotePorts;
@@ -275,12 +275,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,
@@ -293,10 +293,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 b631a1f..4c2ab7b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -678,7 +678,7 @@ qemuStateInitialize(bool privileged,
if (!(qemu_driver->activeScsiHostdevs = virSCSIDeviceListNew()))
goto error;
- if (!(qemu_driver->sharedDisks = virHashCreate(30, qemuSharedDiskEntryFree)))
+ if (!(qemu_driver->sharedDevices = virHashCreate(30, qemuSharedDeviceEntryFree)))
goto error;
if (privileged) {
@@ -949,7 +949,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 ff5fc89..70eadb6 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)
--
1.8.1.4