6ae9ed
From 2e6ca604192638d5182bb109fc83590c6d1028ae Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <2e6ca604192638d5182bb109fc83590c6d1028ae@dist-git>
6ae9ed
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
6ae9ed
Date: Thu, 21 Jul 2016 15:57:55 +0200
6ae9ed
Subject: [PATCH] Assign addresses to USB devices
6ae9ed
MIME-Version: 1.0
6ae9ed
Content-Type: text/plain; charset=UTF-8
6ae9ed
Content-Transfer-Encoding: 8bit
6ae9ed
6ae9ed
Automatically assign addresses to USB devices.
6ae9ed
6ae9ed
Just like reserving, this is only done for newly defined domains.
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1215968
6ae9ed
(cherry picked from commit bf182078d96476c8d5557737c1107241f280a947)
6ae9ed
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6ae9ed
---
6ae9ed
 src/conf/domain_addr.c                             | 133 ++++++++++++++++++++-
6ae9ed
 src/conf/domain_addr.h                             |  14 +++
6ae9ed
 src/libvirt_private.syms                           |   3 +
6ae9ed
 src/qemu/qemu_domain_address.c                     |  65 ++++++++++
6ae9ed
 .../qemuxml2argvdata/qemuxml2argv-bios-nvram.args  |   2 +-
6ae9ed
 tests/qemuxml2argvdata/qemuxml2argv-bios.args      |   2 +-
6ae9ed
 .../qemuxml2argv-controller-order.args             |   8 +-
6ae9ed
 .../qemuxml2argv-disk-usb-device-removable.args    |   3 +-
6ae9ed
 .../qemuxml2argv-disk-usb-device.args              |   2 +-
6ae9ed
 .../qemuxml2argv-graphics-spice-timeout.args       |   2 +-
6ae9ed
 .../qemuxml2argv-graphics-spice-usb-redir.args     |   2 +-
6ae9ed
 ...muxml2argv-hostdev-usb-address-device-boot.args |   3 +-
6ae9ed
 .../qemuxml2argv-hostdev-usb-address-device.args   |   2 +-
6ae9ed
 .../qemuxml2argv-hostdev-usb-address.args          |   2 +-
6ae9ed
 .../qemuxml2argv-hugepages-numa.args               |   6 +-
6ae9ed
 .../qemuxml2argv-input-usbmouse.args               |   2 +-
6ae9ed
 .../qemuxml2argv-input-usbtablet.args              |   2 +-
6ae9ed
 .../qemuxml2argv-pseries-usb-kbd.args              |   2 +-
6ae9ed
 .../qemuxml2argv-serial-spiceport.args             |   2 +-
6ae9ed
 .../qemuxml2argv-smartcard-controller.args         |   2 +-
6ae9ed
 .../qemuxml2argv-smartcard-host-certificates.args  |   2 +-
6ae9ed
 .../qemuxml2argv-smartcard-host.args               |   2 +-
6ae9ed
 ...emuxml2argv-smartcard-passthrough-spicevmc.args |   2 +-
6ae9ed
 .../qemuxml2argv-smartcard-passthrough-tcp.args    |   2 +-
6ae9ed
 .../qemuxml2argv-sound-device.args                 |   2 +-
6ae9ed
 .../qemuxml2argv-usb-ich9-autoassign.args          |  10 +-
6ae9ed
 .../qemuxml2argv-usb-port-autoassign.args          |   8 +-
6ae9ed
 .../qemuxml2argv-usb-port-missing.args             |   4 +-
6ae9ed
 .../qemuxml2argv-usb-redir-boot.args               |   2 +-
6ae9ed
 tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args |   2 +-
6ae9ed
 .../qemuxml2argv-usb-xhci-autoassign.args          |  10 +-
6ae9ed
 31 files changed, 260 insertions(+), 45 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
6ae9ed
index bbac399..3b0c205 100644
6ae9ed
--- a/src/conf/domain_addr.c
6ae9ed
+++ b/src/conf/domain_addr.c
6ae9ed
@@ -1489,7 +1489,7 @@ virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs,
6ae9ed
 
6ae9ed
 #define VIR_DOMAIN_USB_HUB_PORTS 8
6ae9ed
 
6ae9ed
-static int
6ae9ed
+int
6ae9ed
 virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs,
6ae9ed
                              virDomainHubDefPtr hub)
6ae9ed
 {
6ae9ed
@@ -1564,6 +1564,119 @@ virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs,
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+static int
6ae9ed
+virDomainUSBAddressFindFreePort(virDomainUSBAddressHubPtr hub,
6ae9ed
+                                unsigned int *portpath,
6ae9ed
+                                unsigned int level)
6ae9ed
+{
6ae9ed
+    unsigned int port;
6ae9ed
+    ssize_t portIdx;
6ae9ed
+    size_t i;
6ae9ed
+
6ae9ed
+    /* Look for free ports on the current hub */
6ae9ed
+    if ((portIdx = virBitmapNextClearBit(hub->portmap, -1)) >= 0) {
6ae9ed
+        port = portIdx + 1;
6ae9ed
+        VIR_DEBUG("Found a free port %u at level %u", port, level);
6ae9ed
+        portpath[level] = port;
6ae9ed
+        return 0;
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    VIR_DEBUG("No ports found on hub %p, trying the hubs on it", hub);
6ae9ed
+
6ae9ed
+    if (level >= VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH - 1)
6ae9ed
+        return -1;
6ae9ed
+
6ae9ed
+    /* Recursively search through the ports that contain another hub */
6ae9ed
+    for (i = 0; i < hub->nports; i++) {
6ae9ed
+        if (!hub->ports[i])
6ae9ed
+            continue;
6ae9ed
+
6ae9ed
+        port = i + 1;
6ae9ed
+        VIR_DEBUG("Looking at USB hub at level: %u port: %u", level, port);
6ae9ed
+        if (virDomainUSBAddressFindFreePort(hub->ports[i], portpath,
6ae9ed
+                                            level + 1) < 0)
6ae9ed
+            continue;
6ae9ed
+
6ae9ed
+        portpath[level] = port;
6ae9ed
+        return 0;
6ae9ed
+    }
6ae9ed
+    return -1;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
+/* Try to find a free port on bus @bus.
6ae9ed
+ *
6ae9ed
+ * Returns  0 on success
6ae9ed
+ *         -1 on fatal error (OOM)
6ae9ed
+ *         -2 if there is no bus at @bus or no free port on this bus
6ae9ed
+ */
6ae9ed
+static int
6ae9ed
+virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                                 virDomainDeviceInfoPtr info,
6ae9ed
+                                 size_t bus)
6ae9ed
+{
6ae9ed
+    unsigned int portpath[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH] = { 0 };
6ae9ed
+    virDomainUSBAddressHubPtr hub = addrs->buses[bus];
6ae9ed
+    char *portStr = NULL;
6ae9ed
+    int ret = -1;
6ae9ed
+
6ae9ed
+    if (!hub)
6ae9ed
+        return -2;
6ae9ed
+
6ae9ed
+    if (virDomainUSBAddressFindFreePort(hub, portpath, 0) < 0)
6ae9ed
+        return -2;
6ae9ed
+
6ae9ed
+    /* we found a free port */
6ae9ed
+    if (!(portStr = virDomainUSBAddressPortFormat(portpath)))
6ae9ed
+        goto cleanup;
6ae9ed
+
6ae9ed
+    info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
6ae9ed
+    info->addr.usb.bus = bus;
6ae9ed
+    memcpy(info->addr.usb.port, portpath, sizeof(portpath));
6ae9ed
+    VIR_DEBUG("Assigning USB addr bus=%u port=%s",
6ae9ed
+              info->addr.usb.bus, portStr);
6ae9ed
+    if (virDomainUSBAddressReserve(info, addrs) < 0)
6ae9ed
+        goto cleanup;
6ae9ed
+
6ae9ed
+    ret = 0;
6ae9ed
+ cleanup:
6ae9ed
+    VIR_FREE(portStr);
6ae9ed
+    return ret;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
+int
6ae9ed
+virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                          virDomainDeviceInfoPtr info)
6ae9ed
+{
6ae9ed
+    size_t i;
6ae9ed
+    int rc;
6ae9ed
+
6ae9ed
+    if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
6ae9ed
+        VIR_DEBUG("A USB port on bus %u was requested", info->addr.usb.bus);
6ae9ed
+        if (!addrs->buses[info->addr.usb.bus]) {
6ae9ed
+            virReportError(VIR_ERR_XML_ERROR,
6ae9ed
+                           _("USB bus %u requested but no controller "
6ae9ed
+                             "with that index is present"), info->addr.usb.bus);
6ae9ed
+            return -1;
6ae9ed
+        }
6ae9ed
+        rc = virDomainUSBAddressAssignFromBus(addrs, info, info->addr.usb.bus);
6ae9ed
+        if (rc >= -1)
6ae9ed
+            return rc;
6ae9ed
+    } else {
6ae9ed
+        VIR_DEBUG("Looking for a free USB port on all the buses");
6ae9ed
+        for (i = 0; i < addrs->nbuses; i++) {
6ae9ed
+            rc = virDomainUSBAddressAssignFromBus(addrs, info, i);
6ae9ed
+            if (rc >= -1)
6ae9ed
+                return rc;
6ae9ed
+        }
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No free USB ports"));
6ae9ed
+    return -1;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 int
6ae9ed
 virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
6ae9ed
                            void *data)
6ae9ed
@@ -1604,3 +1717,21 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
6ae9ed
     VIR_FREE(portStr);
6ae9ed
     return ret;
6ae9ed
 }
6ae9ed
+
6ae9ed
+
6ae9ed
+int
6ae9ed
+virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                          virDomainDeviceInfoPtr info)
6ae9ed
+{
6ae9ed
+    if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
6ae9ed
+        (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB &&
6ae9ed
+         !virDomainUSBAddressPortIsValid(info->addr.usb.port))) {
6ae9ed
+        if (virDomainUSBAddressAssign(addrs, info) < 0)
6ae9ed
+            return -1;
6ae9ed
+    } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
6ae9ed
+        if (virDomainUSBAddressReserve(info, addrs) < 0)
6ae9ed
+            return -1;
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    return 0;
6ae9ed
+}
6ae9ed
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
6ae9ed
index a24d216..633aa16 100644
6ae9ed
--- a/src/conf/domain_addr.h
6ae9ed
+++ b/src/conf/domain_addr.h
6ae9ed
@@ -273,10 +273,24 @@ virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void);
6ae9ed
 int virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs,
6ae9ed
                                          virDomainDefPtr def)
6ae9ed
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
6ae9ed
+int
6ae9ed
+virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                             virDomainHubDefPtr hub)
6ae9ed
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
6ae9ed
 void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs);
6ae9ed
 
6ae9ed
 int
6ae9ed
 virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
6ae9ed
                            void *data)
6ae9ed
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
6ae9ed
+
6ae9ed
+int
6ae9ed
+virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                          virDomainDeviceInfoPtr info)
6ae9ed
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
6ae9ed
+
6ae9ed
+int
6ae9ed
+virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                          virDomainDeviceInfoPtr info)
6ae9ed
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
6ae9ed
 #endif /* __DOMAIN_ADDR_H__ */
6ae9ed
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
6ae9ed
index f66ccf5..4727d39 100644
6ae9ed
--- a/src/libvirt_private.syms
6ae9ed
+++ b/src/libvirt_private.syms
6ae9ed
@@ -107,11 +107,14 @@ virDomainPCIAddressSetGrow;
6ae9ed
 virDomainPCIAddressSlotInUse;
6ae9ed
 virDomainPCIAddressValidate;
6ae9ed
 virDomainPCIControllerModelToConnectType;
6ae9ed
+virDomainUSBAddressAssign;
6ae9ed
+virDomainUSBAddressEnsure;
6ae9ed
 virDomainUSBAddressPortFormat;
6ae9ed
 virDomainUSBAddressPortFormatBuf;
6ae9ed
 virDomainUSBAddressPortIsValid;
6ae9ed
 virDomainUSBAddressReserve;
6ae9ed
 virDomainUSBAddressSetAddControllers;
6ae9ed
+virDomainUSBAddressSetAddHub;
6ae9ed
 virDomainUSBAddressSetCreate;
6ae9ed
 virDomainUSBAddressSetFree;
6ae9ed
 virDomainVirtioSerialAddrAssign;
6ae9ed
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
6ae9ed
index f66b2f0..21c2ecf 100644
6ae9ed
--- a/src/qemu/qemu_domain_address.c
6ae9ed
+++ b/src/qemu/qemu_domain_address.c
6ae9ed
@@ -1622,6 +1622,63 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+struct qemuAssignUSBIteratorInfo {
6ae9ed
+    virDomainUSBAddressSetPtr addrs;
6ae9ed
+    size_t count;
6ae9ed
+};
6ae9ed
+
6ae9ed
+
6ae9ed
+static int
6ae9ed
+qemuDomainAssignUSBPortsIterator(virDomainDeviceInfoPtr info,
6ae9ed
+                                 void *opaque)
6ae9ed
+{
6ae9ed
+    struct qemuAssignUSBIteratorInfo *data = opaque;
6ae9ed
+
6ae9ed
+    if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
6ae9ed
+        return 0;
6ae9ed
+
6ae9ed
+    return virDomainUSBAddressAssign(data->addrs, info);
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
+static int
6ae9ed
+qemuDomainAssignUSBHubs(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                        virDomainDefPtr def)
6ae9ed
+{
6ae9ed
+    size_t i;
6ae9ed
+
6ae9ed
+    for (i = 0; i < def->nhubs; i++) {
6ae9ed
+        virDomainHubDefPtr hub = def->hubs[i];
6ae9ed
+        if (hub->type != VIR_DOMAIN_HUB_TYPE_USB)
6ae9ed
+            continue;
6ae9ed
+
6ae9ed
+        if (hub->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB &&
6ae9ed
+            virDomainUSBAddressPortIsValid(hub->info.addr.usb.port))
6ae9ed
+            continue;
6ae9ed
+        if (virDomainUSBAddressAssign(addrs, &hub->info) < 0)
6ae9ed
+            return -1;
6ae9ed
+
6ae9ed
+        if (virDomainUSBAddressSetAddHub(addrs, hub) < 0)
6ae9ed
+            return -1;
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    return 0;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
+static int
6ae9ed
+qemuDomainAssignUSBPorts(virDomainUSBAddressSetPtr addrs,
6ae9ed
+                         virDomainDefPtr def)
6ae9ed
+{
6ae9ed
+    struct qemuAssignUSBIteratorInfo data = { .addrs = addrs };
6ae9ed
+
6ae9ed
+    return virDomainUSBDeviceDefForeach(def,
6ae9ed
+                                        qemuDomainAssignUSBPortsIterator,
6ae9ed
+                                        &data,
6ae9ed
+                                        true);
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 static int
6ae9ed
 qemuDomainAssignUSBAddresses(virDomainDefPtr def,
6ae9ed
                              virDomainObjPtr obj)
6ae9ed
@@ -1642,6 +1699,14 @@ qemuDomainAssignUSBAddresses(virDomainDefPtr def,
6ae9ed
 
6ae9ed
     VIR_DEBUG("Existing USB addresses have been reserved");
6ae9ed
 
6ae9ed
+    if (qemuDomainAssignUSBHubs(addrs, def) < 0)
6ae9ed
+        goto cleanup;
6ae9ed
+
6ae9ed
+    if (qemuDomainAssignUSBPorts(addrs, def) < 0)
6ae9ed
+        goto cleanup;
6ae9ed
+
6ae9ed
+    VIR_DEBUG("Finished assigning USB ports");
6ae9ed
+
6ae9ed
     if (obj && obj->privateData) {
6ae9ed
         priv = obj->privateData;
6ae9ed
         priv->usbaddrs = addrs;
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args
6ae9ed
index fe4e419..848a029 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args
6ae9ed
@@ -21,5 +21,5 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
 -serial pty \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios.args b/tests/qemuxml2argvdata/qemuxml2argv-bios.args
6ae9ed
index 012af85..604b871 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-bios.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios.args
6ae9ed
@@ -22,5 +22,5 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
 -serial pty \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
6ae9ed
index 70f3fdb..7b98beb 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
6ae9ed
@@ -19,8 +19,8 @@ nowait \
6ae9ed
 -boot order=cna,menu=off \
6ae9ed
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
6ae9ed
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
--device usb-hub,id=hub0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1.1 \
6ae9ed
+-device usb-hub,id=hub0,bus=usb.0,port=1 \
6ae9ed
 -drive file=/tmp/fdr.img,format=raw,if=none,id=drive-virtio-disk0,cache=none,\
6ae9ed
 aio=native \
6ae9ed
 -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\
6ae9ed
@@ -37,10 +37,10 @@ media=cdrom,id=drive-ide0-1-0,readonly=on \
6ae9ed
 -chardev spicevmc,id=charchannel0,name=vdagent \
6ae9ed
 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
6ae9ed
 id=channel0,name=com.redhat.spice.0 \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1.2 \
6ae9ed
 -spice port=5901,tls-port=5902,addr=0.0.0.0,x509-dir=/etc/pki/libvirt-spice \
6ae9ed
 -vga cirrus \
6ae9ed
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
6ae9ed
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
6ae9ed
--device usb-host,hostbus=14,hostaddr=6,id=hostdev0 \
6ae9ed
+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=2 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args
6ae9ed
index 63e2bb2..7cda592 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args
6ae9ed
@@ -21,5 +21,6 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
 -drive file=/tmp/usbdisk.img,format=raw,if=none,id=drive-usb-disk0 \
6ae9ed
--device usb-storage,drive=drive-usb-disk0,id=usb-disk0,removable=on \
6ae9ed
+-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk0,id=usb-disk0,\
6ae9ed
+removable=on \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args
6ae9ed
index 5d1ea98..03ef44f 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args
6ae9ed
@@ -21,5 +21,5 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
 -drive file=/tmp/usbdisk.img,format=raw,if=none,id=drive-usb-disk0 \
6ae9ed
--device usb-storage,drive=drive-usb-disk0,id=usb-disk0 \
6ae9ed
+-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk0,id=usb-disk0 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
6ae9ed
index c0be4ee..cead7d6 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
6ae9ed
@@ -28,7 +28,7 @@ media=cdrom,id=drive-ide0-1-0,readonly=on \
6ae9ed
 -device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \
6ae9ed
 -net tap,fd=3,vlan=0,name=hostnet0 \
6ae9ed
 -serial pty \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1 \
6ae9ed
 -spice port=5900,addr=127.0.0.1 \
6ae9ed
 -vga std \
6ae9ed
 -device AC97,id=sound0,bus=pci.0,addr=0x3 \
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args
6ae9ed
index fa248b3..3f00da4 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args
6ae9ed
@@ -30,7 +30,7 @@ zlib-glz-wan-compression=auto,playback-compression=on,streaming-video=filter,\
6ae9ed
 disable-copy-paste \
6ae9ed
 -vga cirrus \
6ae9ed
 -chardev socket,id=charredir0,host=localhost,port=4000 \
6ae9ed
--device usb-redir,chardev=charredir0,id=redir0 \
6ae9ed
+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \
6ae9ed
 -chardev spicevmc,id=charredir1,name=usbredir \
6ae9ed
 -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args
6ae9ed
index 8c00055..ddf90c0 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args
6ae9ed
@@ -19,5 +19,6 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -usb \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
--device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bootindex=1 \
6ae9ed
+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bootindex=1,bus=usb.0,\
6ae9ed
+port=1 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args
6ae9ed
index b5e6834..7883c61 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args
6ae9ed
@@ -20,5 +20,5 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -usb \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
--device usb-host,hostbus=14,hostaddr=6,id=hostdev0 \
6ae9ed
+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
6ae9ed
index bb5d55a..d1c3e8f 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
6ae9ed
@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -usb \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
--device usb-host,hostbus=14,hostaddr=6,id=hostdev0
6ae9ed
+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
6ae9ed
index c5a9e53..5c356ef 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
6ae9ed
@@ -46,7 +46,7 @@ id=channel0,name=org.qemu.guest_agent.0 \
6ae9ed
 -chardev spicevmc,id=charchannel1,name=vdagent \
6ae9ed
 -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
6ae9ed
 id=channel1,name=com.redhat.spice.0 \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1 \
6ae9ed
 -spice port=5901,tls-port=5902,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
6ae9ed
 -vga qxl \
6ae9ed
 -global qxl-vga.ram_size=67108864 \
6ae9ed
@@ -54,7 +54,7 @@ id=channel1,name=com.redhat.spice.0 \
6ae9ed
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
6ae9ed
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
6ae9ed
 -chardev spicevmc,id=charredir0,name=usbredir \
6ae9ed
--device usb-redir,chardev=charredir0,id=redir0 \
6ae9ed
+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 \
6ae9ed
 -chardev spicevmc,id=charredir1,name=usbredir \
6ae9ed
--device usb-redir,chardev=charredir1,id=redir1 \
6ae9ed
+-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
6ae9ed
index bd0e5c6..df96e6a 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
6ae9ed
@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -usb \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
--device usb-mouse,id=input0
6ae9ed
+-device usb-mouse,id=input0,bus=usb.0,port=1
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
6ae9ed
index 294515f..faf21d5 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
6ae9ed
@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -usb \
6ae9ed
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
--device usb-tablet,id=input0
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
6ae9ed
index 25c16cb..5887616 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
6ae9ed
@@ -22,4 +22,4 @@ server,nowait \
6ae9ed
 -device pci-ohci,id=usb,bus=pci,addr=0x1 \
6ae9ed
 -chardev pty,id=charserial0 \
6ae9ed
 -device spapr-vty,chardev=charserial0,reg=0x30000000 \
6ae9ed
--device usb-kbd,id=input0
6ae9ed
+-device usb-kbd,id=input0,bus=usb.0,port=1
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
6ae9ed
index 246e854..f05c3f2 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
6ae9ed
@@ -23,7 +23,7 @@ server,nowait \
6ae9ed
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
6ae9ed
 -chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \
6ae9ed
 -device isa-serial,chardev=charserial0,id=serial0 \
6ae9ed
--device usb-tablet,id=input0 \
6ae9ed
+-device usb-tablet,id=input0,bus=usb.0,port=1 \
6ae9ed
 -spice port=5903,tls-port=5904,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
6ae9ed
 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
6ae9ed
 addr=0x2 \
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args
6ae9ed
index d3135c2..beb2935 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args
6ae9ed
@@ -19,7 +19,7 @@ server,nowait \
6ae9ed
 -mon chardev=charmonitor,id=monitor,mode=readline \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
6ae9ed
 -usb \
6ae9ed
 -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args
6ae9ed
index 09ef26c..72cf24b 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args
6ae9ed
@@ -19,7 +19,7 @@ server,nowait \
6ae9ed
 -mon chardev=charmonitor,id=monitor,mode=readline \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
6ae9ed
 -usb \
6ae9ed
 -device ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,\
6ae9ed
 cert3=cert3,db=/etc/pki/nssdb,id=smartcard0,bus=ccid0.0 \
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args
6ae9ed
index d3135c2..beb2935 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args
6ae9ed
@@ -19,7 +19,7 @@ server,nowait \
6ae9ed
 -mon chardev=charmonitor,id=monitor,mode=readline \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
6ae9ed
 -usb \
6ae9ed
 -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args
6ae9ed
index b618507..cdca4c4 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args
6ae9ed
@@ -19,7 +19,7 @@ server,nowait \
6ae9ed
 -mon chardev=charmonitor,id=monitor,mode=readline \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
6ae9ed
 -usb \
6ae9ed
 -chardev spicevmc,id=charsmartcard0,name=smartcard \
6ae9ed
 -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args
6ae9ed
index e0fcb49..0c526c8 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args
6ae9ed
@@ -19,7 +19,7 @@ server,nowait \
6ae9ed
 -mon chardev=charmonitor,id=monitor,mode=readline \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
--device usb-ccid,id=ccid0 \
6ae9ed
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
6ae9ed
 -usb \
6ae9ed
 -chardev socket,id=charsmartcard0,host=127.0.0.1,port=2001,server,nowait \
6ae9ed
 -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
6ae9ed
index 8d846a0..b084f4e 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
6ae9ed
@@ -34,5 +34,5 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \
6ae9ed
 -device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \
6ae9ed
 -device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \
6ae9ed
--device usb-audio,id=sound8 \
6ae9ed
+-device usb-audio,id=sound8,bus=usb.0,port=1 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args
6ae9ed
index faaff95..db95851 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args
6ae9ed
@@ -24,9 +24,9 @@ server,nowait \
6ae9ed
 addr=0x4 \
6ae9ed
 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \
6ae9ed
 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \
6ae9ed
--device usb-hub,id=hub0 \
6ae9ed
--device usb-hub,id=hub1 \
6ae9ed
--device usb-mouse,id=input0 \
6ae9ed
--device usb-mouse,id=input1 \
6ae9ed
--device usb-mouse,id=input2 \
6ae9ed
+-device usb-hub,id=hub0,bus=usb.0,port=1 \
6ae9ed
+-device usb-hub,id=hub1,bus=usb.0,port=2 \
6ae9ed
+-device usb-mouse,id=input0,bus=usb.0,port=3 \
6ae9ed
+-device usb-mouse,id=input1,bus=usb.0,port=4 \
6ae9ed
+-device usb-mouse,id=input2,bus=usb.0,port=5 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args
6ae9ed
index aa80919..ac5cfdd 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args
6ae9ed
@@ -21,8 +21,8 @@ server,nowait \
6ae9ed
 -boot c \
6ae9ed
 -usb \
6ae9ed
 -device usb-hub,id=hub0,bus=usb.0,port=1 \
6ae9ed
--device usb-hub,id=hub1 \
6ae9ed
--device usb-mouse,id=input0 \
6ae9ed
--device usb-mouse,id=input1 \
6ae9ed
--device usb-mouse,id=input2 \
6ae9ed
+-device usb-hub,id=hub1,bus=usb.0,port=2 \
6ae9ed
+-device usb-mouse,id=input0,bus=usb.0,port=1.1 \
6ae9ed
+-device usb-mouse,id=input1,bus=usb.0,port=1.2 \
6ae9ed
+-device usb-mouse,id=input2,bus=usb.0,port=1.3 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
6ae9ed
index d43c58d..56c0750 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args
6ae9ed
@@ -20,7 +20,7 @@ server,nowait \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
 -usb \
6ae9ed
--device usb-hub,id=hub0,bus=usb.0 \
6ae9ed
--device usb-hub,id=hub1,bus=usb.0 \
6ae9ed
+-device usb-hub,id=hub0,bus=usb.0,port=1 \
6ae9ed
+-device usb-hub,id=hub1,bus=usb.0,port=2 \
6ae9ed
 -device usb-mouse,id=input0,bus=usb.0 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args
6ae9ed
index 53b9040..bc47963 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args
6ae9ed
@@ -24,7 +24,7 @@ addr=0x4 \
6ae9ed
 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \
6ae9ed
 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \
6ae9ed
 -chardev socket,id=charredir0,host=localhost,port=4000 \
6ae9ed
--device usb-redir,chardev=charredir0,id=redir0,bootindex=1 \
6ae9ed
+-device usb-redir,chardev=charredir0,id=redir0,bootindex=1,bus=usb.0,port=1 \
6ae9ed
 -chardev spicevmc,id=charredir1,name=usbredir \
6ae9ed
 -device usb-redir,chardev=charredir1,id=redir1,bootindex=2,bus=usb.0,port=4 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args
6ae9ed
index 08e8f3e..0999c97 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args
6ae9ed
@@ -25,7 +25,7 @@ addr=0x4 \
6ae9ed
 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \
6ae9ed
 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \
6ae9ed
 -chardev socket,id=charredir0,host=localhost,port=4000 \
6ae9ed
--device usb-redir,chardev=charredir0,id=redir0 \
6ae9ed
+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \
6ae9ed
 -chardev spicevmc,id=charredir1,name=usbredir \
6ae9ed
 -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 \
6ae9ed
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args
6ae9ed
index 7c5e6a5..15a9d29 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args
6ae9ed
@@ -20,8 +20,8 @@ server,nowait \
6ae9ed
 -no-acpi \
6ae9ed
 -boot c \
6ae9ed
 -device nec-usb-xhci,p2=8,p3=8,id=usb,bus=pci.0,addr=0x3 \
6ae9ed
--device usb-hub,id=hub0 \
6ae9ed
--device usb-hub,id=hub1 \
6ae9ed
--device usb-mouse,id=input0 \
6ae9ed
--device usb-mouse,id=input1 \
6ae9ed
--device usb-mouse,id=input2
6ae9ed
+-device usb-hub,id=hub0,bus=usb.0,port=1 \
6ae9ed
+-device usb-hub,id=hub1,bus=usb.0,port=2 \
6ae9ed
+-device usb-mouse,id=input0,bus=usb.0,port=3 \
6ae9ed
+-device usb-mouse,id=input1,bus=usb.0,port=4 \
6ae9ed
+-device usb-mouse,id=input2,bus=usb.0,port=5
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed