[virt-tools-list] [virt-manager PATCH 3/7] details: Show attached disk information in scsi controller page

Lin Ma lma at suse.com
Mon Nov 6 12:52:05 UTC 2017


It helps users to recognize controllers <-> disks mapping relationship.

Signed-off-by: Lin Ma <lma at suse.com>
---
 ui/details.ui          | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 virtManager/details.py | 25 ++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/ui/details.ui b/ui/details.ui
index f307f340..1202db07 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -4990,6 +4990,54 @@ if you know what you are doing.</small></property>
                                         <property name="top_attach">1</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkLabel" id="disk-list-label">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="halign">start</property>
+                                        <property name="label" translatable="yes">Disks:</property>
+                                        <property name="use_markup">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">2</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkBox" id="scsi-disk-box">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="orientation">vertical</property>
+                                        <property name="spacing">3</property>
+                                        <child>
+                                          <object class="GtkScrolledWindow" id="scsi-disk-scroll">
+                                            <property name="width_request">270</property>
+                                            <property name="height_request">100</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="shadow_type">in</property>
+                                            <child>
+                                              <object class="GtkTreeView" id="scsi-disk-list">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <child internal-child="selection">
+                                                  <object class="GtkTreeSelection" id="scsi-disk-selection"/>
+                                                </child>
+                                              </object>
+                                            </child>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">2</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
diff --git a/virtManager/details.py b/virtManager/details.py
index 22e0786e..a9e0cb79 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -1042,6 +1042,16 @@ class vmmDetails(vmmGObjectUI):
         uiutil.init_combo_text_column(combo, 1)
         combo.set_active(-1)
 
+        attached_disk_list = self.widget("scsi-disk-list")
+        model = Gtk.ListStore(str)
+        attached_disk_list.set_model(model)
+        attached_disk_list.set_headers_visible(False)
+        diskTextCol = Gtk.TreeViewColumn()
+        disk_txt = Gtk.CellRendererText()
+        diskTextCol.pack_start(disk_txt, True)
+        diskTextCol.add_attribute(disk_txt, 'text', 0)
+        attached_disk_list.append_column(diskTextCol)
+
 
     ##########################
     # Window state listeners #
@@ -2995,17 +3005,30 @@ class vmmDetails(vmmGObjectUI):
         if not dev:
             return
 
+        self.widget("disk-list-label").set_visible(False)
+        self.widget("scsi-disk-box").set_visible(False)
         can_remove = True
         if self.vm.get_xmlobj().os.is_x86() and dev.type == "usb":
             can_remove = False
         if dev.type == "pci":
             can_remove = False
         if dev.type == "scsi":
+            model = self.widget("scsi-disk-list").get_model()
+            model.clear()
             for disk in self.vm.get_disk_devices(inactive=True):
                 if (dev.type == disk.bus and
                     dev.index == disk.address.controller):
                     can_remove = False
-                    break
+                    name = _label_for_device(disk)
+                    bus = disk.address.bus
+                    target = disk.address.target
+                    unit = disk.address.unit
+                    infoStr = ("%s:  bus = %s, target = %s, unit = %s" %
+                               (name, bus, target, unit))
+                    model.append([infoStr])
+            self.widget("disk-list-label").set_visible(not can_remove)
+            self.widget("scsi-disk-box").set_visible(not can_remove)
+
         self.widget("config-remove").set_sensitive(can_remove)
 
         type_label = dev.pretty_desc()
-- 
2.14.0




More information about the virt-tools-list mailing list