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

[virt-tools-list] [PATCH 4/4] details: propose to add or remove Spice agent when switching



---
 src/virtManager/details.py |   13 ++++++++++++-
 src/virtManager/domain.py  |   14 +++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/details.py b/src/virtManager/details.py
index 8e6e50e..2a62ba9 100644
--- a/src/virtManager/details.py
+++ b/src/virtManager/details.py
@@ -1855,12 +1855,23 @@ class vmmDetails(vmmGObjectUI):
         passwd = self.window.get_widget("gfx-password").get_text() or None
         keymap = self.get_combo_label_value("gfx-keymap")
 
+        dialog = gtk.MessageDialog(parent = self.window.get_widget("vmm-details"),
+                                   type = gtk.MESSAGE_QUESTION,
+                                   buttons = gtk.BUTTONS_YES_NO,
+                                   message_format = \
+                                       _("You are switching graphics type to %s, " \
+                                         "would you like to %s Spice agent channels?") %
+                                         (gtype, gtype == "vnc" and "remove" or "add"))
+        result = dialog.run()
+        dialog.hide()
+        spicevmc = result == gtk.RESPONSE_YES
+
         return self._change_config_helper([self.vm.define_graphics_password,
                                            self.vm.define_graphics_keymap,
                                            self.vm.define_graphics_type],
                                           [(dev_id_info, passwd),
                                            (dev_id_info, keymap),
-                                           (dev_id_info, gtype)],
+                                           (dev_id_info, gtype, spicevmc)],
                                           [self.vm.hotplug_graphics_password],
                                           [(dev_id_info, passwd)])
 
diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py
index 7fc66ed..a4d2f5c 100644
--- a/src/virtManager/domain.py
+++ b/src/virtManager/domain.py
@@ -26,6 +26,7 @@ import threading
 import gobject
 
 import virtinst
+from virtinst.VirtualCharDevice import VirtualCharSpicevmcDevice
 from virtManager import util
 import virtinst.support as support
 
@@ -450,9 +451,20 @@ class vmmDomainBase(vmmLibvirtObject):
         def change(editdev):
             editdev.keymap = newval
         return self._redefine_device(change, devobj)
-    def define_graphics_type(self, devobj, newval):
+    def define_graphics_type(self, devobj, newval, spicevmc):
         def change(editdev):
             editdev.type = newval
+            if spicevmc:
+                guest = self._get_guest_to_define()
+                if newval == "spice":
+                    guest.add_device(VirtualCharSpicevmcDevice(guest.conn))
+                else:
+                    channels = guest.get_devices("channel")
+                    channels = filter(lambda x: x.char_type ==
+                                      virtinst.VirtualCharDevice.CHAR_SPICEVMC, channels)
+                    for dev in channels:
+                        guest.remove_device(dev)
+
         return self._redefine_device(change, devobj)
 
     def define_sound_model(self, devobj, newmodel):
-- 
1.7.4


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