qemuDomainRemoveHostDevice: Use new infrastructure for (i)SCSI

Similarly to previous commits, modify the hostdev detach code to use
blockdev infrastructure to detach (i)SCSI hostdevs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-06-19 15:51:06 +02:00
parent 3455acebf8
commit 8d243d257f

View File

@ -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;
}