Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/qemu/qemu_hostdev.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 5771f41..e39bc47 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -402,9 +402,14 @@ qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virUSBDevicePtr tmp;
virDomainHostdevDefPtr *hostdevs = def->hostdevs;
int nhostdevs = def->nhostdevs;
+ const char *dom_name = def->name;
virHostdevManagerPtr hostdev_mgr;
bool coldBoot = !!(flags & VIR_COLD_BOOT);
+ hostdev_mgr = virHostdevManagerGetDefault();
+ if (hostdev_mgr == NULL)
+ return -1;
+
/* To prevent situation where USB device is assigned to two domains
* we need to keep a list of currently assigned USB devices.
* This is done in several loops which cannot be joined into one big
@@ -443,10 +448,7 @@ qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
* and add them do driver list. However, if something goes
* wrong, perform rollback.
*/
- hostdev_mgr = virHostdevManagerGetDefault();
- if (hostdev_mgr == NULL)
- goto cleanup;
- if (qemuPrepareHostdevUSBDevices(hostdev_mgr, def->name, list) < 0)
+ if (qemuPrepareHostdevUSBDevices(hostdev_mgr, dom_name, list) < 0)
goto cleanup;
/* Loop 2: Temporary list was successfully merged with
--
1.6.0.2