During my work on removing addresses caching, usb addresses were added :).
It should be applied on top of:
https://www.redhat.com/archives/libvir-list/2016-August/msg00945.html
or some small conflicts appear.
I took an approach where exactly the same function is used to both
calculate and recalculate the address set. It forces us to keep all
the usb address handling in such state that reusing that function
doesn't perform any changes that aren't needed.
It might even be possible to unify the handling of usb devices into
one function, "qemuDomainAssignUSBAddresses", and remove some code.
For example, virDomainUSBAddressEnsure looks almost exactly like
qemuDomainAssignUSBPorts plus virDomainUSBAddressReserve. The end goal
would be simply calling qemuDomainAssignUSBAddresses() as many times
as we want, for example when creating a new domain or after a hotplug.
To see what I mean, please take a look at qemuDomainAttachUSBMassStorageDevice.
If I remove the call to virDomainUSBAddressEnsure and move creating the
USB address set somewhere down (after virDomainDiskInsertPreAlloced),
it works - the address is assigned flawlessly.
Does it make any sense?
Is there any reason why we don't add new usb hubs when hotplugging
devices?
By the way please excuse me for resending an old patch series a few
minutes ago, it was an accident.
Tomasz Flendrich (5):
Add qemuDomainUSBAddrSetCreateFromDomain
qemu_hotplug: use a recalculated usb address set
remove qemuDomainReleaseDeviceAddress and its uses
remove unused virDomainUSBAddressRelease
Add a USB hotplug testcase for reattachment
src/conf/domain_addr.c | 30 -------------
src/conf/domain_addr.h | 5 ---
src/libvirt_private.syms | 1 -
src/qemu/qemu_domain.c | 3 +-
src/qemu/qemu_domain.h | 2 -
src/qemu/qemu_domain_address.c | 62 ++++++++++++---------------
src/qemu/qemu_domain_address.h | 8 ++--
src/qemu/qemu_hotplug.c | 95 +++++++++++-------------------------------
src/qemu/qemu_process.c | 6 +--
tests/qemuhotplugtest.c | 7 +++-
10 files changed, 62 insertions(+), 157 deletions(-)
--
1.9.1