Introduce a convenience function to handle formulating the hostdev path
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
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 8e9da0d..fd0ad3f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1208,15 +1208,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,
@@ -1225,14 +1223,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