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

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



Hi,
this is new version of host device information bits, tested with PCI devices as well.

Thanks,
Michal

On 08/05/2009 04:11 PM, 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.

Thanks,
Michal


_______________________________________________
virt-tools-list mailing list
virt-tools-list redhat com
https://www.redhat.com/mailman/listinfo/virt-tools-list

diff -r e363de9ac549 src/virtManager/details.py
--- a/src/virtManager/details.py	Wed Oct 21 12:01:53 2009 -0400
+++ b/src/virtManager/details.py	Mon Oct 26 15:58:02 2009 +0100
@@ -1173,12 +1173,35 @@
         if not hostdevinfo:
             return
 
+        try:
+            typ = hostdevinfo[1]['type']
+            if typ == 'usb':
+                typ = 'usb_device'
+            vendor_id = hostdevinfo[1]['vendor']['id']
+            product_id = hostdevinfo[1]['product']['id']
+        except Exception, e:
+            vendor_id = -1
+            product_id = -1
+
+        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 e363de9ac549 src/vmm-details.glade
--- a/src/vmm-details.glade	Wed Oct 21 12:01:53 2009 -0400
+++ b/src/vmm-details.glade	Mon Oct 26 15:58:02 2009 +0100
@@ -3474,8 +3474,8 @@
                                           <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="top_attach">0</property>
+                                            <property name="bottom_attach">1</property>
                                             <property name="y_options"></property>
                                           </packing>
                                         </child>
@@ -3499,13 +3499,59 @@
                                             <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">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="label9">
                                             <property name="visible">True</property>
                                             <property name="xalign">1</property>
@@ -3536,8 +3582,48 @@
                                             <property name="label" translatable="yes">Source Device:</property>
                                           </widget>
                                           <packing>
-                                            <property name="top_attach">2</property>
-                                            <property name="bottom_attach">3</property>
+                                            <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>

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