]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix smm=off handling
authorAndrea Bolognani <abologna@redhat.com>
Fri, 13 May 2022 14:09:30 +0000 (16:09 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 16 May 2022 12:29:11 +0000 (14:29 +0200)
We have to always store the state of the feature in the
virDomainDef struct, otherwise

  <smm state='off'/>

will incorrectly be interpreted as if the <smm> element was not
present.

Fixes: eeb94215b074a71b3c8932d5fcaf657f269b2c82
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2argvdata/machine-smm-off.x86_64-latest.args
tests/qemuxml2xmloutdata/machine-smm-off.x86_64-latest.xml

index d9b55c80aafb22fdf1a9d9afa539d56d9bb227b2..70562cc9935727b5c18e78a6926f32e07cb47abe 100644 (file)
@@ -17676,8 +17676,12 @@ virDomainFeaturesDefParse(virDomainDef *def,
                                          VIR_XML_PROP_NONE, &state) < 0)
                 return -1;
 
-            if ((state == VIR_TRISTATE_SWITCH_ABSENT) ||
-                (state == VIR_TRISTATE_SWITCH_ON)) {
+            if (state == VIR_TRISTATE_SWITCH_ABSENT)
+                state = VIR_TRISTATE_SWITCH_ON;
+
+            def->features[val] = state;
+
+            if (state == VIR_TRISTATE_SWITCH_ON) {
                 int rv = virParseScaledValue("string(./features/smm/tseg)",
                                              "string(./features/smm/tseg/@unit)",
                                              ctxt,
@@ -17688,7 +17692,6 @@ virDomainFeaturesDefParse(virDomainDef *def,
                 if (rv < 0)
                     return -1;
 
-                def->features[val] = VIR_TRISTATE_SWITCH_ON;
                 def->tseg_specified = rv != 0;
             }
             break;
index b5a685524e82fdcb1d403f7271242cf52d5afec8..46f6a4a70c81da458729150bee596d7e797069e5 100644 (file)
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -name guest=QEMUGuest1,debug-threads=on \
 -S \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
--machine q35,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-machine q35,usb=off,smm=off,dump-guest-core=off,memory-backend=pc.ram \
 -accel tcg \
 -cpu qemu64 \
 -m 214 \
index 1d58c228927973a1ab0e7604b645bd812374d58c..77b0b39750e48f838519e41e154f305db505aecb 100644 (file)
@@ -8,6 +8,9 @@
     <type arch='x86_64' machine='q35'>hvm</type>
     <boot dev='hd'/>
   </os>
+  <features>
+    <smm state='off'/>
+  </features>
   <cpu mode='custom' match='exact' check='none'>
     <model fallback='forbid'>qemu64</model>
   </cpu>