mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
addhardware: Drop tcp/udp/dev char support
I know openstack uses tcp consoles but for end users I've never really heard about it. RHEL compiles out udp as well. I'm fine telling users to go to the cli and use virt-xml for this use case. Use this opportunity to drop a lot of code that only simplified the case when there are tons of char options we need to consider
This commit is contained in:
parent
954d2687d0
commit
b3865d7b0d
@ -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)
|
||||
|
||||
|
@ -845,127 +845,6 @@
|
||||
<property name="top_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="char-use-telnet">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="char-mode">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="char-host">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-port-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">_Port:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-port</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="char-port">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment3</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox10">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="char-bind-host">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-bind-port-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Po_rt:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-bind-port</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="char-bind-port">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment2</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-path-label">
|
||||
<property name="visible">True</property>
|
||||
@ -980,62 +859,6 @@
|
||||
<property name="top_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-mode-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">_Mode:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-mode</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-host-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">H_ost:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-host</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-bind-host-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">_Bind Host:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-mode</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-use-telnet-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Use Te_lnet:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">char-use-telnet</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
@ -1076,17 +899,6 @@
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="char-target-type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="char-target-name-label">
|
||||
<property name="visible">True</property>
|
||||
@ -1171,6 +983,23 @@
|
||||
<property name="top_attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="char-target-type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry">
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="char-table-atkobject">
|
||||
<property name="AtkObject::accessible-name">char-tab</property>
|
||||
|
@ -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"))
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user