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 <jferlan@xxxxxxxxxx> --- 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 7506895..3fa00f0 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.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list