[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH] VMM - Show host device information bits



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.

Thanks,
Michal
# HG changeset patch
# User Michal Novotny <minovotn 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']
+        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)
diff -r 44c1515273ac -r 3e7fd1794965 src/vmm-details.glade
--- a/src/vmm-details.glade	Wed Aug 05 16:00:32 2009 +0200
+++ b/src/vmm-details.glade	Wed Aug 05 16:06:01 2009 +0200
@@ -3437,12 +3437,56 @@
                                           <packing>
                                             <property name="left_attach">1</property>
                                             <property name="right_attach">2</property>
+                                            <property name="top_attach">5</property>
+                                            <property name="bottom_attach">6</property>
+                                            <property name="y_options"></property>
+                                          </packing>
+                                        </child>
+
+                                        <child>
+                                          <widget class="GtkLabel" id="hostdev-name">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label">label</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
                                             <property name="top_attach">2</property>
                                             <property name="bottom_attach">3</property>
                                             <property name="y_options"></property>
                                           </packing>
                                         </child>
                                         <child>
+                                          <widget class="GtkLabel" id="hostdev-vendor">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label">label</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">3</property>
+                                            <property name="bottom_attach">4</property>
+                                            <property name="y_options"></property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkLabel" id="hostdev-product">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label">label</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">4</property>
+                                            <property name="bottom_attach">5</property>
+                                            <property name="y_options"></property>
+                                          </packing>
+                                        </child>
+
+                                        <child>
                                           <widget class="GtkLabel" id="hostdev-mode">
                                             <property name="visible">True</property>
                                             <property name="xalign">0</property>
@@ -3499,12 +3543,53 @@
                                             <property name="label" translatable="yes">Source Device:</property>
                                           </widget>
                                           <packing>
+                                            <property name="top_attach">5</property>
+                                            <property name="bottom_attach">6</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                            <property name="y_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+
+                                        <child>
+                                          <widget class="GtkLabel" id="label4">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">Device Name:</property>
+                                          </widget>
+                                          <packing>
                                             <property name="top_attach">2</property>
                                             <property name="bottom_attach">3</property>
                                             <property name="x_options">GTK_FILL</property>
                                             <property name="y_options">GTK_FILL</property>
                                           </packing>
                                         </child>
+                                        <child>
+                                          <widget class="GtkLabel" id="label5">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">Device Vendor:</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="top_attach">3</property>
+                                            <property name="bottom_attach">4</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                            <property name="y_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkLabel" id="label6">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">Product Name:</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="top_attach">4</property>
+                                            <property name="bottom_attach">5</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                            <property name="y_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+
                                       </widget>
                                     </child>
                                   </widget>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]