commit 6fa885e5831e637976487e39c877ab3a80325ee8 Author: Marc-André Lureau Date: Tue Apr 5 01:35:31 2011 +0200 addhardware: allow setting the char device target name diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py index a8ceb78..91ece33 100644 --- a/src/virtManager/addhardware.py +++ b/src/virtManager/addhardware.py @@ -54,6 +54,7 @@ char_widget_mappings = { "bind_port" : "char-bind-port", "bind_host" : "char-bind-host", "protocol" : "char-use-telnet", + "target_name" : "char-target-name", } def get_list_selection(widget): @@ -117,6 +118,7 @@ class vmmAddHardware(vmmGObjectUI): "char_host_focus_in": (self.update_doc, "source_host"), "char_bind_host_focus_in": (self.update_doc, "bind_host"), "char_telnet_focus_in": (self.update_doc, "protocol"), + "char_name_focus_in": (self.update_doc, "target_name"), }) util.bind_escape_key_close(self) @@ -443,6 +445,7 @@ class vmmAddHardware(vmmGObjectUI): self.window.get_widget("char-bind-host").set_text("127.0.0.1") self.window.get_widget("char-bind-port").get_adjustment().value = 4556 self.window.get_widget("char-use-telnet").set_active(False) + self.window.get_widget("char-target-name").set_text("com.redhat.spice.0") # Hide all notebook pages, so the wizard isn't as big as the largest # page @@ -1143,6 +1146,7 @@ class vmmAddHardware(vmmGObjectUI): bind_host = self.window.get_widget("char-bind-host").get_text() source_port = self.window.get_widget("char-port").get_adjustment().value bind_port = self.window.get_widget("char-bind-port").get_adjustment().value + target_name = self.window.get_widget("char-target-name").get_text() if self.window.get_widget("char-use-telnet").get_active(): protocol = VirtualCharDevice.CHAR_PROTOCOL_TELNET @@ -1156,6 +1160,7 @@ class vmmAddHardware(vmmGObjectUI): "bind_port": bind_port, "bind_host": bind_host, "protocol": protocol, + "target_name": target_name, } try: diff --git a/src/vmm-add-hardware.glade b/src/vmm-add-hardware.glade index bbd3a42..c5087a1 100644 --- a/src/vmm-add-hardware.glade +++ b/src/vmm-add-hardware.glade @@ -1504,7 +1504,7 @@ to connect to the virtual machine. True - 5 + 6 2 8 8 @@ -1520,6 +1520,34 @@ to connect to the virtual machine. + + True + True + + + + 1 + 2 + 5 + 6 + + + + + True + 0 + Name: + True + char-use-telnet + + + 5 + 6 + GTK_FILL + + + + True True commit ce9a125728b6622008849dd9c35309e36104913e Author: Marc-André Lureau Date: Tue Apr 5 01:35:32 2011 +0200 addhardware: fix adding and removing a channel device diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py index 91ece33..885c8b9 100644 --- a/src/virtManager/addhardware.py +++ b/src/virtManager/addhardware.py @@ -286,19 +286,6 @@ class vmmAddHardware(vmmGObjectUI): video_dev = self.window.get_widget("video-model") uihelpers.build_video_combo(self.vm, video_dev) - # Char device type - char_devtype = self.window.get_widget("char-device-type") - # Type name, desc - char_devtype_model = gtk.ListStore(str, str) - char_devtype.set_model(char_devtype_model) - text = gtk.CellRendererText() - char_devtype.pack_start(text, True) - char_devtype.add_attribute(text, 'text', 1) - for t in VirtualCharDevice.char_types: - desc = VirtualCharDevice.get_char_type_desc(t) - row = [t, desc + " (%s)" % t] - char_devtype_model.append(row) - # Character dev mode char_mode = self.window.get_widget("char-mode") # Mode name, desc @@ -358,6 +345,10 @@ class vmmAddHardware(vmmGObjectUI): self.vm.is_hvm(), _("Not supported for this guest type."), "parallel") + add_hw_option("Channel", gtk.STOCK_CONNECT, PAGE_CHAR, + self.vm.is_hvm(), + _("Not supported for this guest type."), + "channel") add_hw_option("USB Host Device", "system-run", PAGE_HOSTDEV, self.vm.get_connection().is_nodedev_capable(), _("Connection does not support host device enumeration"), @@ -688,6 +679,23 @@ class vmmAddHardware(vmmGObjectUI): def get_hw_selection(self): return get_list_selection(self.window.get_widget("hardware-list")) + def update_char_device_type_model(self): + # Char device type + char_devtype = self.window.get_widget("char-device-type") + dev_type = self.get_char_type() + # Type name, desc + char_devtype_model = gtk.ListStore(str, str) + char_devtype.clear() + char_devtype.set_model(char_devtype_model) + text = gtk.CellRendererText() + char_devtype.pack_start(text, True) + char_devtype.add_attribute(text, 'text', 1) + for t in VirtualCharDevice.char_types_for_dev_type[dev_type]: + desc = VirtualCharDevice.get_char_type_desc(t) + row = [t, desc + " (%s)" % t] + char_devtype_model.append(row) + char_devtype.set_active(0) + def hw_selected(self, src=None): ignore = src self._dev = None @@ -707,6 +715,7 @@ class vmmAddHardware(vmmGObjectUI): self.window.get_widget("hardware-info").set_text(msg) if page == PAGE_CHAR: + self.update_char_device_type_model() devtype = self.window.get_widget("char-device-type") self.change_char_device_type(devtype) @@ -814,6 +823,8 @@ class vmmAddHardware(vmmGObjectUI): if label == "parallel": return VirtualDevice.VIRTUAL_DEV_PARALLEL + elif label == "channel": + return VirtualDevice.VIRTUAL_DEV_CHANNEL return VirtualDevice.VIRTUAL_DEV_SERIAL def dev_to_title(self, page): @@ -849,6 +860,9 @@ class vmmAddHardware(vmmGObjectUI): def change_char_device_type(self, src): self.update_doc(None, None, "char_type") + idx = src.get_active() + if idx < 0: + return chartype = self.get_char_type() devtype = src.get_model()[src.get_active()][0] @@ -863,7 +877,6 @@ class vmmAddHardware(vmmGObjectUI): self.window.get_widget(widget_name).set_sensitive(make_visible) has_mode = self._dev.supports_property("source_mode") - if has_mode and self.window.get_widget("char-mode").get_active() == -1: self.window.get_widget("char-mode").set_active(0) diff --git a/src/virtManager/details.py b/src/virtManager/details.py index 69e2b1a..ca21c2d 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -2752,7 +2752,7 @@ class vmmDetails(vmmGObjectUI): port = chardev.target_port label = devtype.capitalize() - if devtype != "console": + if devtype not in ["console", "channel"]: # Don't show port for console label += " %s" % (int(port) + 1) diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py index 9730233..7fc66ed 100644 --- a/src/virtManager/domain.py +++ b/src/virtManager/domain.py @@ -46,6 +46,7 @@ def compare_device(origdev, newdev, idx): "console" : ["char_type", "target_type", "target_port"], "graphics" : ["type", "vmmindex"], "controller" : ["type", "index"], + "channel" : ["char_type", "target_name"], } if id(origdev) == id(newdev): @@ -713,8 +714,9 @@ class vmmDomainBase(vmmLibvirtObject): serials = self._build_device_list("serial") parallels = self._build_device_list("parallel") consoles = self._build_device_list("console") + channels = self._build_device_list("channel") - for devicelist in [serials, parallels, consoles]: + for devicelist in [serials, parallels, consoles, channels]: devs.extend(devicelist) # Don't display if it's just a duplicate of commit 127e065d9ee7c5bee0f221352e51fb51ccff1626 Author: Marc-André Lureau Date: Tue Apr 5 01:35:33 2011 +0200 details: show char device target name diff --git a/src/virtManager/details.py b/src/virtManager/details.py index ca21c2d..8e6e50e 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -2495,6 +2495,7 @@ class vmmDetails(vmmGObjectUI): target_port = chardev.target_port dev_type = chardev.char_type or "pty" src_path = chardev.source_path + target_name = chardev.target_name primary = hasattr(chardev, "virtmanager_console_dup") typelabel = "" @@ -2518,6 +2519,7 @@ class vmmDetails(vmmGObjectUI): self.window.get_widget("char-type").set_markup(typelabel) self.window.get_widget("char-dev-type").set_text(dev_type) self.window.get_widget("char-source-path").set_text(src_path or "-") + self.window.get_widget("char-target-name").set_text(target_name or "-") def refresh_hostdev_page(self): hostdev = self.get_hw_selection(HW_LIST_COL_DEVICE) diff --git a/src/vmm-details.glade b/src/vmm-details.glade index d0d3837..d23c3da 100644 --- a/src/vmm-details.glade +++ b/src/vmm-details.glade @@ -4681,7 +4681,7 @@ I/O: True 3 - 2 + 3 2 8 4 @@ -4689,7 +4689,7 @@ I/O: True 1 - Device Type: + Device type: GTK_FILL @@ -4700,7 +4700,7 @@ I/O: True 1 - Source Path: + Source path: 1 @@ -4710,6 +4710,19 @@ I/O: + + True + 1 + Target name: + + + 2 + 3 + GTK_FILL + + + + True 0 @@ -4739,6 +4752,22 @@ I/O: + + + True + 0 + label508 + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + commit 69ba897ac35731bf6cfca00a3e8ac30485a9855d Author: Marc-André Lureau Date: Tue Apr 5 01:35:34 2011 +0200 details: propose to add or remove Spice agent when switching crobinso: Improve metric for deciding to ask about add/remove agent diff --git a/src/virtManager/details.py b/src/virtManager/details.py index 8e6e50e..eb5a9e5 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -1850,17 +1850,54 @@ class vmmDetails(vmmGObjectUI): (dev_id_info, nettype, source)]) # Graphics options + def _do_change_spicevmc(self, gdev, newgtype): + has_multi_spice = (len(filter( + lambda dev: dev.type == dev.TYPE_SPICE, + self.vm.get_graphics_devices())) > 1) + has_spicevmc = bool(filter( + (lambda dev: + (dev.dev_type == dev.DEV_CHANNEL and + dev.char_type == dev.CHAR_SPICEVMC)), + self.vm.get_char_devices())) + fromspice = (gdev.type == "spice") + tospice = (newgtype == "spice") + + if fromspice and tospice: + return False + if not fromspice and not tospice: + return False + + print tospice, fromspice, has_spicevmc, has_multi_spice + + if tospice and has_spicevmc: + return False + if fromspice and not has_spicevmc: + return False + + if fromspice and has_multi_spice: + # Don't offer to remove if there are other spice displays + return False + + msg = (_("You are switching graphics type to %(gtype)s, " + "would you like to %(action)s Spice agent channels?") % + {"gtype": newgtype, + "action": fromspice and "remove" or "add"}) + return self.err.yes_no(msg) + def config_graphics_apply(self, dev_id_info): gtype = self.get_combo_label_value("gfx-type") passwd = self.window.get_widget("gfx-password").get_text() or None keymap = self.get_combo_label_value("gfx-keymap") + change_spicevmc = self._do_change_spicevmc(dev_id_info, gtype) + 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, + change_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):