[PATCH v5 13/16] 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 | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 21f024fb88..47fa307097 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4952,13 +4952,20 @@ static char *
 qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
 {
     char *source = NULL;
+    char *netsource = NULL;
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
     qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(iscsisrc->src);
 
     /* Rather than pull what we think we want - use the network disk code */
-    source = qemuBuildNetworkDriveStr(iscsisrc->src, diskSrcPriv->secinfo);
+    netsource = qemuBuildNetworkDriveStr(iscsisrc->src, diskSrcPriv->secinfo);
+    if (!netsource)
+        goto cleanup;
+    if (virAsprintf(&source, "file=%s,if=none,format=raw", netsource) < 0)
+        goto cleanup;
 
+ cleanup:
+    VIR_FREE(netsource);
     return source;
 }
 
@@ -5011,7 +5018,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