From: Michal Privoznik <[email protected]>

As it turns out, some users of the hyperv "host-model" mode might
want to override the hypervisor defaults. For instance disable a
feature that's on by default, or vice versa. Currently, this is
not possible because as soon as our XML parser sees the
"host-model" mode it exits early and skips parsing of individual
features (for "custom" mode). Well, do not return early and parse
the rest.

Signed-off-by: Michal Privoznik <[email protected]>
---
 docs/formatdomain.rst                                     | 3 +++
 src/conf/domain_conf.c                                    | 3 +--
 src/conf/schemas/domaincommon.rng                         | 8 ++++----
 tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml | 6 +++++-
 tests/qemuxmlconfdata/hyperv-host-model.xml               | 6 +++++-
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 87644ad42a..31eba779c1 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2197,6 +2197,9 @@ are:
       enlightenments are supported by hypervisor and expands them on domain
       startup into the live XML. In a sense, this is similar to ``host-model``
       CPU mode (See `CPU model and topology`_). :since:`Since 11.9.0`
+      It is also possible to set features, like in ``custom`` mode. These are
+      then left untouched and no expansion is done for them. :since:`Since
+      12.1.0`
 
    The ``mode`` attribute can be omitted and will default to ``custom``.
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e88dc62520..aee7de9669 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17220,8 +17220,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def,
 
     def->features[VIR_DOMAIN_FEATURE_HYPERV] = mode;
 
-    if (mode == VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH ||
-        mode == VIR_DOMAIN_HYPERV_MODE_HOST_MODEL)
+    if (mode == VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH)
         return 0;
 
     node = xmlFirstElementChild(node);
diff --git a/src/conf/schemas/domaincommon.rng 
b/src/conf/schemas/domaincommon.rng
index e659900687..c2b886dbdc 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -8080,13 +8080,13 @@
         <attribute name="mode">
           <value>passthrough</value>
         </attribute>
-        <attribute name="mode">
-          <value>host-model</value>
-        </attribute>
         <group>
           <optional>
             <attribute name="mode">
-              <value>custom</value>
+              <choice>
+                <value>custom</value>
+                <value>host-model</value>
+              </choice>
             </attribute>
           </optional>
           <interleave>
diff --git a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml 
b/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml
index 453a43b3c9..9535cee02a 100644
--- a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml
@@ -10,7 +10,11 @@
   </os>
   <features>
     <acpi/>
-    <hyperv mode='host-model'/>
+    <hyperv mode='host-model'>
+      <relaxed state='on'/>
+      <spinlocks state='on' retries='8192'/>
+      <xmm_input state='off'/>
+    </hyperv>
   </features>
   <cpu mode='custom' match='exact' check='none'>
     <model fallback='forbid'>qemu64</model>
diff --git a/tests/qemuxmlconfdata/hyperv-host-model.xml 
b/tests/qemuxmlconfdata/hyperv-host-model.xml
index fae00d86dd..473a41892d 100644
--- a/tests/qemuxmlconfdata/hyperv-host-model.xml
+++ b/tests/qemuxmlconfdata/hyperv-host-model.xml
@@ -10,7 +10,11 @@
   </os>
   <features>
     <acpi/>
-    <hyperv mode='host-model'/>
+    <hyperv mode='host-model'>
+      <relaxed state='on'/>
+      <spinlocks state='on' retries='8192'/>
+      <xmm_input state='off'/>
+    </hyperv>
   </features>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
-- 
2.52.0

Reply via email to