[PATCH 18/80] qemu: Remove code conditional on QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 142 +++++++++++-----------------------------
 src/qemu/qemu_domain.c  |  18 ++---
 2 files changed, 43 insertions(+), 117 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cb54190780..e0c5e15a63 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5091,27 +5091,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,
@@ -5138,32 +5117,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,
@@ -5286,41 +5239,34 @@ 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;
-
-        case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
-            src = scsisrc->u.iscsi.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_LAST:
-        default:
-            virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol);
-            return NULL;
-        }
+    case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
+        src = scsisrc->u.iscsi.src;
+        break;

-        srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
-        ret->storageNodeName = src->nodestorage;
-        ret->storageAttached = true;
+    case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST:
+    default:
+        virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol);
+        return NULL;
+    }

-        if (srcpriv && srcpriv->secinfo)
-            ret->authsecretAlias = g_strdup(srcpriv->secinfo->alias);
+    srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
+    ret->storageNodeName = src->nodestorage;
+    ret->storageAttached = true;

-    } else {
-        ret->driveAlias = qemuAliasFromHostdev(hostdev);
-        ret->driveAdded = true;
-    }
+    if (srcpriv && srcpriv->secinfo)
+        ret->authsecretAlias = g_strdup(srcpriv->secinfo->alias);

     return g_steal_pointer(&ret);
 }
@@ -5329,45 +5275,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;
-
-        case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
-            src = scsisrc->u.iscsi.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_LAST:
-        default:
-            virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol);
-            return NULL;
-        }
+    case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
+        src = scsisrc->u.iscsi.src;
+        break;

-        ret->storageNodeName = src->nodestorage;
-        *backendAlias = src->nodestorage;
+    case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST:
+    default:
+        virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol);
+        return NULL;
+    }

-        if (!(ret->storageProps = qemuBlockStorageSourceGetBackendProps(src,
-                                                                        QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP)))
-            return NULL;
+    ret->storageNodeName = src->nodestorage;
+    *backendAlias = src->nodestorage;

-    } 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 (!(ret->storageProps = qemuBlockStorageSourceGetBackendProps(src,
+                                                                    QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP)))
+        return NULL;

-    if (src &&
-        qemuBuildStorageSourceAttachPrepareCommon(src, ret) < 0)
+    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 245cae9c60..d45c5d30a9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5718,7 +5718,6 @@ qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(virDomainHostdevDef *hostdev,
  */
 static int
 qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(virDomainHostdevDef *hostdev,
-                                                       virQEMUCaps *qemuCaps,
                                                        unsigned int parseFlags)
 {
     virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi;
@@ -5727,11 +5726,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)
@@ -5782,8 +5776,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 &&
@@ -11018,12 +11011,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;
-- 
2.36.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux