Introduce a convenience function to handle formulating the hostdev path Signed-off-by: John Ferlan <jfer...@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 48fb74a..f82244f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1213,15 +1213,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, @@ -1230,14 +1228,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list