[virt-tools-list] [virt-manager] [PATCH 1/2] guest: Query availability of usb redirdevs in domcaps

Lin Ma lma at suse.com
Fri Nov 4 04:11:44 UTC 2022


Signed-off-by: Lin Ma <lma at suse.com>
---
 virtinst/domcapabilities.py | 7 +++++++
 virtinst/guest.py           | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py
index d22ce6a2..cb5fddbb 100644
--- a/virtinst/domcapabilities.py
+++ b/virtinst/domcapabilities.py
@@ -113,6 +113,7 @@ class _Devices(_CapsBlock):
     graphics = XMLChildProperty(_make_capsblock("graphics"), is_single=True)
     tpm = XMLChildProperty(_make_capsblock("tpm"), is_single=True)
     filesystem = XMLChildProperty(_make_capsblock("filesystem"), is_single=True)
+    redirdev = XMLChildProperty(_make_capsblock("redirdev"), is_single=True)
 
 
 class _Features(_CapsBlock):
@@ -448,6 +449,12 @@ class DomainCapabilities(XMLBuilder):
 
         return self.devices.graphics.get_enum("type").has_value("spice")
 
+    def supports_redirdev_usb(self):
+        """
+        Return True if libvirt advertises support for USB redirect
+        """
+        return self.devices.redirdev.get_enum("bus").has_value("usb")
+
     def supports_filesystem_virtiofs(self):
         """
         Return True if libvirt advertises support for virtiofs
diff --git a/virtinst/guest.py b/virtinst/guest.py
index e6636022..1d1e2ee9 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -1155,6 +1155,8 @@ class Guest(XMLBuilder):
         self.add_device(dev)
 
     def _add_spice_usbredir(self):
+        if not self.lookup_domcaps().supports_redirdev_usb():
+            return
         if self.skip_default_usbredir:
             return
         if self.devices.redirdev:
-- 
2.37.3



More information about the virt-tools-list mailing list