[PATCH v2 3/7] domain_capabilities: Expose Hyper-V Enlightenments

Michal Privoznik posted 7 patches 3 years, 1 month ago
[PATCH v2 3/7] domain_capabilities: Expose Hyper-V Enlightenments
Posted by Michal Privoznik 3 years, 1 month ago
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 docs/formatdomaincaps.rst                      | 15 +++++++++++++++
 src/conf/domain_capabilities.c                 | 18 ++++++++++++++++++
 src/conf/domain_capabilities.h                 |  8 ++++++++
 src/conf/schemas/domaincaps.rng                | 10 ++++++++++
 tests/domaincapsdata/empty.xml                 |  1 +
 tests/domaincapsdata/libxl-xenfv.xml           |  1 +
 tests/domaincapsdata/libxl-xenpv.xml           |  1 +
 tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_4.2.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_4.2.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_4.2.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_4.2.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_4.2.0.s390x.xml      |  1 +
 tests/domaincapsdata/qemu_4.2.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_5.0.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_5.0.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_5.0.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_5.0.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_5.1.0-tcg.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_5.1.0.sparc.xml      |  1 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_5.2.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_5.2.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_5.2.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_5.2.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_5.2.0.s390x.xml      |  1 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_6.0.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_6.0.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_6.0.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_6.0.0.s390x.xml      |  1 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_6.2.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_6.2.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_6.2.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_6.2.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_7.0.0-tcg.x86_64.xml |  1 +
 .../domaincapsdata/qemu_7.0.0-virt.aarch64.xml |  1 +
 tests/domaincapsdata/qemu_7.0.0.aarch64.xml    |  1 +
 tests/domaincapsdata/qemu_7.0.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_7.1.0-tcg.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_7.1.0.ppc64.xml      |  1 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_7.2.0-tcg.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml     |  1 +
 tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml |  1 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml     |  1 +
 62 files changed, 109 insertions(+)

diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst
index 532fea0f60..dc227e9d02 100644
--- a/docs/formatdomaincaps.rst
+++ b/docs/formatdomaincaps.rst
@@ -624,6 +624,12 @@ capabilities. All features occur as children of the main ``features`` element.
            <section node='1' size='262144' unit='KiB'/>
          </sections>
        </sgx>
+       <hyperv supported='yes'>
+         <enum name='features'>
+           <value>relaxed</value>
+           <value>vapic</value>
+         </enum>
+       </hyperv>
      </features>
    </domainCapabilities>
 
@@ -733,3 +739,12 @@ document store. In order to use SGX with libvirt have a look at `SGX in domain X
 
 ``sections``
    The sections of the SGX enclave page cache (called EPC).
+
+
+Hyper-V Enlightenments
+^^^^^^^^^^^^^^^^^^^^^^
+
+Report which features improving behavior of guests running Microsoft Windows
+are supported. The ``features`` enum corresponds to the ``<hyperv/>`` element
+(well, its children) as documented in `Hypervisor features
+<formatdomain.html#hypervisor-features>`__
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 01714e2270..82432b60a7 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -100,6 +100,7 @@ virDomainCapsDispose(void *obj)
     virCPUDefFree(caps->cpu.hostModel);
     virSEVCapabilitiesFree(caps->sev);
     virSGXCapabilitiesFree(caps->sgx);
+    g_free(caps->hyperv);
 
     values = &caps->os.loader.values;
     for (i = 0; i < values->nvalues; i++)
@@ -678,6 +679,22 @@ virDomainCapsFeatureSGXFormat(virBuffer *buf,
     virBufferAddLit(buf, "</sgx>\n");
 }
 
+static void
+virDomainCapsFeatureHypervFormat(virBuffer *buf,
+                                 const virDomainCapsFeatureHyperv *hyperv)
+{
+    if (!hyperv) {
+        virBufferAddLit(buf, "<hyperv supported='no'/>\n");
+        return;
+    }
+
+    FORMAT_PROLOGUE(hyperv);
+
+    ENUM_PROCESS(hyperv, features, virDomainHypervTypeToString);
+
+    FORMAT_EPILOGUE(hyperv);
+}
+
 static void
 virDomainCapsFormatFeatures(const virDomainCaps *caps,
                             virBuffer *buf)
@@ -698,6 +715,7 @@ virDomainCapsFormatFeatures(const virDomainCaps *caps,
 
     virDomainCapsFeatureSEVFormat(&childBuf, caps->sev);
     virDomainCapsFeatureSGXFormat(&childBuf, caps->sgx);
+    virDomainCapsFeatureHypervFormat(&childBuf, caps->hyperv);
 
     virXMLFormatElement(buf, "features", NULL, &childBuf);
 }
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 1d504a3506..770856bf53 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -158,6 +158,13 @@ struct _virDomainCapsFeatureGIC {
     virDomainCapsEnum version; /* Info about virGICVersion */
 };
 
+STATIC_ASSERT_ENUM(VIR_DOMAIN_HYPERV_LAST);
+typedef struct _virDomainCapsFeatureHyperv virDomainCapsFeatureHyperv;
+struct _virDomainCapsFeatureHyperv {
+    virTristateBool supported;
+    virDomainCapsEnum features; /* Info about supported virDomainHyperv features */
+};
+
 typedef enum {
     VIR_DOMCAPS_CPU_USABLE_UNKNOWN,
     VIR_DOMCAPS_CPU_USABLE_YES,
@@ -263,6 +270,7 @@ struct _virDomainCaps {
     virDomainCapsFeatureGIC gic;
     virSEVCapability *sev;
     virSGXCapability *sgx;
+    virDomainCapsFeatureHyperv *hyperv;
     /* add new domain features here */
 
     virTristateBool features[VIR_DOMAIN_CAPS_FEATURE_LAST];
diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng
index b6408bca88..4b96e89dfa 100644
--- a/src/conf/schemas/domaincaps.rng
+++ b/src/conf/schemas/domaincaps.rng
@@ -296,6 +296,9 @@
       <optional>
         <ref name="sgx"/>
       </optional>
+      <optional>
+        <ref name="hyperv"/>
+      </optional>
     </element>
   </define>
 
@@ -396,6 +399,13 @@
     </element>
   </define>
 
+  <define name="hyperv">
+    <element name="hyperv">
+      <ref name="supported"/>
+      <ref name="enum"/>
+    </element>
+  </define>
+
   <define name="value">
     <zeroOrMore>
       <element name="value">
diff --git a/tests/domaincapsdata/empty.xml b/tests/domaincapsdata/empty.xml
index 97752ca04a..542522ed29 100644
--- a/tests/domaincapsdata/empty.xml
+++ b/tests/domaincapsdata/empty.xml
@@ -14,5 +14,6 @@
   <features>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/libxl-xenfv.xml b/tests/domaincapsdata/libxl-xenfv.xml
index c71d759517..d7e3424830 100644
--- a/tests/domaincapsdata/libxl-xenfv.xml
+++ b/tests/domaincapsdata/libxl-xenfv.xml
@@ -77,5 +77,6 @@
     <genid supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/libxl-xenpv.xml b/tests/domaincapsdata/libxl-xenpv.xml
index 8ae2370b7e..a3269f4909 100644
--- a/tests/domaincapsdata/libxl-xenpv.xml
+++ b/tests/domaincapsdata/libxl-xenpv.xml
@@ -67,5 +67,6 @@
     <genid supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
index d0bf0bdc7b..49550e799f 100644
--- a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
@@ -238,5 +238,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0-tcg.x86_64.xml
index 6a3818fb4e..a5a1eb71fb 100644
--- a/tests/domaincapsdata/qemu_4.2.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0-tcg.x86_64.xml
@@ -253,5 +253,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_4.2.0-virt.aarch64.xml
index 02aca3e448..e001128bf5 100644
--- a/tests/domaincapsdata/qemu_4.2.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0-virt.aarch64.xml
@@ -185,5 +185,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0.aarch64.xml b/tests/domaincapsdata/qemu_4.2.0.aarch64.xml
index 676e1b0739..5aa9520fab 100644
--- a/tests/domaincapsdata/qemu_4.2.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0.aarch64.xml
@@ -179,5 +179,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0.ppc64.xml b/tests/domaincapsdata/qemu_4.2.0.ppc64.xml
index bcc415d7de..2017a0cf44 100644
--- a/tests/domaincapsdata/qemu_4.2.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0.ppc64.xml
@@ -152,5 +152,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0.s390x.xml b/tests/domaincapsdata/qemu_4.2.0.s390x.xml
index 4f176e2d37..e9c082244b 100644
--- a/tests/domaincapsdata/qemu_4.2.0.s390x.xml
+++ b/tests/domaincapsdata/qemu_4.2.0.s390x.xml
@@ -259,5 +259,6 @@
     <s390-pv supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_4.2.0.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0.x86_64.xml
index 36a4081764..c67217d4ac 100644
--- a/tests/domaincapsdata/qemu_4.2.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0.x86_64.xml
@@ -238,5 +238,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml
index 05884cdb86..bf8c6a5a54 100644
--- a/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml
@@ -240,5 +240,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_5.0.0-tcg.x86_64.xml
index c53b84c140..ebab6a15f3 100644
--- a/tests/domaincapsdata/qemu_5.0.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0-tcg.x86_64.xml
@@ -255,5 +255,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_5.0.0-virt.aarch64.xml
index e74a3d9f5f..071187cfaf 100644
--- a/tests/domaincapsdata/qemu_5.0.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0-virt.aarch64.xml
@@ -198,5 +198,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0.aarch64.xml b/tests/domaincapsdata/qemu_5.0.0.aarch64.xml
index 605575c793..05ba8f5a83 100644
--- a/tests/domaincapsdata/qemu_5.0.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0.aarch64.xml
@@ -192,5 +192,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0.ppc64.xml b/tests/domaincapsdata/qemu_5.0.0.ppc64.xml
index a5b718618b..35d6733d23 100644
--- a/tests/domaincapsdata/qemu_5.0.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0.ppc64.xml
@@ -159,5 +159,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.0.0.x86_64.xml b/tests/domaincapsdata/qemu_5.0.0.x86_64.xml
index fd1f42b555..c3ac6668af 100644
--- a/tests/domaincapsdata/qemu_5.0.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.0.0.x86_64.xml
@@ -240,5 +240,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml
index a04c3e7130..f8eeb3c097 100644
--- a/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml
@@ -241,5 +241,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.1.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_5.1.0-tcg.x86_64.xml
index a7b2ff8d7d..5a6aee6bda 100644
--- a/tests/domaincapsdata/qemu_5.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.1.0-tcg.x86_64.xml
@@ -255,5 +255,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.1.0.sparc.xml b/tests/domaincapsdata/qemu_5.1.0.sparc.xml
index cde31462bc..f3ad4d43cb 100644
--- a/tests/domaincapsdata/qemu_5.1.0.sparc.xml
+++ b/tests/domaincapsdata/qemu_5.1.0.sparc.xml
@@ -126,5 +126,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.1.0.x86_64.xml b/tests/domaincapsdata/qemu_5.1.0.x86_64.xml
index 45b7dcf6e4..6cf741e7ea 100644
--- a/tests/domaincapsdata/qemu_5.1.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.1.0.x86_64.xml
@@ -241,5 +241,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml
index 61cfa7d449..bf642e4956 100644
--- a/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml
@@ -241,5 +241,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_5.2.0-tcg.x86_64.xml
index caced52187..8d1702b5e3 100644
--- a/tests/domaincapsdata/qemu_5.2.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0-tcg.x86_64.xml
@@ -255,5 +255,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_5.2.0-virt.aarch64.xml
index f19ad32693..43febfb61a 100644
--- a/tests/domaincapsdata/qemu_5.2.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0-virt.aarch64.xml
@@ -198,5 +198,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0.aarch64.xml b/tests/domaincapsdata/qemu_5.2.0.aarch64.xml
index 605575c793..05ba8f5a83 100644
--- a/tests/domaincapsdata/qemu_5.2.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0.aarch64.xml
@@ -192,5 +192,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0.ppc64.xml b/tests/domaincapsdata/qemu_5.2.0.ppc64.xml
index 8ae7487c1e..87dd5cd28e 100644
--- a/tests/domaincapsdata/qemu_5.2.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0.ppc64.xml
@@ -159,5 +159,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0.s390x.xml b/tests/domaincapsdata/qemu_5.2.0.s390x.xml
index 760f514d7b..7e7f58acd6 100644
--- a/tests/domaincapsdata/qemu_5.2.0.s390x.xml
+++ b/tests/domaincapsdata/qemu_5.2.0.s390x.xml
@@ -261,5 +261,6 @@
     <s390-pv supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_5.2.0.x86_64.xml b/tests/domaincapsdata/qemu_5.2.0.x86_64.xml
index 67f8b0fd83..61969bcffd 100644
--- a/tests/domaincapsdata/qemu_5.2.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_5.2.0.x86_64.xml
@@ -241,5 +241,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml
index 08585e6cb0..c9c5506536 100644
--- a/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml
@@ -248,5 +248,6 @@
       <maxESGuests>450</maxESGuests>
     </sev>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_6.0.0-tcg.x86_64.xml
index 7536a42ad5..eb42eec406 100644
--- a/tests/domaincapsdata/qemu_6.0.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.0.0-tcg.x86_64.xml
@@ -263,5 +263,6 @@
       <maxESGuests>450</maxESGuests>
     </sev>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_6.0.0-virt.aarch64.xml
index 1235dd0ab7..def36192f5 100644
--- a/tests/domaincapsdata/qemu_6.0.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_6.0.0-virt.aarch64.xml
@@ -200,5 +200,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0.aarch64.xml b/tests/domaincapsdata/qemu_6.0.0.aarch64.xml
index 461e34f1d6..7177d16fa4 100644
--- a/tests/domaincapsdata/qemu_6.0.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_6.0.0.aarch64.xml
@@ -194,5 +194,6 @@
     <backup supported='no'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0.s390x.xml b/tests/domaincapsdata/qemu_6.0.0.s390x.xml
index b1968668db..b977b494d4 100644
--- a/tests/domaincapsdata/qemu_6.0.0.s390x.xml
+++ b/tests/domaincapsdata/qemu_6.0.0.s390x.xml
@@ -262,5 +262,6 @@
     <s390-pv supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.0.0.x86_64.xml b/tests/domaincapsdata/qemu_6.0.0.x86_64.xml
index 632f7c21d1..a5333e5293 100644
--- a/tests/domaincapsdata/qemu_6.0.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.0.0.x86_64.xml
@@ -248,5 +248,6 @@
       <maxESGuests>450</maxESGuests>
     </sev>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
index 35d1014626..b0480cf625 100644
--- a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
index 9d56f2dda7..5e89b5d17b 100644
--- a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
@@ -258,5 +258,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
index 591ca12d72..4a3cdbe758 100644
--- a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
index 7558e78423..064d0014c6 100644
--- a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_6.2.0-tcg.x86_64.xml
index c667b944da..194712f95c 100644
--- a/tests/domaincapsdata/qemu_6.2.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0-tcg.x86_64.xml
@@ -260,5 +260,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_6.2.0-virt.aarch64.xml
index 2c9ba98a0a..1da26e9c36 100644
--- a/tests/domaincapsdata/qemu_6.2.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0-virt.aarch64.xml
@@ -207,5 +207,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0.aarch64.xml b/tests/domaincapsdata/qemu_6.2.0.aarch64.xml
index 9b546f59bc..2878c9d42e 100644
--- a/tests/domaincapsdata/qemu_6.2.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0.aarch64.xml
@@ -201,5 +201,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0.ppc64.xml b/tests/domaincapsdata/qemu_6.2.0.ppc64.xml
index fd7c9d8d5a..a2d6428c2f 100644
--- a/tests/domaincapsdata/qemu_6.2.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0.ppc64.xml
@@ -158,5 +158,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_6.2.0.x86_64.xml b/tests/domaincapsdata/qemu_6.2.0.x86_64.xml
index a20d3722fd..1da12ba5f1 100644
--- a/tests/domaincapsdata/qemu_6.2.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml
index ac9d384bb3..7e24baf97f 100644
--- a/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml
@@ -254,5 +254,6 @@
         <section node='1' size='262144' unit='KiB'/>
       </sections>
     </sgx>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_7.0.0-tcg.x86_64.xml
index 2419875474..1fe6b606fa 100644
--- a/tests/domaincapsdata/qemu_7.0.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0-tcg.x86_64.xml
@@ -270,5 +270,6 @@
         <section node='1' size='262144' unit='KiB'/>
       </sections>
     </sgx>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0-virt.aarch64.xml b/tests/domaincapsdata/qemu_7.0.0-virt.aarch64.xml
index f4eb8a728b..e3f1b2d2c0 100644
--- a/tests/domaincapsdata/qemu_7.0.0-virt.aarch64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0-virt.aarch64.xml
@@ -206,5 +206,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0.aarch64.xml b/tests/domaincapsdata/qemu_7.0.0.aarch64.xml
index 053bec369b..6cae496a8e 100644
--- a/tests/domaincapsdata/qemu_7.0.0.aarch64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0.aarch64.xml
@@ -200,5 +200,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0.ppc64.xml b/tests/domaincapsdata/qemu_7.0.0.ppc64.xml
index 9c09174d77..f957e8167d 100644
--- a/tests/domaincapsdata/qemu_7.0.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0.ppc64.xml
@@ -163,5 +163,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.0.0.x86_64.xml b/tests/domaincapsdata/qemu_7.0.0.x86_64.xml
index 886e14ea49..f8b9526831 100644
--- a/tests/domaincapsdata/qemu_7.0.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.0.0.x86_64.xml
@@ -254,5 +254,6 @@
         <section node='1' size='262144' unit='KiB'/>
       </sections>
     </sgx>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml
index 6b5e8a6820..77e015659d 100644
--- a/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.1.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_7.1.0-tcg.x86_64.xml
index e44804c21c..56ac94c8d7 100644
--- a/tests/domaincapsdata/qemu_7.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.1.0-tcg.x86_64.xml
@@ -259,5 +259,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.1.0.ppc64.xml b/tests/domaincapsdata/qemu_7.1.0.ppc64.xml
index 15cf6a9cf8..3ea6fa0943 100644
--- a/tests/domaincapsdata/qemu_7.1.0.ppc64.xml
+++ b/tests/domaincapsdata/qemu_7.1.0.ppc64.xml
@@ -156,5 +156,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.1.0.x86_64.xml b/tests/domaincapsdata/qemu_7.1.0.x86_64.xml
index d4069dd6f0..dc5f9d7148 100644
--- a/tests/domaincapsdata/qemu_7.1.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.1.0.x86_64.xml
@@ -244,5 +244,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml
index e6997ccbc6..d58fafde51 100644
--- a/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml
@@ -249,5 +249,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.2.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_7.2.0-tcg.x86_64.xml
index b9bf0b6a04..e5428beea1 100644
--- a/tests/domaincapsdata/qemu_7.2.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.2.0-tcg.x86_64.xml
@@ -248,5 +248,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_7.2.0.x86_64.xml b/tests/domaincapsdata/qemu_7.2.0.x86_64.xml
index 67ecdc0b12..fa1cb45d65 100644
--- a/tests/domaincapsdata/qemu_7.2.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_7.2.0.x86_64.xml
@@ -249,5 +249,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml
index efc67b2ef9..eb18b5c696 100644
--- a/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml
@@ -249,5 +249,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml
index d9b092e6fd..471a92693f 100644
--- a/tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml
@@ -248,5 +248,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
diff --git a/tests/domaincapsdata/qemu_8.0.0.x86_64.xml b/tests/domaincapsdata/qemu_8.0.0.x86_64.xml
index 2b17a409bd..436ca212a8 100644
--- a/tests/domaincapsdata/qemu_8.0.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.0.0.x86_64.xml
@@ -249,5 +249,6 @@
     <backup supported='yes'/>
     <sev supported='no'/>
     <sgx supported='no'/>
+    <hyperv supported='no'/>
   </features>
 </domainCapabilities>
-- 
2.38.2
Re: [PATCH v2 3/7] domain_capabilities: Expose Hyper-V Enlightenments
Posted by Peter Krempa 3 years, 1 month ago
On Thu, Jan 05, 2023 at 09:34:57 +0100, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---

[....]

> diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
> index 01714e2270..82432b60a7 100644
> --- a/src/conf/domain_capabilities.c
> +++ b/src/conf/domain_capabilities.c

[...]

> @@ -678,6 +679,22 @@ virDomainCapsFeatureSGXFormat(virBuffer *buf,
>      virBufferAddLit(buf, "</sgx>\n");
>  }
>  
> +static void
> +virDomainCapsFeatureHypervFormat(virBuffer *buf,
> +                                 const virDomainCapsFeatureHyperv *hyperv)
> +{
> +    if (!hyperv) {
> +        virBufferAddLit(buf, "<hyperv supported='no'/>\n");
> +        return;
> +    }

Since the hyperv features are properly expanded only starting with
qemu-6.1, but I don't see a way of probing that given qemu does not
support it (hv-passthrough feature is actually supported in qemu-4.2,
but supposedly does nothing when expanding it) this would wrongly report
that hyperv enlightenments are not supported with given qemu which is
not true.

Thus this should most likely completely avoid the 'hyperv' element in
such case as we can't report reliable data and if this is run on x86/arm
then 'no' certainly is a wrong answer as some of the hyperv
enlightenments are supported for a very long time.

'no' is the right answer on other platforms though, but I don't think
that it matters too much.

The same then later comes when qemu doesn't report any of the features,
because we know that on x86 with supported qemu versions that is simply
not true.

> +
> +    FORMAT_PROLOGUE(hyperv);
> +
> +    ENUM_PROCESS(hyperv, features, virDomainHypervTypeToString);
> +

With appropriate changes:

Reviewed-by: Peter Krempa <pkrempa@redhat.com>