mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-03 13:47:18 +03:00
virtinst: throw error when --host-device can't specify unique device
When there are mutiple USB devices with identical vendorId and productId, with --host-device <vendorId:productId>, virt-install fails to specify one. Currently the virt-install add the first node device with these vendorId and productId. This fix will throw out an error when argument to --host-device can't specify unique node device. For example: virt-install ${other args} \ --host-device <vendorId:productId> ERROR 15e1:2007 corresponds to multiple node devices
This commit is contained in:
parent
b15e51e73b
commit
0802cb1add
@ -640,7 +640,8 @@ vinst.add_invalid("redirdev", "--redirdev usb,type=tcp,server=:399") # Missing
|
||||
|
||||
vinst.add_category("hostdev", "--noautoconsole --nographics --nodisks --pxe")
|
||||
vinst.add_valid("hostdev", "--host-device usb_device_781_5151_2004453082054CA1BEEE") # Host dev by libvirt name
|
||||
vinst.add_valid("hostdev", "--host-device 001.003 --host-device 15:0.1 --host-device 2:15:0.2 --host-device 0:15:0.3 --host-device 0x0781:0x5151 --host-device 1d6b:2") # Many hostdev parsing types
|
||||
vinst.add_valid("hostdev", "--host-device 001.003 --host-device 15:0.1 --host-device 2:15:0.2 --host-device 0:15:0.3 --host-device 0x0781:0x5151") # Many hostdev parsing types
|
||||
vinst.add_invalid("hostdev", "--host-device 1d6b:2") # multiple USB devices with identical vendorId and productId
|
||||
vinst.add_invalid("hostdev", "--host-device pci_8086_2850_scsi_host_scsi_host") # Unsupported hostdev type
|
||||
vinst.add_invalid("hostdev", "--host-device foobarhostdev") # Unknown hostdev
|
||||
vinst.add_invalid("hostdev", "--host-device 300:400") # Parseable hostdev, but unknown digits
|
||||
|
@ -527,14 +527,24 @@ def devAddressToNodedev(conn, addrstr):
|
||||
cmp_func, devtype = ret
|
||||
|
||||
# Iterate over node devices and compare
|
||||
count = 0
|
||||
nodedev = None
|
||||
|
||||
nodenames = conn.listDevices(devtype, 0)
|
||||
for name in nodenames:
|
||||
nodedev = _lookupNodeName(conn, name)
|
||||
if cmp_func(nodedev):
|
||||
return nodedev
|
||||
tmpnode = _lookupNodeName(conn, name)
|
||||
if cmp_func(tmpnode):
|
||||
nodedev = tmpnode
|
||||
count += 1
|
||||
|
||||
raise ValueError(_("Did not find a matching node device for '%s'") %
|
||||
addrstr)
|
||||
if count == 1:
|
||||
return nodedev
|
||||
elif count > 1:
|
||||
raise ValueError(_("%s corresponds to multiple node devices") %
|
||||
addrstr)
|
||||
elif count < 1:
|
||||
raise ValueError(_("Did not find a matching node device for '%s'") %
|
||||
addrstr)
|
||||
|
||||
|
||||
def parse(xml):
|
||||
|
Loading…
x
Reference in New Issue
Block a user