From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> Similarly to virt-install --listen=none, add an option to disable all extra display server listening interface/ports. Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- virtManager/addhardware.py | 10 +++++++--- virtManager/domain.py | 4 ++++ virtManager/gfxdetails.py | 28 +++++++++++++++++++++------- virtinst/devicegraphics.py | 16 +++++++++++++++- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 60b9157..87f397e 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -1546,10 +1546,14 @@ class vmmAddHardware(vmmGObjectUI): self._dev = virtinst.VirtualGraphics(self.conn.get_backend()) self._dev.type = gtype - self._dev.port = port self._dev.passwd = passwd - self._dev.listen = addr - self._dev.tlsPort = tlsport + + if addr == "none": + self._dev.set_listen_none() + else: + self._dev.listen = addr + self._dev.port = port + self._dev.tlsPort = tlsport if keymap: self._dev.keymap = keymap except ValueError, e: diff --git a/virtManager/domain.py b/virtManager/domain.py index 6e742b9..96bae64 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -847,6 +847,10 @@ class vmmDomain(vmmLibvirtObject): if gl != _SENTINEL: editdev.gl = gl + if listen == "none": + editdev.set_listen_none() + else: + editdev.remove_listen_none() if do_hotplug: self.hotplug(device=editdev) else: diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py index f3cd3a9..40e0cd8 100644 --- a/virtManager/gfxdetails.py +++ b/virtManager/gfxdetails.py @@ -51,7 +51,7 @@ class vmmGraphicsDetails(vmmGObjectUI): "on_graphics_use_password": self._change_password_chk, "on_graphics_password_changed": lambda ignore: self.emit("changed-password"), - "on_graphics_address_changed": lambda ignore: self.emit("changed-address"), + "on_graphics_address_changed": self._change_graphics_address, "on_graphics_tlsport_changed": lambda ignore: self.emit("changed-tlsport"), "on_graphics_port_changed": lambda ignore: self.emit("changed-port"), "on_graphics_keymap_changed": lambda ignore: self.emit("changed-keymap"), @@ -86,6 +86,7 @@ class vmmGraphicsDetails(vmmGObjectUI): model.append([None, _("Hypervisor default")]) model.append(["127.0.0.1", _("Localhost only")]) model.append(["0.0.0.0", _("All interfaces")]) + model.append(["none", _("None")]) # Keymap combo = self.widget("graphics-keymap") @@ -181,8 +182,12 @@ class vmmGraphicsDetails(vmmGObjectUI): use_passwd = gfx.passwd is not None set_port("graphics-port", gfx.port) - uiutil.set_list_selection( - self.widget("graphics-address"), gfx.listen) + if gfx.has_listen_none(): + uiutil.set_list_selection( + self.widget("graphics-address"), "none") + else: + uiutil.set_list_selection( + self.widget("graphics-address"), gfx.listen) uiutil.set_list_selection( self.widget("graphics-keymap"), gfx.keymap or None) @@ -211,15 +216,20 @@ class vmmGraphicsDetails(vmmGObjectUI): ############# def _show_rows_from_type(self): - hide_all = ["graphics-xauth", "graphics-display", "graphics-address", + hide_all = ["graphics-xauth", "graphics-display", "graphics-password-box", "graphics-keymap", "graphics-port-box", "graphics-tlsport-box", "graphics-opengl"] gtype = uiutil.get_list_selection(self.widget("graphics-type")) + addr = uiutil.get_list_selection(self.widget("graphics-address")) + sdl_rows = ["graphics-xauth", "graphics-display"] - vnc_rows = ["graphics-password-box", "graphics-address", - "graphics-port-box", "graphics-keymap"] - spice_rows = vnc_rows[:] + ["graphics-tlsport-box"] + vnc_rows = ["graphics-password-box", "graphics-keymap"] + if addr != "none": + vnc_rows.extend(["graphics-port-box"]) + spice_rows = vnc_rows[:] + if addr != "none": + spice_rows.extend(["graphics-tlsport-box"]) if self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_GL): spice_rows.extend(["graphics-opengl"]) @@ -238,6 +248,10 @@ class vmmGraphicsDetails(vmmGObjectUI): self._show_rows_from_type() self.emit("changed-type") + def _change_graphics_address(self, ignore): + self._show_rows_from_type() + self.emit("changed-address") + def _change_port_auto(self, ignore): self.widget("graphics-port-auto").set_inconsistent(False) self._change_ports() diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py index 07b554e..e885418 100644 --- a/virtinst/devicegraphics.py +++ b/virtinst/devicegraphics.py @@ -202,6 +202,11 @@ class VirtualGraphics(VirtualDevice): self.remove_child(find_listen[0]) else: find_listen[0].address = val + + if self.port is None and self.tlsPort is None and self.type == "spice": + self.port = -1 + self.tlsPort = -1 + return val listen = XMLProperty("./@listen", set_converter=_set_listen) @@ -219,16 +224,25 @@ class VirtualGraphics(VirtualDevice): for listen in self.listens: self.remove_child(listen) + def remove_listen_none(self): + for listen in self.listens: + if listen.type == "none": + self.remove_child(listen) + def add_listen(self): obj = _GraphicsListen(self.conn) self.add_child(obj) return obj + def has_listen_none(self): + return len(self.listens) > 0 and self.listens[0].type == "none" + def set_listen_none(self): self.remove_all_listens() + self.listen = None self.port = None self.tlsPort = None - self.autoport = False + self.autoport = None self.socket = None if self.conn.check_support( -- 2.10.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list