In order to drop caching of the usb address set, a function is added
that creates or recreates the usb address set, assigning addresses
if necessary.
---
src/qemu/qemu_domain_address.c | 39 ++++++++++++++++++++++++++++-----------
src/qemu/qemu_domain_address.h | 3 +++
2 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 0aa940b..99df92c 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1743,42 +1743,59 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
}
-static int
-qemuDomainAssignUSBAddresses(virDomainDefPtr def,
- virDomainObjPtr obj)
+virDomainUSBAddressSetPtr
+qemuDomainUSBAddrSetCreateFromDomain(virDomainDefPtr def)
{
- int ret = -1;
virDomainUSBAddressSetPtr addrs = NULL;
- qemuDomainObjPrivatePtr priv = NULL;
if (!(addrs = virDomainUSBAddressSetCreate()))
- goto cleanup;
+ goto error;
if (qemuDomainUSBAddressAddHubs(def) < 0)
- goto cleanup;
+ goto error;
if (virDomainUSBAddressSetAddControllers(addrs, def) < 0)
- goto cleanup;
+ goto error;
if (virDomainUSBDeviceDefForeach(def, virDomainUSBAddressReserve, addrs,
true) < 0)
- goto cleanup;
+ goto error;
VIR_DEBUG("Existing USB addresses have been reserved");
if (qemuDomainAssignUSBHubs(addrs, def) < 0)
- goto cleanup;
+ goto error;
if (qemuDomainAssignUSBPorts(addrs, def) < 0)
- goto cleanup;
+ goto error;
VIR_DEBUG("Finished assigning USB ports");
+ return addrs;
+
+ error:
+ virDomainUSBAddressSetFree(addrs);
+ return NULL;
+}
+
+
+static int
+qemuDomainAssignUSBAddresses(virDomainDefPtr def,
+ virDomainObjPtr obj)
+{
+ int ret = -1;
+ virDomainUSBAddressSetPtr addrs = NULL;
+ qemuDomainObjPrivatePtr priv = NULL;
+
+ if (!(addrs = qemuDomainUSBAddrSetCreateFromDomain(def)))
+ goto cleanup;
+
if (obj && obj->privateData) {
priv = obj->privateData;
priv->usbaddrs = addrs;
addrs = NULL;
}
+
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h
index dee352b..dfa76d2 100644
--- a/src/qemu/qemu_domain_address.h
+++ b/src/qemu/qemu_domain_address.h
@@ -51,6 +51,9 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
bool dryRun,
bool assign);
+virDomainUSBAddressSetPtr
+qemuDomainUSBAddrSetCreateFromDomain(virDomainDefPtr def);
+
# define __QEMU_DOMAIN_ADDRESS_H__
#endif /* __QEMU_DOMAIN_ADDRESS_H__ */
--
1.9.1