[virt-tools-list] [PATCH] virtinst: support to constrain the spicevmc usage to correct parameters
Cole Robinson
crobinso at redhat.com
Tue Apr 5 16:48:44 UTC 2011
On 04/04/2011 07:34 PM, Marc-André Lureau wrote:
> 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(-)
>
Pushed with some changes mentioned inline
> 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 ]
> +
Rather than dup the list, I did
_non_channel_types = char_types[:]
_non_channel_types.remove(CHAR_SPICEVMC)
> + 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],
> }
>
This broke test_cli, specifically --channel pty,target_type=virtio,name=
I reworked this function to provide the same end result
> 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)
>
This should have been self.has_target
Thanks,
Cole
More information about the virt-tools-list
mailing list