[PATCH virt-manager v4] virt-manager: prevent attach of inactive nodedevs

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

 



With virt-manager application, it is possible to add inactive node
devices(eg: mediated device) in host system to guest system. But it is
impossible to start a guest system with inactive node devices.  Also,
it is not yet possible to start a node device with virt-manager
application. So, the user cannot use the inactive node devices.

This patch disables the "finish" button and provides a tip, when
inactive node devices are selected. So, it is not possible to add
inactive node devices to the guest system.

Signed-off-by: Shalini Chellathurai Saroja <shalini@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 virtManager/addhardware.py | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 132ba4e0..88ed4579 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -754,15 +754,34 @@ class vmmAddHardware(vmmGObjectUI):
     def _build_hostdev_treeview(self):
         host_dev = self.widget("host-device")
         # [ xmlobj, label]
-        host_dev_model = Gtk.ListStore(object, str)
+        host_dev_model = Gtk.ListStore(object, str, bool)
         host_dev.set_model(host_dev_model)
         host_col = Gtk.TreeViewColumn()
         text = Gtk.CellRendererText()
         host_col.pack_start(text, True)
         host_col.add_attribute(text, 'text', 1)
+        host_col.add_attribute(text, 'sensitive', 2)
         host_dev_model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
         host_dev.append_column(host_col)
 
+
+    def _hostdev_row_selected_cb(self, selection):
+        model, treeiter = selection.get_selected()
+
+        if treeiter is None:
+            return
+
+        row = model[treeiter]
+        tooltip = None
+        sensitive = row[2]
+        if row[0] and sensitive is False:
+            tooltip = (_("%s is not active in the host system.\n"
+            "Please start the mdev in the host system before adding it to the guest.")
+            % row[1])
+        self.widget("create-finish").set_tooltip_text(tooltip)
+        self.widget("create-finish").set_sensitive(sensitive)
+
+
     def _populate_hostdev_model(self, devtype):
         devlist = self.widget("host-device")
         model = devlist.get_model()
@@ -790,12 +809,17 @@ class vmmAddHardware(vmmGObjectUI):
                         prettyname = "%s %s" % (
                                 parentdev.pretty_name(), prettyname)
 
-            model.append([dev.xmlobj, prettyname])
+            model.append([dev.xmlobj, prettyname, dev.is_active()])
 
         if len(model) == 0:
-            model.append([None, _("No Devices Available")])
+            model.append([None, _("No Devices Available"), False])
+
         uiutil.set_list_selection_by_number(devlist, 0)
 
+        devlist.get_selection().connect("changed",
+                                        self._hostdev_row_selected_cb)
+        devlist.get_selection().emit("changed")
+
 
     @staticmethod
     def build_video_combo(vm, combo):
-- 
2.34.1




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux