[virt-tools-list] [PATCH] Add operating system icons to the main vmlist

Richard W.M. Jones rjones at redhat.com
Tue Apr 19 21:50:30 UTC 2011


This is mainly for discussion.  Here is what it looks like:

http://oirase.annexia.org/tmp/vmm-icons-in-vmlist.png

Of course without caching/persistency, these icons don't appear
immediately.  The inspection thread runs in the background inspecting
each guest one at a time, so the icons appear as the inspection thread
gets to them.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From 00dbdba51098224c6cebd2299a2fe65b54ca12d8 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Tue, 19 Apr 2011 22:23:50 +0100
Subject: [PATCH 2/2] Display operating system inspection icons in main
 vmlist.

---
 src/virtManager/manager.py |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/manager.py b/src/virtManager/manager.py
index 2abca04..029576c 100644
--- a/src/virtManager/manager.py
+++ b/src/virtManager/manager.py
@@ -44,6 +44,7 @@ ROW_IS_CONN_CONNECTED = 8
 ROW_IS_VM = 9
 ROW_IS_VM_RUNNING = 10
 ROW_COLOR = 11
+ROW_INSPECTION_OS_ICON = 12
 
 # Columns in the tree view
 COL_NAME = 0
@@ -402,9 +403,10 @@ class vmmManager(vmmGObjectUI):
         self.window.get_widget("vm-notebook").set_show_tabs(False)
 
         # Handle, name, markup, status, status icon, key/uuid, hint, is conn,
-        # is conn connected, is vm, is vm running, fg color
+        # is conn connected, is vm, is vm running, fg color, inspection icon
         model = gtk.TreeStore(object, str, str, str, gtk.gdk.Pixbuf, str, str,
-                              bool, bool, bool, bool, gtk.gdk.Color)
+                              bool, bool, bool, bool, gtk.gdk.Color,
+                              gtk.gdk.Pixbuf)
         vmlist.set_model(model)
         util.tooltip_wrapper(vmlist, ROW_HINT, "set_tooltip_column")
 
@@ -434,6 +436,12 @@ class vmmManager(vmmGObjectUI):
         statusCol.add_attribute(status_icon, 'pixbuf', ROW_STATUS_ICON)
         statusCol.add_attribute(status_icon, 'visible', ROW_IS_VM)
 
+        inspection_os_icon = gtk.CellRendererPixbuf()
+        statusCol.pack_start(inspection_os_icon, False)
+        statusCol.add_attribute(inspection_os_icon, 'pixbuf',
+                                ROW_INSPECTION_OS_ICON)
+        statusCol.add_attribute(inspection_os_icon, 'visible', ROW_IS_VM)
+
         name_txt = gtk.CellRendererText()
         nameCol.pack_start(name_txt, True)
         nameCol.add_attribute(name_txt, 'markup', ROW_MARKUP)
@@ -736,6 +744,7 @@ class vmmManager(vmmGObjectUI):
         vm.connect("status-changed", self.vm_status_changed)
         vm.connect("resources-sampled", self.vm_resources_sampled)
         vm.connect("config-changed", self.vm_resources_sampled)
+        vm.connect("inspection-changed", self.vm_inspection_changed)
 
         vmlist = self.window.get_widget("vm-list")
         model = vmlist.get_model()
@@ -804,6 +813,8 @@ class vmmManager(vmmGObjectUI):
         row.insert(ROW_IS_VM, True)
         row.insert(ROW_IS_VM_RUNNING, vm.is_active())
         row.insert(ROW_COLOR, gtk.gdk.Color(0, 0, 0))
+        row.insert(ROW_INSPECTION_OS_ICON,
+                   vm.inspection_os_icon(False))
 
         row[ROW_MARKUP] = self._build_vm_markup(vm, row)
 
@@ -841,6 +852,7 @@ class vmmManager(vmmGObjectUI):
         row.insert(ROW_IS_VM, False)
         row.insert(ROW_IS_VM_RUNNING, False)
         row.insert(ROW_COLOR, self._build_conn_color(conn))
+        row.insert(ROW_INSPECTION_OS_ICON, None)
 
         _iter = model.append(None, row)
         path = model.get_path(_iter)
@@ -940,6 +952,17 @@ class vmmManager(vmmGObjectUI):
         row[ROW_MARKUP] = self._build_vm_markup(vm, row)
         model.row_changed(row.path, row.iter)
 
+    def vm_inspection_changed(self, vm):
+        vmlist = self.window.get_widget("vm-list")
+        model = vmlist.get_model()
+
+        if self.vm_row_key(vm) not in self.rows:
+            return
+
+        row = self.rows[self.vm_row_key(vm)]
+        row[ROW_INSPECTION_OS_ICON] = vm.inspection_os_icon(False)
+        model.row_changed(row.path, row.iter)
+
     def conn_state_changed(self, conn):
         self.conn_refresh_resources(conn)
         self.vm_selected()
-- 
1.7.4.4



More information about the virt-tools-list mailing list