From 8d243d257f6b142f7116cdb4e73547fc3b5f76ac Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 19 Jun 2020 15:51:06 +0200 Subject: [PATCH] qemuDomainRemoveHostDevice: Use new infrastructure for (i)SCSI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similarly to previous commits, modify the hostdev detach code to use blockdev infrastructure to detach (i)SCSI hostdevs. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_hotplug.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9fd4d58a7f..26912334d2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4442,31 +4442,17 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, virDomainNetDefPtr net = NULL; size_t i; qemuDomainObjPrivatePtr priv = vm->privateData; - g_autofree char *drivealias = NULL; - const char *secretObjAlias = NULL; VIR_DEBUG("Removing host device %s from domain %p %s", hostdev->info->alias, vm, vm->def->name); if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { - virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; - virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi; + g_autoptr(qemuBlockStorageSourceAttachData) detachscsi = NULL; - if (!(drivealias = qemuAliasFromHostdev(hostdev))) - return -1; - - if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { - qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src); - if (srcPriv && srcPriv->secinfo) - secretObjAlias = srcPriv->secinfo->s.aes.alias; - } + detachscsi = qemuBuildHostdevSCSIDetachPrepare(hostdev, priv->qemuCaps); qemuDomainObjEnterMonitor(driver, vm); - qemuMonitorDriveDel(priv->mon, drivealias); - - if (secretObjAlias) - ignore_value(qemuMonitorDelObject(priv->mon, secretObjAlias, false)); - + qemuBlockStorageSourceAttachRollback(priv->mon, detachscsi); if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; }