[REPOST PATCH v6 4/8] qemu: Refactor qemuBuildSCSIiSCSIHostdevDrvStr slightly

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

 



Rather than building the "file" string in qemuBuildSCSIHostdevDrvStr
build it in the called helper.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 70a389f2a3..577c76b44b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4895,15 +4895,22 @@ static char *
 qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
 {
     char *source = NULL;
+    char *netsource = NULL;
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
     qemuDomainStorageSourcePrivatePtr srcPriv =
         QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
 
     /* Rather than pull what we think we want - use the network disk code */
-    source = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ?
-                                      srcPriv->secinfo : NULL);
+    netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ?
+                                         srcPriv->secinfo : NULL);
+    if (!netsource)
+        goto cleanup;
+    if (virAsprintf(&source, "file=%s,if=none,format=raw", netsource) < 0)
+        goto cleanup;
 
+ cleanup:
+    VIR_FREE(netsource);
     return source;
 }
 
@@ -4956,7 +4963,7 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
     if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
         if (!(source = qemuBuildSCSIiSCSIHostdevDrvStr(dev)))
             goto error;
-        virBufferAsprintf(&buf, "file=%s,if=none,format=raw", source);
+        virBufferAsprintf(&buf, "%s", source);
     } else {
         if (!(source = qemuBuildSCSIHostHostdevDrvStr(dev)))
             goto error;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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