details: the bus, device values of USB device is decimal rather than hex

Although the code in lookup_nodedev() is general to deal with
hostdev, it has to seperate USB device from PCI device there.
For PCI device, the domain/bus/slot/function is hex.
For USB device, the bus/device is decimal.

This fix makes the label use hostdev pretty_name:

 +------------------------------------------------------+
 | Physical USB Device                                  |
 |   Device: 006:032 RSA RSA SecureID (R) Authenticator |

(crobinso: fix some pylint)
This commit is contained in:
Guannan Ren 2013-04-23 21:30:34 +08:00 committed by Cole Robinson
parent 54c6bb6bd1
commit 5a316b9a51

View File

@ -270,19 +270,25 @@ def lookup_nodedev(vmmconn, hostdev):
return None
return getattr(node, attr)
devtype = hostdev.type
vendor_id = hostdev.vendor or -1
product_id = hostdev.product or -1
device = intify(hostdev.device, True)
bus = intify(hostdev.bus, True)
domain = intify(hostdev.domain, True)
func = intify(hostdev.function, True)
slot = intify(hostdev.slot, True)
devtype = hostdev.type
found_dev = None
vendor_id = product_id = bus = device = \
domain = slot = func = None
# For USB we want a device, not a bus
if devtype == 'usb':
devtype = 'usb_device'
devtype = 'usb_device'
vendor_id = hostdev.vendor or -1
product_id = hostdev.product or -1
bus = intify(hostdev.bus)
device = intify(hostdev.device)
elif devtype == 'pci':
domain = intify(hostdev.domain, True)
bus = intify(hostdev.bus, True)
slot = intify(hostdev.slot, True)
func = intify(hostdev.function, True)
devs = vmmconn.get_nodedevs(devtype, None)
for dev in devs: