diff --git a/tests/uitests/addhardware.py b/tests/uitests/addhardware.py
index 9ea8222e8..5001cd374 100644
--- a/tests/uitests/addhardware.py
+++ b/tests/uitests/addhardware.py
@@ -387,7 +387,7 @@ class AddHardware(uiutils.UITestCase):
tab = self._select_hw(addhw, "Console", "char-tab")
tab.find("Device Type:", "combo box").click()
tab.find_fuzzy("Pseudo TTY", "menu item").click()
- tab.find("Type:", "combo box").click()
+ tab.find("Type:", "combo box").click_combo_entry()
tab.find_fuzzy("Hypervisor default", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@@ -401,20 +401,10 @@ class AddHardware(uiutils.UITestCase):
finish.click()
uiutils.check_in_loop(lambda: details.active)
- # Add udp serial
- self._open_addhw_window(details)
- tab = self._select_hw(addhw, "Serial", "char-tab")
- tab.find("Device Type:", "combo box").click()
- tab.find_fuzzy("UDP", "menu item").click()
- finish.click()
- uiutils.check_in_loop(lambda: details.active)
-
- # Add parallel+device
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Parallel", "char-tab")
tab.find("Device Type:", "combo box").click()
- tab.find_fuzzy("Physical host character", "menu item").click()
- tab.find("Path:", "text").text = "/dev/parallel0"
+ tab.find_fuzzy("Unix", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index 71321b2d8..4001ca64e 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -845,127 +845,6 @@
4
-
-
-
- 1
- 9
-
-
-
-
-
- 1
- 7
-
-
-
-
-
- 1
- 6
-
-
-
-
- True
- False
- 6
-
-
- True
- True
-
-
- True
- True
- 0
-
-
-
-
- True
- False
- start
- Po_rt:
- True
- char-bind-port
-
-
- False
- True
- 1
-
-
-
-
- True
- True
- adjustment2
-
-
- False
- True
- 2
-
-
-
-
- 1
- 8
-
-
True
@@ -980,62 +859,6 @@
4
-
-
- True
- False
- start
- _Mode:
- True
- char-mode
-
-
- 0
- 7
-
-
-
-
- True
- False
- start
- H_ost:
- True
- char-host
-
-
- 0
- 6
-
-
-
-
- True
- False
- start
- _Bind Host:
- True
- char-mode
-
-
- 0
- 8
-
-
-
-
- True
- False
- start
- Use Te_lnet:
- True
- char-use-telnet
-
-
- 0
- 9
-
-
True
@@ -1076,17 +899,6 @@
2
-
-
- True
- False
- start
-
-
- 1
- 2
-
-
True
@@ -1171,6 +983,23 @@
5
+
+
+ True
+ False
+ start
+ True
+
+
+ True
+
+
+
+
+ 1
+ 2
+
+
char-tab
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index ba3b3ac98..3cc6c552c 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -202,7 +202,6 @@ class vmmAddHardware(vmmGObjectUI):
self._build_hostdev_treeview()
self.build_video_combo(self.vm, self.widget("video-model"))
_build_combo(self.widget("char-device-type"), [])
- self._build_char_mode_combo()
self._build_char_target_type_combo()
self._build_char_target_name_combo()
self.build_watchdogmodel_combo(self.vm, self.widget("watchdog-model"))
@@ -323,11 +322,6 @@ class vmmAddHardware(vmmGObjectUI):
# Char parameters
self.widget("char-path").set_text("")
self.widget("char-channel").set_text("")
- self.widget("char-host").set_text("127.0.0.1")
- self.widget("char-port").set_value(4555)
- self.widget("char-bind-host").set_text("127.0.0.1")
- self.widget("char-bind-port").set_value(4556)
- self.widget("char-use-telnet").set_active(False)
self.widget("char-auto-socket").set_active(True)
@@ -600,13 +594,6 @@ class vmmAddHardware(vmmGObjectUI):
_build_combo(combo, values, default_value=default)
- def _build_char_mode_combo(self):
- values = []
- for t in DeviceSerial.MODES:
- desc = DeviceSerial.pretty_mode(t)
- values.append([t, desc + " (%s)" % t])
- _build_combo(self.widget("char-mode"), values)
-
def _build_char_target_type_combo(self):
values = []
if self.conn.is_qemu():
@@ -622,25 +609,13 @@ class vmmAddHardware(vmmGObjectUI):
_build_combo(self.widget("char-target-name"), values)
def _populate_char_device_type_combo(self):
- stable_blacklist = ["pipe", "udp"]
-
- # Char device type
- char_devtype = self.widget("char-device-type")
- char_devtype_model = char_devtype.get_model()
- char_devtype_model.clear()
char_class = self._get_char_class()
+ model = self.widget("char-device-type").get_model()
+ model.clear()
- # Type name, desc
- for t in char_class.TYPES:
- if (t in stable_blacklist and
- self.vm.xmlobj.stable_defaults()):
- continue
-
- desc = char_class.pretty_type(t)
- row = [t, desc + " (%s)" % t]
- char_devtype_model.append(row)
-
- uiutil.set_list_selection(char_devtype, "pty")
+ for t in char_class.get_recommended_types(self.vm.xmlobj):
+ model.append([t, char_class.pretty_type(t) + " (%s)" % t])
+ uiutil.set_list_selection(self.widget("char-device-type"), "pty")
@staticmethod
@@ -939,7 +914,6 @@ class vmmAddHardware(vmmGObjectUI):
doshow = not src.get_active()
uiutil.set_grid_row_visible(self.widget("char-path-label"), doshow)
- uiutil.set_grid_row_visible(self.widget("char-mode-label"), doshow)
def _change_char_target_name(self, src):
if not src.get_visible():
@@ -964,29 +938,18 @@ class vmmAddHardware(vmmGObjectUI):
if devtype is None:
return
- char_widget_mappings = {
- "source_path": "char-path",
- "source_channel": "char-channel",
- "source_mode": "char-mode",
- "source_host": "char-host",
- "bind_host": "char-bind-host",
- "protocol": "char-use-telnet",
- }
-
char_class = self._get_char_class()
+ dev = char_class(self.conn.get_backend())
+ dev.type = devtype
- self._dev = char_class(self.conn.get_backend())
- self._dev.type = devtype
+ ischan = dev.DEVICE_TYPE == "channel"
+ iscon = dev.DEVICE_TYPE == "console"
+ show_auto = devtype == "unix" and ischan
- ischan = self._dev.DEVICE_TYPE == "channel"
- iscon = self._dev.DEVICE_TYPE == "console"
- show_auto = (devtype == "unix" and ischan and
- self.conn.check_support(self.conn.SUPPORT_CONN_AUTOSOCKET))
-
- for param_name, widget_name in char_widget_mappings.items():
- make_visible = self._dev.supports_property(param_name)
- uiutil.set_grid_row_visible(self.widget(widget_name + "-label"),
- make_visible)
+ uiutil.set_grid_row_visible(self.widget("char-path-label"),
+ dev.supports_property("source_path"))
+ uiutil.set_grid_row_visible(self.widget("char-channel-label"),
+ dev.supports_property("source_channel"))
uiutil.set_grid_row_visible(
self.widget("char-target-name-label"), ischan)
@@ -996,10 +959,6 @@ class vmmAddHardware(vmmGObjectUI):
self.widget("char-auto-socket-label"), show_auto)
self.widget("char-auto-socket").emit("toggled")
- has_mode = self._dev.supports_property("source_mode")
- if has_mode and self.widget("char-mode").get_active() == -1:
- self.widget("char-mode").set_active(0)
-
def _change_usbredir_type(self, src):
pass
@@ -1392,29 +1351,14 @@ class vmmAddHardware(vmmGObjectUI):
def _validate_page_char(self):
char_class = self._get_char_class()
- modebox = self.widget("char-mode")
- devbox = self.widget("char-device-type")
+ devtype = uiutil.get_list_selection(self.widget("char-device-type"))
+
typebox = self.widget("char-target-type")
- devtype = uiutil.get_list_selection(devbox)
-
- devclass = char_class(self.conn.get_backend())
- devclass.type = devtype
-
source_path = self.widget("char-path").get_text()
source_channel = self.widget("char-channel").get_text()
- source_mode = uiutil.get_list_selection(modebox)
- source_host = self.widget("char-host").get_text()
- bind_host = self.widget("char-bind-host").get_text()
- source_port = self.widget("char-port").get_value()
- bind_port = self.widget("char-bind-port").get_value()
target_name = self.widget("char-target-name").get_child().get_text()
target_type = uiutil.get_list_selection(typebox)
- if self.widget("char-use-telnet").get_active():
- protocol = DeviceSerial.PROTOCOL_TELNET
- else:
- protocol = DeviceSerial.PROTOCOL_RAW
-
if not self.widget("char-target-name").get_visible():
target_name = None
if not typebox.get_visible():
@@ -1422,34 +1366,17 @@ class vmmAddHardware(vmmGObjectUI):
if (self.widget("char-auto-socket").get_visible() and
self.widget("char-auto-socket").get_active()):
source_path = None
- source_mode = "bind"
- if (devclass.type == "tcp" and source_mode == "bind"):
- devclass.bind_host = source_host
- devclass.bind_port = source_port
- source_host = source_port = source_mode = None
-
- value_mappings = {
- "source_path": source_path,
- "source_channel": source_channel,
- "source_mode": source_mode,
- "source_host": source_host,
- "source_port": source_port,
- "bind_port": bind_port,
- "bind_host": bind_host,
- "protocol": protocol,
- "target_name": target_name,
- "target_type": target_type,
- }
-
- self._dev = devclass
-
- for param_name, val in value_mappings.items():
- if self._dev.supports_property(param_name) and val is not None:
- setattr(self._dev, param_name, val)
-
- # Dump XML for sanity checking
- self._dev.get_xml()
+ self._dev = char_class(self.conn.get_backend())
+ self._dev.type = devtype
+ if self._dev.supports_property("source_path"):
+ self._dev.source_path = source_path
+ if self._dev.supports_property("source_channel"):
+ self._dev.source_channel = source_channel
+ if self._dev.supports_property("target_name"):
+ self._dev.target_name = target_name
+ if self._dev.supports_property("target_type"):
+ self._dev.target_type = target_type
def _validate_page_video(self):
model = uiutil.get_list_selection(self.widget("video-model"))
diff --git a/virtinst/devices/char.py b/virtinst/devices/char.py
index fc9d522d7..2a66c3325 100644
--- a/virtinst/devices/char.py
+++ b/virtinst/devices/char.py
@@ -29,16 +29,6 @@ class _DeviceChar(Device):
TYPE_SPICEPORT = "spiceport"
TYPE_NMDM = "nmdm"
- # We don't list the non-UI friendly types here
- _TYPES_FOR_ALL = [TYPE_PTY, TYPE_DEV, TYPE_FILE,
- TYPE_TCP, TYPE_UDP, TYPE_UNIX]
- _TYPES_FOR_CHANNEL = [TYPE_SPICEVMC, TYPE_SPICEPORT]
- TYPES = _TYPES_FOR_ALL
-
- MODE_CONNECT = "connect"
- MODE_BIND = "bind"
- MODES = [MODE_CONNECT, MODE_BIND]
-
CHANNEL_NAME_SPICE = "com.redhat.spice.0"
CHANNEL_NAME_QEMUGA = "org.qemu.guest_agent.0"
CHANNEL_NAME_LIBGUESTFS = "org.libguestfs.channel.0"
@@ -48,6 +38,16 @@ class _DeviceChar(Device):
CHANNEL_NAME_LIBGUESTFS,
CHANNEL_NAME_SPICE_WEBDAV]
+ @classmethod
+ def get_recommended_types(cls, _guest):
+ if cls.XML_NAME == "console":
+ return [cls.TYPE_PTY]
+
+ ret = [cls.TYPE_PTY, cls.TYPE_FILE, cls.TYPE_UNIX]
+ if cls.XML_NAME == "channel":
+ ret = [cls.TYPE_SPICEVMC, cls.TYPE_SPICEPORT] + ret
+ return ret
+
@staticmethod
def pretty_channel_name(val):
if val == _DeviceChar.CHANNEL_NAME_SPICE:
@@ -94,20 +94,6 @@ class _DeviceChar(Device):
return desc
- @staticmethod
- def pretty_mode(char_mode):
- """
- Return a human readable description of the passed char type
- """
- desc = ""
-
- if char_mode == _DeviceChar.MODE_CONNECT:
- desc = _("Client mode")
- elif char_mode == _DeviceChar.MODE_BIND:
- desc = _("Server mode")
-
- return desc
-
def supports_property(self, propname, ro=False):
"""
Whether the character dev type supports the passed property name
@@ -215,7 +201,7 @@ class _DeviceChar(Device):
def set_defaults(self, _guest):
if not self.source_mode and self.supports_property("source_mode"):
- self.source_mode = self.MODE_BIND
+ self.source_mode = "bind"
if not self.protocol and self.supports_property("protocol"):
self.protocol = "raw"
if not self.target_type and self.DEVICE_TYPE == "channel":
@@ -227,7 +213,6 @@ class _DeviceChar(Device):
class DeviceConsole(_DeviceChar):
XML_NAME = "console"
- TYPES = [_DeviceChar.TYPE_PTY]
class DeviceSerial(_DeviceChar):
@@ -240,5 +225,3 @@ class DeviceParallel(_DeviceChar):
class DeviceChannel(_DeviceChar):
XML_NAME = "channel"
- TYPES = (_DeviceChar._TYPES_FOR_CHANNEL +
- _DeviceChar._TYPES_FOR_ALL)