Its only use was to check conflicts of the sgio attributes between
devices shared with other domains.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_conf.c | 292 ----------------------------------------
src/qemu/qemu_conf.h | 35 -----
src/qemu/qemu_driver.c | 3 -
src/qemu/qemu_hostdev.c | 28 ----
src/qemu/qemu_hotplug.c | 20 ---
src/qemu/qemu_process.c | 27 +---
6 files changed, 1 insertion(+), 404 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 28cbdd6e61..81449b8b77 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1450,298 +1450,6 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *driver,
}
-struct _qemuSharedDeviceEntry {
- size_t ref;
- char **domains; /* array of domain names */
-};
-
-/* Construct the hash key for sharedDevices as "major:minor" */
-char *
-qemuGetSharedDeviceKey(const char *device_path)
-{
- int maj, min;
- int rc;
-
- if ((rc = virGetDeviceID(device_path, &maj, &min)) < 0) {
- virReportSystemError(-rc,
- _("Unable to get minor number of device
'%s'"),
- device_path);
- return NULL;
- }
-
- return g_strdup_printf("%d:%d", maj, min);
-}
-
-
-bool
-qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntry *entry,
- const char *name,
- int *idx)
-{
- size_t i;
-
- for (i = 0; i < entry->ref; i++) {
- if (STREQ(entry->domains[i], name)) {
- if (idx)
- *idx = i;
- return true;
- }
- }
-
- return false;
-}
-
-void
-qemuSharedDeviceEntryFree(void *payload)
-{
- qemuSharedDeviceEntry *entry = payload;
- size_t i;
-
- if (!entry)
- return;
-
- for (i = 0; i < entry->ref; i++)
- g_free(entry->domains[i]);
- g_free(entry->domains);
- g_free(entry);
-}
-
-
-static int
-qemuSharedDeviceEntryInsert(virQEMUDriver *driver,
- const char *key,
- const char *name)
-{
- qemuSharedDeviceEntry *entry = NULL;
-
- if ((entry = virHashLookup(driver->sharedDevices, key))) {
- /* Nothing to do if the shared scsi host device is already
- * recorded in the table.
- */
- if (!qemuSharedDeviceEntryDomainExists(entry, name, NULL)) {
- VIR_EXPAND_N(entry->domains, entry->ref, 1);
- entry->domains[entry->ref - 1] = g_strdup(name);
- }
- } else {
- entry = g_new0(qemuSharedDeviceEntry, 1);
- entry->domains = g_new0(char *, 1);
-
- entry->domains[0] = g_strdup(name);
-
- entry->ref = 1;
-
- if (virHashAddEntry(driver->sharedDevices, key, entry) < 0)
- goto error;
- }
-
- return 0;
-
- error:
- qemuSharedDeviceEntryFree(entry);
- return -1;
-}
-
-
-static int
-qemuSharedDeviceEntryRemove(virQEMUDriver *driver,
- const char *key,
- const char *name)
-{
- qemuSharedDeviceEntry *entry = NULL;
- int idx;
-
- if (!(entry = virHashLookup(driver->sharedDevices, key)))
- return -1;
-
- /* Nothing to do if the shared disk is not recorded in the table. */
- if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx))
- return 0;
-
- if (entry->ref != 1) {
- VIR_FREE(entry->domains[idx]);
- VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref);
- } else {
- ignore_value(virHashRemoveEntry(driver->sharedDevices, key));
- }
-
- return 0;
-}
-
-
-static int
-qemuSharedDiskAddRemoveInternal(virQEMUDriver *driver,
- virDomainDiskDef *disk,
- const char *name,
- bool addDisk)
-{
- g_autofree char *key = NULL;
- int ret = -1;
-
- if (virStorageSourceIsEmpty(disk->src) ||
- !disk->src->shared ||
- !virStorageSourceIsBlockLocal(disk->src))
- return 0;
-
- qemuDriverLock(driver);
-
- if (!(key = qemuGetSharedDeviceKey(virDomainDiskGetSource(disk))))
- goto cleanup;
-
- if (addDisk) {
- if (qemuSharedDeviceEntryInsert(driver, key, name) < 0)
- goto cleanup;
- } else {
- if (qemuSharedDeviceEntryRemove(driver, key, name) < 0)
- goto cleanup;
- }
-
- ret = 0;
- cleanup:
- qemuDriverUnlock(driver);
- return ret;
-}
-
-
-/* qemuAddSharedDisk:
- * @driver: Pointer to qemu driver struct
- * @src: disk source
- * @name: The domain name
- *
- * Increase ref count and add the domain name into the list which
- * records all the domains that use the shared device if the entry
- * already exists, otherwise add a new entry.
- */
-int
-qemuAddSharedDisk(virQEMUDriver *driver,
- virDomainDiskDef *disk,
- const char *name)
-{
- return qemuSharedDiskAddRemoveInternal(driver, disk, name, true);
-}
-
-
-static bool
-qemuIsSharedHostdev(virDomainHostdevDef *hostdev)
-{
- return (hostdev->shareable &&
- (virHostdevIsSCSIDevice(hostdev) &&
- hostdev->source.subsys.u.scsi.protocol !=
- VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI));
-}
-
-
-static char *
-qemuGetHostdevPath(virDomainHostdevDef *hostdev)
-{
- virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi;
- virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host;
- g_autofree char *dev_name = NULL;
-
- if (!(dev_name = virSCSIDeviceGetDevName(NULL,
- scsihostsrc->adapter,
- scsihostsrc->bus,
- scsihostsrc->target,
- scsihostsrc->unit)))
- return NULL;
-
- return g_strdup_printf("/dev/%s", dev_name);
-}
-
-
-static int
-qemuSharedHostdevAddRemoveInternal(virQEMUDriver *driver,
- virDomainHostdevDef *hostdev,
- const char *name,
- bool addDevice)
-{
- g_autofree char *dev_path = NULL;
- g_autofree char *key = NULL;
- int ret = -1;
-
- if (!qemuIsSharedHostdev(hostdev))
- return 0;
-
- if (!(dev_path = qemuGetHostdevPath(hostdev)) ||
- !(key = qemuGetSharedDeviceKey(dev_path)))
- return -1;
-
- qemuDriverLock(driver);
-
- if (addDevice)
- ret = qemuSharedDeviceEntryInsert(driver, key, name);
- else
- ret = qemuSharedDeviceEntryRemove(driver, key, name);
-
- qemuDriverUnlock(driver);
-
- return ret;
-}
-
-static int
-qemuSharedDeviceAddRemoveInternal(virQEMUDriver *driver,
- virDomainDeviceDef *dev,
- const char *name,
- bool addDevice)
-{
- /* Currently the only conflicts we have to care about for
- * the shared disk and shared host device is "sgio" setting,
- * which is only valid for block disk and scsi host device.
- */
- if (dev->type == VIR_DOMAIN_DEVICE_DISK)
- return qemuSharedDiskAddRemoveInternal(driver, dev->data.disk,
- name, addDevice);
- if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV)
- return qemuSharedHostdevAddRemoveInternal(driver, dev->data.hostdev,
- name, addDevice);
- return 0;
-}
-
-
-/* qemuAddSharedDevice:
- * @driver: Pointer to qemu driver struct
- * @dev: The device def
- * @name: The domain name
- *
- * Increase ref count and add the domain name into the list which
- * records all the domains that use the shared device if the entry
- * already exists, otherwise add a new entry.
- */
-int
-qemuAddSharedDevice(virQEMUDriver *driver,
- virDomainDeviceDef *dev,
- const char *name)
-{
- return qemuSharedDeviceAddRemoveInternal(driver, dev, name, true);
-}
-
-
-int
-qemuRemoveSharedDisk(virQEMUDriver *driver,
- virDomainDiskDef *disk,
- const char *name)
-{
- return qemuSharedDiskAddRemoveInternal(driver, disk, name, false);
-}
-
-
-/* qemuRemoveSharedDevice:
- * @driver: Pointer to qemu driver struct
- * @device: The device def
- * @name: The domain name
- *
- * Decrease ref count and remove the domain name from the list which
- * records all the domains that use the shared device if ref is not
- * 1, otherwise remove the entry.
- */
-int
-qemuRemoveSharedDevice(virQEMUDriver *driver,
- virDomainDeviceDef *dev,
- const char *name)
-{
- return qemuSharedDeviceAddRemoveInternal(driver, dev, name, false);
-}
-
-
int qemuDriverAllocateID(virQEMUDriver *driver)
{
return g_atomic_int_add(&driver->lastvmid, 1) + 1;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 5961b0b205..c71a666aea 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -292,9 +292,6 @@ struct _virQEMUDriver {
virHostdevManager *hostdevMgr;
- /* Immutable pointer. Unsafe APIs. XXX */
- GHashTable *sharedDevices;
-
/* Immutable pointer, immutable object */
virPortAllocatorRange *remotePorts;
@@ -344,38 +341,6 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *driver,
virArch arch,
virDomainVirtType virttype);
-typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry;
-
-bool qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntry *entry,
- const char *name,
- int *idx)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-
-char *qemuGetSharedDeviceKey(const char *disk_path)
- ATTRIBUTE_NONNULL(1);
-
-void qemuSharedDeviceEntryFree(void *payload);
-
-int qemuAddSharedDisk(virQEMUDriver *driver,
- virDomainDiskDef *disk,
- const char *name)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-
-int qemuAddSharedDevice(virQEMUDriver *driver,
- virDomainDeviceDef *dev,
- const char *name)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-
-int qemuRemoveSharedDevice(virQEMUDriver *driver,
- virDomainDeviceDef *dev,
- const char *name)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-
-int qemuRemoveSharedDisk(virQEMUDriver *driver,
- virDomainDiskDef *disk,
- const char *name)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-
int qemuDriverAllocateID(virQEMUDriver *driver);
virDomainXMLOption *virQEMUDriverCreateXMLConf(virQEMUDriver *driver,
const char *defsecmodel);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 65ac5ef367..028b53b4ad 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -735,8 +735,6 @@ qemuStateInitialize(bool privileged,
if (!(qemu_driver->hostdevMgr = virHostdevManagerGetDefault()))
goto error;
- qemu_driver->sharedDevices = virHashNew(qemuSharedDeviceEntryFree);
-
if (qemuMigrationDstErrorInit(qemu_driver) < 0)
goto error;
@@ -1078,7 +1076,6 @@ qemuStateCleanup(void)
virPortAllocatorRangeFree(qemu_driver->migrationPorts);
virPortAllocatorRangeFree(qemu_driver->webSocketPorts);
virPortAllocatorRangeFree(qemu_driver->remotePorts);
- g_clear_pointer(&qemu_driver->sharedDevices, g_hash_table_unref);
virObjectUnref(qemu_driver->hostdevMgr);
virObjectUnref(qemu_driver->securityManager);
virObjectUnref(qemu_driver->domainEventState);
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 5461de459a..dfe657c51e 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -272,25 +272,8 @@ qemuHostdevPrepareSCSIDevices(virQEMUDriver *driver,
virDomainHostdevDef **hostdevs,
int nhostdevs)
{
- size_t i;
virHostdevManager *hostdev_mgr = driver->hostdevMgr;
- /* Loop 1: Add the shared scsi host device to shared device
- * table.
- */
- for (i = 0; i < nhostdevs; i++) {
- virDomainDeviceDef dev;
-
- if (!virHostdevIsSCSIDevice(hostdevs[i]))
- continue;
-
- dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
- dev.data.hostdev = hostdevs[i];
-
- if (qemuAddSharedDevice(driver, &dev, name) < 0)
- return -1;
- }
-
return virHostdevPrepareSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
name, hostdevs, nhostdevs);
}
@@ -426,19 +409,8 @@ qemuHostdevReAttachSCSIDevices(virQEMUDriver *driver,
virDomainHostdevDef **hostdevs,
int nhostdevs)
{
- size_t i;
virHostdevManager *hostdev_mgr = driver->hostdevMgr;
- for (i = 0; i < nhostdevs; i++) {
- virDomainHostdevDef *hostdev = hostdevs[i];
- virDomainDeviceDef dev;
-
- dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
- dev.data.hostdev = hostdev;
-
- ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
- }
-
virHostdevReAttachSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
name, hostdevs, nhostdevs);
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0dd3121221..9dc74d89d2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -603,7 +603,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver,
qemuDomainObjPrivate *priv = vm->privateData;
virStorageSource *oldsrc = disk->src;
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- bool sharedAdded = false;
bool managedpr = virStorageSourceChainHasManagedPR(oldsrc) ||
virStorageSourceChainHasManagedPR(newsrc);
int ret = -1;
@@ -620,11 +619,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver,
if (virDomainDiskTranslateSourcePool(disk) < 0)
goto cleanup;
- if (qemuAddSharedDisk(driver, disk, vm->def->name) < 0)
- goto cleanup;
-
- sharedAdded = true;
-
if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
goto cleanup;
@@ -649,7 +643,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver,
/* remove the old source from shared device list */
disk->src = oldsrc;
- ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, oldsrc));
/* media was changed, so we can remove the old media definition now */
@@ -662,9 +655,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver,
cleanup:
/* undo changes to the new disk */
if (ret < 0) {
- if (sharedAdded)
- ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
-
ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, newsrc));
}
@@ -977,9 +967,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
if (virDomainDiskTranslateSourcePool(disk) < 0)
goto cleanup;
- if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
- goto cleanup;
-
if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
goto cleanup;
@@ -1076,8 +1063,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
cleanup:
if (ret < 0) {
- ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name));
-
if (releaseUSB)
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
@@ -4418,7 +4403,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
{
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
g_autoptr(qemuBlockStorageSourceChainData) diskBackend = NULL;
- virDomainDeviceDef dev;
size_t i;
qemuDomainObjPrivate *priv = vm->privateData;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
@@ -4482,10 +4466,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
if (diskBackend)
qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src);
- dev.type = VIR_DOMAIN_DEVICE_DISK;
- dev.data.disk = disk;
- ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
-
if (virStorageSourceChainHasManagedPR(disk->src) &&
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b425acfec1..6203efef3a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5022,7 +5022,7 @@ qemuProcessSetupGraphics(virQEMUDriver *driver,
static int
-qemuProcessSetupRawIO(virQEMUDriver *driver,
+qemuProcessSetupRawIO(virQEMUDriver *driver G_GNUC_UNUSED,
virDomainObj *vm,
virCommand *cmd G_GNUC_UNUSED)
{
@@ -5032,7 +5032,6 @@ qemuProcessSetupRawIO(virQEMUDriver *driver,
/* in case a certain disk is desirous of CAP_SYS_RAWIO, add this */
for (i = 0; i < vm->def->ndisks; i++) {
- virDomainDeviceDef dev;
virDomainDiskDef *disk = vm->def->disks[i];
if (disk->rawio == VIR_TRISTATE_BOOL_YES) {
@@ -5041,11 +5040,6 @@ qemuProcessSetupRawIO(virQEMUDriver *driver,
break;
#endif
}
-
- dev.type = VIR_DOMAIN_DEVICE_DISK;
- dev.data.disk = disk;
- if (qemuAddSharedDevice(driver, &dev, vm->def->name) < 0)
- goto cleanup;
}
/* If rawio not already set, check hostdevs as well */
@@ -5066,7 +5060,6 @@ qemuProcessSetupRawIO(virQEMUDriver *driver,
ret = 0;
- cleanup:
if (rawio) {
#ifdef CAP_SYS_RAWIO
if (ret == 0)
@@ -8134,15 +8127,6 @@ void qemuProcessStop(virQEMUDriver *driver,
qemuSecurityRestoreAllLabel(driver, vm,
!!(flags & VIR_QEMU_PROCESS_STOP_MIGRATED));
- for (i = 0; i < vm->def->ndisks; i++) {
- virDomainDeviceDef dev;
- virDomainDiskDef *disk = vm->def->disks[i];
-
- dev.type = VIR_DOMAIN_DEVICE_DISK;
- dev.data.disk = disk;
- ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
- }
-
/* Clear out dynamically assigned labels */
for (i = 0; i < vm->def->nseclabels; i++) {
if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC)
@@ -8789,12 +8773,8 @@ qemuProcessReconnect(void *opaque)
if (qemuDomainInitializePflashStorageSource(obj) < 0)
goto error;
- /* XXX: Need to change as long as lock is introduced for
- * qemu_driver->sharedDevices.
- */
for (i = 0; i < obj->def->ndisks; i++) {
virDomainDiskDef *disk = obj->def->disks[i];
- virDomainDeviceDef dev;
if (virDomainDiskTranslateSourcePool(disk) < 0)
goto error;
@@ -8811,11 +8791,6 @@ qemuProcessReconnect(void *opaque)
} else {
VIR_DEBUG("skipping backing chain detection for '%s'",
disk->dst);
}
-
- dev.type = VIR_DOMAIN_DEVICE_DISK;
- dev.data.disk = disk;
- if (qemuAddSharedDevice(driver, &dev, obj->def->name) < 0)
- goto error;
}
for (i = 0; i < obj->def->ngraphics; i++) {
--
2.31.1