[PATCH v2 03/10] qemu: Introduce qemuGetHostdevPath

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

 



Introduce a convenience function to handle formulating the hostdev path

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 48fb74a..f82244f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1213,15 +1213,13 @@ qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
     return false;
 }
 
-
 static char *
-qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
+qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
 {
     virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
     char *dev_name = NULL;
     char *dev_path = NULL;
-    char *key = NULL;
 
     if (!(dev_name = virSCSIDeviceGetDevName(NULL,
                                              scsihostsrc->adapter,
@@ -1230,14 +1228,27 @@ qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
                                              scsihostsrc->unit)))
         goto cleanup;
 
-    if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
+    ignore_value(virAsprintf(&dev_path, "/dev/%s", dev_name));
+
+ cleanup:
+    VIR_FREE(dev_name);
+    return dev_path;
+}
+
+
+static char *
+qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
+{
+    char *key = NULL;
+    char *dev_path = NULL;
+
+    if (!(dev_path = qemuGetHostdevPath(hostdev)))
         goto cleanup;
 
     if (!(key = qemuGetSharedDeviceKey(dev_path)))
         goto cleanup;
 
  cleanup:
-    VIR_FREE(dev_name);
     VIR_FREE(dev_path);
 
     return key;
-- 
2.1.0

--
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]