[PATCH 14/18] qemuBuildHostdevSCSICommandLine: Use new infrastructure

Peter Krempa pkrempa at redhat.com
Fri Jul 10 14:33:35 UTC 2020


In preparation for instantiating (i)SCSI hostdevs via -blockdev,
refactor qemuBuildHostdevSCSICommandLine to use the new infrastructure
which will do it automatically.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_command.c | 44 ++++-------------------------------------
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6b3b1b39ca..7f624a031e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -695,27 +695,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
 }


-/* qemuBuildDiskSecinfoCommandLine:
- * @cmd: Pointer to the command string
- * @secinfo: Pointer to a possible secinfo
- *
- * Add the secret object for the disks that will be using it to perform
- * their authentication.
- *
- * Returns 0 on success, -1 w/ error on some sort of failure.
- */
-static int
-qemuBuildDiskSecinfoCommandLine(virCommandPtr cmd,
-                                qemuDomainSecretInfoPtr secinfo)
-{
-    /* Not necessary for non AES secrets */
-    if (!secinfo || secinfo->type != VIR_DOMAIN_SECRET_INFO_TYPE_AES)
-        return 0;
-
-    return qemuBuildObjectSecretCommandLine(cmd, secinfo);
-}
-
-
 /* qemuBuildGeneralSecinfoURI:
  * @uri: Pointer to the URI structure to add to
  * @secinfo: Pointer to the secret info data (if present)
@@ -5151,29 +5130,14 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd,
                                 virDomainHostdevDefPtr hostdev,
                                 virQEMUCapsPtr qemuCaps)
 {
-    virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+    g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
     g_autofree char *devstr = NULL;
-    g_autofree char *drvstr = NULL;
-    g_autofree char *backendAlias = NULL;
+    const char *backendAlias = NULL;

-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
-        virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =
-            &scsisrc->u.iscsi;
-        qemuDomainStorageSourcePrivatePtr srcPriv =
-            QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
-
-        if (qemuBuildDiskSecinfoCommandLine(cmd, srcPriv ?
-                                            srcPriv->secinfo :
-                                            NULL) < 0)
-            return -1;
-    }
-
-    virCommandAddArg(cmd, "-drive");
-    if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps)))
+    if (!(data = qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendAlias, qemuCaps)))
         return -1;
-    virCommandAddArg(cmd, drvstr);

-    if (!(backendAlias = qemuAliasFromHostdev(hostdev)))
+    if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0)
         return -1;

     virCommandAddArg(cmd, "-device");
-- 
2.26.2




More information about the libvir-list mailing list