addhw: Filter root hubs out of USB device list

This commit is contained in:
Cole Robinson 2013-10-05 14:40:38 -04:00
parent c5b5df8db2
commit 89646fe841

View File

@ -662,16 +662,25 @@ class vmmConnection(vmmGObject):
def get_nodedevs(self, devtype=None, devcap=None): def get_nodedevs(self, devtype=None, devcap=None):
retdevs = [] retdevs = []
for dev in self.nodedevs.values(): for dev in self.nodedevs.values():
vdev = dev.get_xmlobj() xmlobj = dev.get_xmlobj()
if devtype and vdev.device_type != devtype: if devtype and xmlobj.device_type != devtype:
continue continue
if devcap: if devcap:
if (not hasattr(vdev, "capability_type") or if (not hasattr(xmlobj, "capability_type") or
vdev.capability_type != devcap): xmlobj.capability_type != devcap):
continue continue
retdevs.append(vdev) if (devtype == "usb_device" and
(("Linux Foundation" in str(xmlobj.vendor_name) or
("Linux" in str(xmlobj.vendor_name) and
xmlobj.vendor_id == "0x1d6b")) and
("root hub" in str(xmlobj.product_name) or
("host controller" in str(xmlobj.product_name).lower() and
str(xmlobj.product_id).startswith("0x000"))))):
continue
retdevs.append(xmlobj)
return retdevs return retdevs
@ -680,8 +689,8 @@ class vmmConnection(vmmGObject):
devs = self.get_nodedevs(devtype) devs = self.get_nodedevs(devtype)
for dev in devs: for dev in devs:
if vendor == dev.vendor_id and \ if (vendor == dev.vendor_id and
product == dev.product_id: product == dev.product_id):
count += 1 count += 1
logging.debug("There are %d node devices with " logging.debug("There are %d node devices with "