[virt-tools-list] [PATCH] VMM - Show host device information bits
Cole Robinson
crobinso at redhat.com
Thu Sep 24 17:44:39 UTC 2009
On 08/05/2009 10:11 AM, Michal Novotny wrote:
> Hi,
> I've been digging addhardware code in virt-manager to find out how it's working in order to create a patch to show USB/PCI host devices information bits. It's been tested and it's working fine for USB devices but I was unable to add PCI device to any VM under KVM (maybe I don't know how to do this but it should be working for both USB and PCI devices according to the source code). I've tested this patch in VMM with USB devices and new information about vendor, product and full device name has been added...
>
> If somebody could test it with PCI devices as well, it would be great.
>
You can work around this issue using libvirt's test driver. Libvirt's
test driver allows you to use a custom XML document defining your VMs,
storage, networks, host details, etc. Currently it lacks host device
support though.
But, in this case, you can fake having PCI devices attached to a VM.
Grab http://fedorapeople.org/~crobinso/virt-manager/testdriver.xml ,
then launch virt-manager like
virt-manager --connect test:///some/path/to/testdriver.xml
There will be a VM called test-many-devices with PCI devs attached.
Comments inline:
> # HG changeset patch
> # User Michal Novotny <minovotn at redhat.com>
> # Date 1249481161 -7200
> # Node ID 3e7fd1794965cc00bff5203c39281a7a9c02ee00
> # Parent 44c1515273ac5d3cb2cf91e5500f9593547bda5b
> Show USB/PCI devices information bits in Details tab
>
> This is the patch to add support of showing USB devices. It should be working on both
> USB and PCI devices but unfortunately I was unable to test it for PCI devices because
> I even was unable to add a PCI device to any VM running under KVM (development is done
> under Fedora 10 x86_64) but it's been tested on USB devices and it's working fine with
> them.
>
> diff -r 44c1515273ac -r 3e7fd1794965 src/virtManager/details.py
> --- a/src/virtManager/details.py Wed Aug 05 16:00:32 2009 +0200
> +++ b/src/virtManager/details.py Wed Aug 05 16:06:01 2009 +0200
> @@ -1177,12 +1177,31 @@
> if not hostdevinfo:
> return
>
> + vendor_id = hostdevinfo[1]['vendor']['id']
> + product_id = hostdevinfo[1]['product']['id']
Not all USB devices will have vendor or product info. USB devices can be
specifed as:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<address bus='6' device='2'/>
</source>
</hostdev>
You'll see this with the test driver I posted.
That said, we don't want to expose just the hex product/vendor/name info
to the user, we want to show them the string representation that they
see from 'lsusb' or 'lspci'. We need to get this information from the
libvirt nodedev APIs. See 'virsh nodedev-list' and 'virsh nodedev-dumpxml'.
Thanks,
Cole
> + typ = hostdevinfo[1]['type']
> + if typ == 'usb':
> + typ = 'usb_device'
> +
> + dev_pretty_name = None
> + dev_vendor_name = None
> + dev_product_name = None
> + devs = self.vm.get_connection().get_devices( typ, None )
> + for dev in devs:
> + if dev.product_id == product_id and dev.vendor_id == vendor_id:
> + dev_pretty_name = dev.pretty_name()
> + dev_vendor_name = dev.vendor_name
> + dev_product_name = dev.product_name
> +
> devlabel = "<b>Physical %s Device</b>" % hostdevinfo[4].upper()
>
> self.window.get_widget("hostdev-title").set_markup(devlabel)
> self.window.get_widget("hostdev-type").set_text(hostdevinfo[4])
> self.window.get_widget("hostdev-mode").set_text(hostdevinfo[3])
> self.window.get_widget("hostdev-source").set_text(hostdevinfo[5])
> + self.window.get_widget("hostdev-name").set_text(dev_pretty_name or "-")
> + self.window.get_widget("hostdev-vendor").set_text(dev_vendor_name or "-")
> + self.window.get_widget("hostdev-product").set_text(dev_product_name or "-")
>
> def refresh_video_page(self):
> vidinfo = self.get_hw_selection(HW_LIST_COL_DEVICE)
More information about the virt-tools-list
mailing list