render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From 8cd3af12f97b099168cd76e57648924e91c02dc7 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <8cd3af12f97b099168cd76e57648924e91c02dc7@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Thu, 9 Jul 2015 08:28:54 -0400
7a3408
Subject: [PATCH] qemu: Inline qemuGetHostdevPath
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1072736
7a3408
7a3408
Since a future patch will need the device path generated when adding a
7a3408
shared host device, remove the qemuAddSharedHostdev and inline the two
7a3408
calls into qemuAddSharedHostdev and qemuRemoveSharedHostdev
7a3408
7a3408
Signed-off-by: John Ferlan <jferlan@redhat.com>
7a3408
(cherry picked from commit 3830795318d972dcce615748ef8558011c8b11bf)
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_conf.c | 39 ++++++++++++++++-----------------------
7a3408
 1 file changed, 16 insertions(+), 23 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
7a3408
index bf2ec1e..cc40dcb 100644
7a3408
--- a/src/qemu/qemu_conf.c
7a3408
+++ b/src/qemu/qemu_conf.c
7a3408
@@ -1267,43 +1267,30 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
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
                      const char *name)
7a3408
 {
7a3408
+    char *dev_path = NULL;
7a3408
     char *key = NULL;
7a3408
     int ret = -1;
7a3408
 
7a3408
     if (!qemuIsSharedHostdev(hostdev))
7a3408
         return 0;
7a3408
 
7a3408
-    if (!(key = qemuGetSharedHostdevKey(hostdev)))
7a3408
-        return -1;
7a3408
+    if (!(dev_path = qemuGetHostdevPath(hostdev)))
7a3408
+        goto cleanup;
7a3408
+
7a3408
+    if (!(key = qemuGetSharedDeviceKey(dev_path)))
7a3408
+        goto cleanup;
7a3408
 
7a3408
     qemuDriverLock(driver);
7a3408
     ret = qemuSharedDeviceEntryInsert(driver, key, name);
7a3408
     qemuDriverUnlock(driver);
7a3408
 
7a3408
+ cleanup:
7a3408
+    VIR_FREE(dev_path);
7a3408
     VIR_FREE(key);
7a3408
     return ret;
7a3408
 }
7a3408
@@ -1392,19 +1379,25 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver,
7a3408
                         virDomainHostdevDefPtr hostdev,
7a3408
                         const char *name)
7a3408
 {
7a3408
+    char *dev_path = NULL;
7a3408
     char *key = NULL;
7a3408
     int ret;
7a3408
 
7a3408
     if (!qemuIsSharedHostdev(hostdev))
7a3408
         return 0;
7a3408
 
7a3408
-    if (!(key = qemuGetSharedHostdevKey(hostdev)))
7a3408
-        return -1;
7a3408
+    if (!(dev_path = qemuGetHostdevPath(hostdev)))
7a3408
+        goto cleanup;
7a3408
+
7a3408
+    if (!(key = qemuGetSharedDeviceKey(dev_path)))
7a3408
+        goto cleanup;
7a3408
 
7a3408
     qemuDriverLock(driver);
7a3408
     ret = qemuSharedDeviceEntryRemove(driver, key, name);
7a3408
     qemuDriverUnlock(driver);
7a3408
 
7a3408
+ cleanup:
7a3408
+    VIR_FREE(dev_path);
7a3408
     VIR_FREE(key);
7a3408
     return ret;
7a3408
 }
7a3408
-- 
7a3408
2.5.1
7a3408