diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 27910efa37..6c459f2494 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5083,27 +5083,6 @@ qemuBuildHubCommandLine(virCommand *cmd, } -static char * -qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef *dev) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - g_autoptr(virJSONValue) srcprops = NULL; - virDomainHostdevSubsysSCSI *scsisrc = &dev->source.subsys.u.scsi; - virDomainHostdevSubsysSCSIiSCSI *iscsisrc = &scsisrc->u.iscsi; - - if (!(srcprops = qemuDiskSourceGetProps(iscsisrc->src))) - return NULL; - - if (virQEMUBuildCommandLineJSON(srcprops, &buf, NULL, - virQEMUBuildCommandLineJSONArrayNumbered) < 0) - return NULL; - - virBufferAddLit(&buf, ",if=none,format=raw"); - - return virBufferContentAndReset(&buf); -} - - virJSONValue * qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, virDomainHostdevDef *dev, @@ -5130,32 +5109,6 @@ qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, } -static char * -qemuBuildSCSIHostdevDrvStr(virDomainHostdevDef *dev) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - g_autofree char *source = NULL; - g_autofree char *drivealias = NULL; - virDomainHostdevSubsysSCSI *scsisrc = &dev->source.subsys.u.scsi; - - if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { - if (!(source = qemuBuildSCSIiSCSIHostdevDrvStr(dev))) - return NULL; - virBufferAdd(&buf, source, -1); - } else { - virBufferAsprintf(&buf, "file=%s,if=none,format=raw", scsisrc->u.host.src->path); - } - - if (!(drivealias = qemuAliasFromHostdev(dev))) - return NULL; - virBufferAsprintf(&buf, ",id=%s", drivealias); - - if (dev->readonly) - virBufferAddLit(&buf, ",readonly=on"); - - return virBufferContentAndReset(&buf); -} - virJSONValue * qemuBuildSCSIHostdevDevProps(const virDomainDef *def, virDomainHostdevDef *dev, @@ -5278,42 +5231,35 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def, qemuBlockStorageSourceAttachData * qemuBuildHostdevSCSIDetachPrepare(virDomainHostdevDef *hostdev, - virQEMUCaps *qemuCaps) + virQEMUCaps *qemuCaps G_GNUC_UNUSED) { virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; g_autoptr(qemuBlockStorageSourceAttachData) ret = g_new0(qemuBlockStorageSourceAttachData, 1); + virStorageSource *src; + qemuDomainStorageSourcePrivate *srcpriv; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) { - virStorageSource *src; - qemuDomainStorageSourcePrivate *srcpriv; + switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: + src = scsisrc->u.host.src; + break; - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: - src = scsisrc->u.host.src; - break; + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: + src = scsisrc->u.iscsi.src; + break; - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: - src = scsisrc->u.iscsi.src; - break; - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: - default: - virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); - return NULL; - } - - srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); - ret->storageNodeName = src->nodestorage; - ret->storageAttached = true; - - if (srcpriv && srcpriv->secinfo) - ret->authsecretAlias = g_strdup(srcpriv->secinfo->alias); - - } else { - ret->driveAlias = qemuAliasFromHostdev(hostdev); - ret->driveAdded = true; + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: + default: + virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); + return NULL; } + srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); + ret->storageNodeName = src->nodestorage; + ret->storageAttached = true; + + if (srcpriv && srcpriv->secinfo) + ret->authsecretAlias = g_strdup(srcpriv->secinfo->alias); + return g_steal_pointer(&ret); } @@ -5321,45 +5267,35 @@ qemuBuildHostdevSCSIDetachPrepare(virDomainHostdevDef *hostdev, qemuBlockStorageSourceAttachData * qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDef *hostdev, const char **backendAlias, - virQEMUCaps *qemuCaps) + virQEMUCaps *qemuCaps G_GNUC_UNUSED) { virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; g_autoptr(qemuBlockStorageSourceAttachData) ret = g_new0(qemuBlockStorageSourceAttachData, 1); virStorageSource *src = NULL; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) { - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: - src = scsisrc->u.host.src; - break; + switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: + src = scsisrc->u.host.src; + break; - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: - src = scsisrc->u.iscsi.src; - break; + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: + src = scsisrc->u.iscsi.src; + break; - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: - default: - virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); - return NULL; - } - - ret->storageNodeName = src->nodestorage; - *backendAlias = src->nodestorage; - - if (!(ret->storageProps = qemuBlockStorageSourceGetBackendProps(src, - QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP))) - return NULL; - - } else { - if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) - src = scsisrc->u.iscsi.src; - ret->driveCmd = qemuBuildSCSIHostdevDrvStr(hostdev); - ret->driveAlias = qemuAliasFromHostdev(hostdev); - *backendAlias = ret->driveAlias; + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: + default: + virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); + return NULL; } - if (src && - qemuBuildStorageSourceAttachPrepareCommon(src, ret) < 0) + ret->storageNodeName = src->nodestorage; + *backendAlias = src->nodestorage; + + if (!(ret->storageProps = qemuBlockStorageSourceGetBackendProps(src, + QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP))) + return NULL; + + if (qemuBuildStorageSourceAttachPrepareCommon(src, ret) < 0) return NULL; return g_steal_pointer(&ret); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 58adda7ec4..4d27ae2282 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5627,7 +5627,6 @@ qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(virDomainHostdevDef *hostdev, */ static int qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(virDomainHostdevDef *hostdev, - virQEMUCaps *qemuCaps, unsigned int parseFlags) { virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; @@ -5636,11 +5635,6 @@ qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(virDomainHostdevDef *host if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_STATUS)) return 0; - if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || - hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) - return 0; - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: if (!scsisrc->u.host.src) @@ -5691,8 +5685,7 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDef *hostdev, if (qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(hostdev, parseFlags) < 0) return -1; - if (qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(hostdev, qemuCaps, - parseFlags) < 0) + if (qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(hostdev, parseFlags) < 0) return -1; if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && @@ -10921,12 +10914,9 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, const char *backendalias = hostdev->info->alias; src->readonly = hostdev->readonly; - - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) { - src->id = qemuDomainStorageIDNew(priv); - src->nodestorage = g_strdup_printf("libvirt-%d-backend", src->id); - backendalias = src->nodestorage; - } + src->id = qemuDomainStorageIDNew(priv); + src->nodestorage = g_strdup_printf("libvirt-%d-backend", src->id); + backendalias = src->nodestorage; if (src->auth) { virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;