[virt-tools-list] [PATCH] virtinst: support to constrain the spicevmc usage to correct parameters
Marc-André Lureau
marcandre.lureau at redhat.com
Mon Apr 4 23:34:13 UTC 2011
This patch is related to another proposed patch series for
virt-manager to allow adding and removing Spice channels easily.
---
virtinst/VirtualCharDevice.py | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/virtinst/VirtualCharDevice.py b/virtinst/VirtualCharDevice.py
index f29081b..cdf2cc4 100644
--- a/virtinst/VirtualCharDevice.py
+++ b/virtinst/VirtualCharDevice.py
@@ -50,6 +50,16 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
CHAR_PIPE, CHAR_NULL, CHAR_TCP, CHAR_UDP, CHAR_UNIX,
CHAR_SPICEVMC ]
+ _char_types = [ CHAR_PTY, CHAR_DEV, CHAR_STDIO, CHAR_FILE, CHAR_VC,
+ CHAR_PIPE, CHAR_NULL, CHAR_TCP, CHAR_UDP, CHAR_UNIX ]
+
+ char_types_for_dev_type = {
+ DEV_SERIAL: _char_types,
+ DEV_PARALLEL: _char_types,
+ DEV_CONSOLE: _char_types,
+ DEV_CHANNEL: [ CHAR_SPICEVMC ]
+ }
+
CHAR_MODE_CONNECT = "connect"
CHAR_MODE_BIND = "bind"
char_modes = [ CHAR_MODE_CONNECT, CHAR_MODE_BIND ]
@@ -71,6 +81,8 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
CHAR_CONSOLE_TARGET_XEN = "xen"
CHAR_CONSOLE_TARGET_VIRTIO = "virtio"
+ has_target = False
+
def get_char_type_desc(char_type):
"""
Return a human readable description of the passed char type
@@ -211,6 +223,7 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
"protocol" : [self.CHAR_TCP],
"bind_host" : [self.CHAR_UDP],
"bind_port" : [self.CHAR_UDP],
+ "target_name" : [self.CHAR_SPICEVMC],
}
if users.get(propname):
@@ -330,7 +343,7 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
def get_target_name(self):
return self._target_name
target_name = _xml_property(get_target_name, set_target_name,
- doc=_("Sysfs Name of virtio port in the guest"),
+ doc=_("Sysfs name of virtio port in the guest"),
xpath="./target/@name")
def get_address_type(self):
@@ -411,7 +424,8 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
char_xml = self._char_xml()
target_xml = self._get_target_xml()
has_target = (self._dev_type == self.DEV_CHANNEL or
- self._dev_type == self.DEV_CONSOLE)
+ self._dev_type == self.DEV_CONSOLE or
+ self._char_type.has_target)
if target_xml and not has_target:
raise RuntimeError(
@@ -575,8 +589,9 @@ class VirtualCharSpicevmcDevice(VirtualCharDevice):
_char_type = VirtualCharDevice.CHAR_SPICEVMC
_char_xml = VirtualCharDevice._char_empty_xml
target_types = [ VirtualCharDevice.CHAR_CHANNEL_TARGET_VIRTIO ]
+ has_target = True
- def __init__(self, conn, dev_type,
+ def __init__(self, conn, dev_type=VirtualCharDevice.DEV_CHANNEL,
parsexml=None, parsexmlnode=None, caps=None):
VirtualCharDevice.__init__(self, conn, dev_type,
parsexml, parsexmlnode, caps)
--
1.7.4
More information about the virt-tools-list
mailing list