]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Parse hyperv features even for host-model
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Feb 2026 09:16:28 +0000 (10:16 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Feb 2026 08:08:45 +0000 (09:08 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/schemas/domaincommon.rng
tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml
tests/qemuxmlconfdata/hyperv-host-model.xml

index d1352a8fb192283845f3d1373da2a86993746342..de0de51fe5e4899b080f19b4f4e272b15276c36b 100644 (file)
@@ -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``.
 
index ffdd455a0d7dd488ad47b71c6853ae01d57cde6b..bd27575d30872f670296da742642e620f5be2e69 100644 (file)
@@ -17262,8 +17262,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);
index bf37c5332c7f35159a2e644b5c2c7bbfac2c2053..8fe1346b05878cd30d23c71a4ff40a6f1cdad02a 100644 (file)
         <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>
index 453a43b3c993b5d9cf75dc2acc21858b864db4cb..9535cee02ad89de0491c497bac83b4cbc6343f2c 100644 (file)
   </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>
index fae00d86dd3bc5b72077e1ebcff5eed7851aea36..473a41892d917c3a32ccbbeb67e5ffee9224554c 100644 (file)
   </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>