File virt-pass-emulator-when-getting-domain-capabilities-.patch of Package salt

From ddcf5ae80be638ade7634990194c48c5c703d538 Mon Sep 17 00:00:00 2001
From: Cedric Bosdonnat <cedric.bosdonnat@free.fr>
Date: Tue, 6 Jul 2021 08:47:25 +0200
Subject: [PATCH] virt: pass emulator when getting domain capabilities
 from libvirt (#394)

On aarch64, for some emulated architectures like armv6l libvirt needs to
have the emulator path to properly return the domain capabilities.

Passing it will avoid virt.all_capabilities to fail on such
architectures.
---
 changelog/60491.fixed           |  1 +
 salt/modules/virt.py            | 10 +++++++---
 tests/unit/modules/test_virt.py |  4 ++++
 3 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 changelog/60491.fixed

diff --git a/changelog/60491.fixed b/changelog/60491.fixed
new file mode 100644
index 0000000000..256d29b5fb
--- /dev/null
+++ b/changelog/60491.fixed
@@ -0,0 +1 @@
+Pass emulator path to get guest capabilities from libvirt
diff --git a/salt/modules/virt.py b/salt/modules/virt.py
index 2f2aa63957..12b39d76db 100644
--- a/salt/modules/virt.py
+++ b/salt/modules/virt.py
@@ -6770,7 +6770,11 @@ def all_capabilities(**kwargs):
         host_caps = ElementTree.fromstring(conn.getCapabilities())
         domains = [
             [
-                (guest.get("arch", {}).get("name", None), key)
+                (
+                    guest.get("arch", {}).get("name", None),
+                    key,
+                    guest.get("arch", {}).get("emulator", None),
+                )
                 for key in guest.get("arch", {}).get("domains", {}).keys()
             ]
             for guest in [
@@ -6788,10 +6792,10 @@ def all_capabilities(**kwargs):
             "domains": [
                 _parse_domain_caps(
                     ElementTree.fromstring(
-                        conn.getDomainCapabilities(None, arch, None, domain)
+                        conn.getDomainCapabilities(emulator, arch, None, domain)
                     )
                 )
-                for (arch, domain) in flattened
+                for (arch, domain, emulator) in flattened
             ],
         }
     finally:
diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py
index 5c7e1e1cc4..c6a76af10f 100644
--- a/tests/unit/modules/test_virt.py
+++ b/tests/unit/modules/test_virt.py
@@ -5057,6 +5057,10 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
             {"qemu", "kvm"}, {domainCaps["domain"] for domainCaps in caps["domains"]},
         )
 
+        self.mock_conn.getDomainCapabilities.assert_called_with(
+            "/usr/bin/qemu-system-x86_64", "x86_64", None, "kvm"
+        )
+
     def test_network_tag(self):
         """
         Test virt._get_net_xml() with VLAN tag
-- 
2.32.0


openSUSE Build Service is sponsored by