addhw: Add 'console' option for adding virtio consoles

This commit is contained in:
Cole Robinson 2013-10-05 11:28:41 -04:00
parent f9fcac27a0
commit 24137cdfe9
3 changed files with 81 additions and 30 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0 on Sat Sep 28 14:12:31 2013 -->
<!-- Generated with glade 3.16.0 on Sat Oct 5 11:25:05 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
@ -1190,7 +1190,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1205,7 +1205,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1218,7 +1218,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1269,7 +1269,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1320,7 +1320,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1336,7 +1336,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1352,7 +1352,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1368,7 +1368,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1384,7 +1384,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1400,7 +1400,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1446,7 +1446,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1457,6 +1457,35 @@
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="char-target-type-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">T_ype:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">char-target-type</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</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">1</property>

View File

@ -29,7 +29,7 @@ from gi.repository import Gdk
import virtinst
from virtinst import util
from virtinst import (VirtualChannelDevice, VirtualParallelDevice,
VirtualSerialDevice,
VirtualSerialDevice, VirtualConsoleDevice,
VirtualVideoDevice, VirtualWatchdog,
VirtualFilesystem, VirtualSmartCardDevice,
VirtualRedirDevice, VirtualTPMDevice)
@ -56,20 +56,6 @@ PAGE_USBREDIR = 12
PAGE_TPM = 13
PAGE_RNG = 14
char_widget_mappings = {
"source_path" : "char-path",
"source_mode" : "char-mode",
"source_host" : "char-host",
"bind_host" : "char-bind-host",
"protocol" : "char-use-telnet",
"target_name" : "char-target-name",
}
tpm_widget_mappings = {
"device_path" : "tpm-device-path",
}
class vmmAddHardware(vmmGObjectUI):
def __init__(self, vm, is_customize_dialog):
@ -267,6 +253,16 @@ class vmmAddHardware(vmmGObjectUI):
desc = VirtualSerialDevice.pretty_mode(t)
char_mode_model.append([t, desc + " (%s)" % t])
# Char target type
lst = self.widget("char-target-type")
model = Gtk.ListStore(str, str)
lst.set_model(model)
uihelpers.set_combo_text_column(lst, 1)
if self.conn.is_qemu():
model.append(["virtio", "virtio"])
else:
model.append([None, "default"])
# Watchdog widgets
combo = self.widget("watchdog-model")
uihelpers.build_watchdogmodel_combo(self.vm, combo)
@ -350,6 +346,8 @@ class vmmAddHardware(vmmGObjectUI):
self.vm.is_hvm(),
_("Not supported for this guest type."),
"parallel")
add_hw_option("Console", Gtk.STOCK_CONNECT, PAGE_CHAR,
True, None, "console")
add_hw_option("Channel", Gtk.STOCK_CONNECT, PAGE_CHAR,
self.vm.is_hvm(),
_("Not supported for this guest type."),
@ -449,6 +447,7 @@ class vmmAddHardware(vmmGObjectUI):
# Char parameters
self.widget("char-device-type").set_active(0)
self.widget("char-target-type").set_active(0)
self.widget("char-path").set_text("")
self.widget("char-host").set_text("127.0.0.1")
self.widget("char-port").set_value(4555)
@ -1033,6 +1032,8 @@ class vmmAddHardware(vmmGObjectUI):
return VirtualParallelDevice
elif label == "channel":
return VirtualChannelDevice
elif label == "console":
return VirtualConsoleDevice
return VirtualSerialDevice
def dev_to_title(self, page):
@ -1081,6 +1082,10 @@ class vmmAddHardware(vmmGObjectUI):
if idx < 0:
return
tpm_widget_mappings = {
"device_path" : "tpm-device-path",
}
devtype = src.get_model()[src.get_active()][0]
conn = self.conn.get_backend()
@ -1097,6 +1102,16 @@ class vmmAddHardware(vmmGObjectUI):
if idx < 0:
return
char_widget_mappings = {
"source_path" : "char-path",
"source_mode" : "char-mode",
"source_host" : "char-host",
"bind_host" : "char-bind-host",
"protocol" : "char-use-telnet",
"target_name" : "char-target-name",
"target_type" : "char-target-type",
}
char_class = self.get_char_type()
devtype = src.get_model()[src.get_active()][0]
conn = self.conn.get_backend()
@ -1504,6 +1519,7 @@ class vmmAddHardware(vmmGObjectUI):
charclass = self.get_char_type()
modebox = self.widget("char-mode")
devbox = self.widget("char-device-type")
typebox = self.widget("char-target-type")
devtype = devbox.get_model()[devbox.get_active()][0]
conn = self.conn.get_backend()
@ -1517,6 +1533,7 @@ class vmmAddHardware(vmmGObjectUI):
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_text()
target_type = typebox.get_model()[typebox.get_active()][0]
if self.widget("char-use-telnet").get_active():
protocol = VirtualSerialDevice.PROTOCOL_TELNET
@ -1532,6 +1549,7 @@ class vmmAddHardware(vmmGObjectUI):
"bind_host": bind_host,
"protocol": protocol,
"target_name": target_name,
"target_type": target_type,
}
try:

View File

@ -110,7 +110,6 @@ class _VirtualCharDevice(VirtualDevice):
return desc
def supports_property(self, propname, ro=False):
"""
Whether the character dev type supports the passed property name
@ -124,20 +123,24 @@ class _VirtualCharDevice(VirtualDevice):
"protocol" : [self.TYPE_TCP],
"bind_host" : [self.TYPE_UDP],
"bind_port" : [self.TYPE_UDP],
}
}
if ro:
users["source_path"] += [self.TYPE_PTY]
channel_users = {
"target_name" : [self.CHANNEL_TARGET_VIRTIO],
}
}
console_props = ["target_type"]
if users.get(propname):
return self.type in users[propname]
if channel_users.get(propname):
return (self.virtual_device_type == "channel" and
self.target_type in channel_users[propname])
if propname in console_props:
return self.virtual_device_type == "console"
return hasattr(self, propname)
@ -256,6 +259,7 @@ class _VirtualCharDevice(VirtualDevice):
class VirtualConsoleDevice(_VirtualCharDevice):
virtual_device_type = "console"
TYPES = [_VirtualCharDevice.TYPE_PTY]
class VirtualSerialDevice(_VirtualCharDevice):