Subject: guest: Query availability of spicevmc channels in domcaps From: Lin Ma lma@suse.com Thu Nov 10 15:57:24 2022 +0800 Date: Wed Dec 14 12:44:54 2022 -0500: Git: 180154d752a33f6b26643184e6aa19dcb110e0eb Signed-off-by: Lin Ma diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py index 91f51f9f..db08bf65 100644 --- a/virtinst/domcapabilities.py +++ b/virtinst/domcapabilities.py @@ -114,6 +114,7 @@ class _Devices(_CapsBlock): tpm = XMLChildProperty(_make_capsblock("tpm"), is_single=True) filesystem = XMLChildProperty(_make_capsblock("filesystem"), is_single=True) redirdev = XMLChildProperty(_make_capsblock("redirdev"), is_single=True) + channel = XMLChildProperty(_make_capsblock("channel"), is_single=True) class _Features(_CapsBlock): @@ -449,6 +450,18 @@ class DomainCapabilities(XMLBuilder): return self.devices.graphics.get_enum("type").has_value("spice") + def supports_channel_spicevmc(self): + """ + Return False if libvirt explicitly advertises no support for + spice channel + """ + if self.devices.channel.supported is None: + # Follow the original behavior in case of talking to older + # libvirt. + return True + + return self.devices.channel.get_enum("type").has_value("spicevmc") + def supports_redirdev_usb(self): """ Return False if libvirt explicitly advertises no support for diff --git a/virtinst/guest.py b/virtinst/guest.py index 1d1e2ee9..c2244ae3 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -1127,6 +1127,8 @@ class Guest(XMLBuilder): self.add_device(ctrl) def _add_spice_channels(self): + if not self.lookup_domcaps().supports_channel_spicevmc(): + return if self.skip_default_channel: return for chn in self.devices.channel: