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