Skip to content

Commit

Permalink
USB: fix Invalid value for attribute 'bus' in element 'address'
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xiaodwan committed Apr 1, 2024
1 parent 5e51331 commit 43fb8bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 43fb8bc

Please sign in to comment.