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

[virt-tools-list] [PATCH] Virt-manager host device information bits



Hi,
this is new patch for host device information to just find & show pretty name of device for USB and PCI devices, tested with test driver so please review...

Thanks,
Michal
diff -r a5b9807ead04 src/virtManager/details.py
--- a/src/virtManager/details.py	Sun Nov 01 21:56:21 2009 -0500
+++ b/src/virtManager/details.py	Tue Nov 03 18:19:29 2009 +0100
@@ -913,12 +913,76 @@
         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']
+            device = 0
+            bus = 0
+            domain = 0
+            func = 0
+            slot = 0
+        except Exception, e:
+            try:
+                device = int(hostdevinfo[1]['address']['device'] or '0x00', 16)
+                bus = int(hostdevinfo[1]['address']['bus'] or '0x00', 16)
+                domain = int(hostdevinfo[1]['address']['domain'] or '0x00', 16)
+                func = int(hostdevinfo[1]['address']['function'] or '0x00', 16)
+                slot = int(hostdevinfo[1]['address']['slot'] or '0x00', 16)
+                vendor_id = -1
+                product_id = -1
+            except Exception, e:
+                device = 0
+                bus = 0
+                domain = 0
+                func = 0
+                slot = 0
+                vendor_id = -1
+                product_id = -1
+
+        dev_pretty_name = None
+        devs = self.vm.get_connection().get_devices( typ, None )
+
+        # Try to get info from {product|vendor}_id
+        for dev in devs:
+            if dev.product_id == product_id and dev.vendor_id == vendor_id:
+                dev_pretty_name = dev.pretty_name()
+
+        if not dev_pretty_name:
+            # Try to get info from bus/addr
+            for dev in devs:
+                try:
+                    dev_id = int(dev.device)
+                except Exception, e:
+                    dev_id = -1
+                try:
+                    bus_id = int(dev.bus)
+                except Exception, e:
+                    bus_id = -1
+                try:
+                    domain_id = int(dev.domain)
+                except Exception, e:
+                    domain_id = -1
+                try:
+                    func_id = int(dev.function)
+                except Exception, e:
+                    func_id = -1
+                try:
+                    slot_id = int(dev.slot)
+                except Exception, e:
+                    slot_id = -1
+
+                if ((dev_id == device and bus_id == bus)
+                  or (domain_id == domain and func_id == func and slot_id == slot)):
+                    dev_pretty_name = dev.pretty_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-source").set_text(dev_pretty_name or "-")
 
     def refresh_video_page(self):
         vidinfo = self.get_hw_selection(HW_LIST_COL_DEVICE)
diff -r a5b9807ead04 src/vmm-details.glade
--- a/src/vmm-details.glade	Sun Nov 01 21:56:21 2009 -0500
+++ b/src/vmm-details.glade	Tue Nov 03 18:19:29 2009 +0100
@@ -6,7 +6,6 @@
     <property name="title" translatable="yes">Virtual Machine</property>
     <property name="default_width">800</property>
     <property name="default_height">600</property>
-    <signal name="delete_event" handler="on_vmm_details_delete_event"/>
     <child>
       <widget class="GtkVBox" id="vbox2">
         <property name="visible">True</property>
@@ -3430,6 +3429,16 @@
                                         <property name="column_spacing">8</property>
                                         <property name="row_spacing">4</property>
                                         <child>
+                                          <widget class="GtkLabel" id="label8">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Source Device:</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="y_options"></property>
+                                          </packing>
+                                        </child>
+                                        <child>
                                           <widget class="GtkLabel" id="hostdev-source">
                                             <property name="visible">True</property>
                                             <property name="xalign">0</property>
@@ -3438,73 +3447,24 @@
                                           <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="x_options"></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>
-                                            <property name="label">label</property>
-                                          </widget>
-                                          <packing>
-                                            <property name="left_attach">1</property>
-                                            <property name="right_attach">2</property>
-                                            <property name="top_attach">1</property>
-                                            <property name="bottom_attach">2</property>
-                                            <property name="y_options"></property>
-                                          </packing>
+                                          <placeholder/>
                                         </child>
                                         <child>
-                                          <widget class="GtkLabel" id="hostdev-type">
-                                            <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="y_options"></property>
-                                          </packing>
+                                          <placeholder/>
                                         </child>
                                         <child>
-                                          <widget class="GtkLabel" id="label9">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">1</property>
-                                            <property name="label" translatable="yes">Device Mode:</property>
-                                          </widget>
-                                          <packing>
-                                            <property name="top_attach">1</property>
-                                            <property name="bottom_attach">2</property>
-                                            <property name="x_options">GTK_FILL</property>
-                                            <property name="y_options"></property>
-                                          </packing>
+                                          <placeholder/>
                                         </child>
                                         <child>
-                                          <widget class="GtkLabel" id="label8">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">1</property>
-                                            <property name="label" translatable="yes">Device Type:</property>
-                                          </widget>
-                                          <packing>
-                                            <property name="x_options">GTK_FILL</property>
-                                            <property name="y_options"></property>
-                                          </packing>
+                                          <placeholder/>
                                         </child>
                                         <child>
-                                          <widget class="GtkLabel" id="label3">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">1</property>
-                                            <property name="label" translatable="yes">Source Device:</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>
+                                          <placeholder/>
                                         </child>
                                       </widget>
                                     </child>

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