render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From 352a07737fdc9a3c090eee92018f62865889c0ea Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <352a07737fdc9a3c090eee92018f62865889c0ea@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Thu, 9 Jul 2015 08:28:52 -0400
7a3408
Subject: [PATCH] qemu: Introduce qemuGetHostdevPath
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1072736
7a3408
7a3408
Introduce a convenience function to handle formulating the hostdev path
7a3408
7a3408
Signed-off-by: John Ferlan <jferlan@redhat.com>
7a3408
(cherry picked from commit 083cbe506b5134c36ecd544a2f9ac3d262951799)
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_conf.c | 27 ++++++++++++++++++++-------
7a3408
 1 file changed, 20 insertions(+), 7 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
7a3408
index 1467427..a761ec5 100644
7a3408
--- a/src/qemu/qemu_conf.c
7a3408
+++ b/src/qemu/qemu_conf.c
7a3408
@@ -1213,13 +1213,12 @@ qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
7a3408
 
7a3408
 
7a3408
 static char *
7a3408
-qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
7a3408
+qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
7a3408
 {
7a3408
     virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
7a3408
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
7a3408
     char *dev_name = NULL;
7a3408
     char *dev_path = NULL;
7a3408
-    char *key = NULL;
7a3408
 
7a3408
     if (!(dev_name = virSCSIDeviceGetDevName(NULL,
7a3408
                                              scsihostsrc->adapter,
7a3408
@@ -1228,19 +1227,33 @@ qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
7a3408
                                              scsihostsrc->unit)))
7a3408
         goto cleanup;
7a3408
 
7a3408
-    if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
7a3408
-        goto cleanup;
7a3408
-
7a3408
-    if (!(key = qemuGetSharedDeviceKey(dev_path)))
7a3408
-        goto cleanup;
7a3408
+    ignore_value(virAsprintf(&dev_path, "/dev/%s", dev_name));
7a3408
 
7a3408
  cleanup:
7a3408
     VIR_FREE(dev_name);
7a3408
+    return dev_path;
7a3408
+}
7a3408
+
7a3408
+
7a3408
+static char *
7a3408
+qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
7a3408
+{
7a3408
+    char *key = NULL;
7a3408
+    char *dev_path = NULL;
7a3408
+
7a3408
+    if (!(dev_path = qemuGetHostdevPath(hostdev)))
7a3408
+        goto cleanup;
7a3408
+
7a3408
+    if (!(key = qemuGetSharedDeviceKey(dev_path)))
7a3408
+        goto cleanup;
7a3408
+
7a3408
+ cleanup:
7a3408
     VIR_FREE(dev_path);
7a3408
 
7a3408
     return key;
7a3408
 }
7a3408
 
7a3408
+
7a3408
 static int
7a3408
 qemuAddSharedHostdev(virQEMUDriverPtr driver,
7a3408
                      virDomainHostdevDefPtr hostdev,
7a3408
-- 
7a3408
2.5.1
7a3408