From 43fb8bc7788e07dcec56e2c067fc5d6a4cd685f8 Mon Sep 17 00:00:00 2001 From: Xiaodai Wang Date: Wed, 27 Mar 2024 18:42:54 +0800 Subject: [PATCH] USB: fix Invalid value for attribute 'bus' in element 'address' From libvirt document, The values of these attributes can be given in decimal, hexadecimal (starting with 0x) or octal (starting with 0) form. In our script, the analyze of 'lsusb' output pass bus and address literally. If the bus num is greater or equal than 8, for instance 008', libvirt will report the error. In the lsusb output, the bus value should be decimal, so just remove the leading zeros from the string to fix it. Signed-off-by: Xiaodai Wang --- virttest/utils_test/libvirt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virttest/utils_test/libvirt.py b/virttest/utils_test/libvirt.py index ec3f41abc3..8b11d3cffa 100644 --- a/virttest/utils_test/libvirt.py +++ b/virttest/utils_test/libvirt.py @@ -1541,8 +1541,8 @@ def create_hostdev_xml( } hostdev_xml.source = hostdev_xml.new_source(**attrs) if dev_type == "usb": - addr_bus = pci_id.split(":")[2] - addr_device = pci_id.split(":")[3] + addr_bus = pci_id.split(":")[2].lstrip("0") + addr_device = pci_id.split(":")[3].lstrip("0") hostdev_xml.source = hostdev_xml.new_source( **( dict(