[PATCH] qemu: assign USB port on a selected hub for all devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Due to a logic error, the autofilling of USB port when a bus is
specified:
    <address type='usb' bus='0'/>
does not work for non-hub devices on domain startup.

Fix the logic in qemuDomainAssignUSBPortsIterator to also
assign ports for USB addresses that do not yet have one.

https://bugzilla.redhat.com/show_bug.cgi?id=1374128
---
 src/qemu/qemu_domain_address.c                            | 7 ++++++-
 tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 9cd1e9e..5c09620 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -2238,7 +2238,12 @@ qemuDomainAssignUSBPortsIterator(virDomainDeviceInfoPtr info,
 {
     struct qemuAssignUSBIteratorInfo *data = opaque;
 
-    if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+    if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+        info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB)
+        return 0;
+
+    if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB &&
+        virDomainUSBAddressPortIsValid(info->addr.usb.port))
         return 0;
 
     return virDomainUSBAddressAssign(data->addrs, info);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
index ff743c8..fbb328e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
@@ -22,5 +22,5 @@ server,nowait \
 -usb \
 -device usb-hub,id=hub0,bus=usb.0,port=1 \
 -device usb-hub,id=hub1,bus=usb.0,port=2 \
--device usb-mouse,id=input0,bus=usb.0 \
+-device usb-mouse,id=input0,bus=usb.0,port=1.1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-- 
2.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux