qemu: Remove code conditional on QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI

Now that QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI is always set we can remove the
code which handled cases when the capability was not set.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-07-19 13:04:16 +02:00
parent ebfa1fb0f9
commit dc8dbb27d4
2 changed files with 45 additions and 119 deletions

View File

@ -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,12 +5231,10 @@ 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);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) {
virStorageSource *src;
qemuDomainStorageSourcePrivate *srcpriv;
@ -5309,11 +5260,6 @@ qemuBuildHostdevSCSIDetachPrepare(virDomainHostdevDef *hostdev,
if (srcpriv && srcpriv->secinfo)
ret->authsecretAlias = g_strdup(srcpriv->secinfo->alias);
} else {
ret->driveAlias = qemuAliasFromHostdev(hostdev);
ret->driveAdded = true;
}
return g_steal_pointer(&ret);
}
@ -5321,13 +5267,12 @@ 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;
@ -5350,16 +5295,7 @@ qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDef *hostdev,
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;
}
if (src &&
qemuBuildStorageSourceAttachPrepareCommon(src, ret) < 0)
if (qemuBuildStorageSourceAttachPrepareCommon(src, ret) < 0)
return NULL;
return g_steal_pointer(&ret);

View File

@ -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;
}
if (src->auth) {
virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;