]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: add deprecated_features attribute
authorCollin Walling <walling@linux.ibm.com>
Mon, 16 Dec 2024 23:03:58 +0000 (18:03 -0500)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 17 Dec 2024 10:45:50 +0000 (11:45 +0100)
Add a new a attribute, deprecated_features='on|off' to the <cpu>
element.  This is used to toggle features flagged as deprecated on the
CPU model on or off.  When this attribute is paired with 'on',
deprecated features will not be filtered.  When paired with 'off', any
CPU features that are flagged as deprecated will be listed under the
CPU model with the 'disable' policy.

Example:

  <cpu mode='host-model' check='partial' deprecated_features='off'/>

The absence of this attribute is equivalent to the 'on' option.

The deprecated features that will populate the domain XML are the same
features that result in the virsh domcapabilities command with the
--disable-deprecated-features argument present.

It is recommended to define a domain XML with this attribute set to
'off' to ensure migration to machines that may outright drop these
features in the future.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/conf/cpu_conf.c
src/conf/cpu_conf.h
src/conf/schemas/cputypes.rng
src/qemu/qemu_process.c
tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.err [new file with mode: 0644]
tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.xml [new file with mode: 0644]
tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.args [new file with mode: 0644]
tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.xml [new file with mode: 0644]
tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml [new file with mode: 0644]
tests/qemuxmlconftest.c

index dcc164d165ae6ac61f2951701e488b5d38ec43cd..31425783baaff167f57f4366569d8cb7c65b3b0c 100644 (file)
@@ -238,6 +238,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
     copy->mode = cpu->mode;
     copy->match = cpu->match;
     copy->check = cpu->check;
+    copy->deprecated_feats = cpu->deprecated_feats;
     copy->fallback = cpu->fallback;
     copy->sockets = cpu->sockets;
     copy->dies = cpu->dies;
@@ -450,6 +451,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
         if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString,
                            VIR_XML_PROP_NONE, &def->check) < 0)
             return -1;
+
+        if (virXMLPropTristateSwitch(ctxt->node, "deprecated_features",
+                                     VIR_XML_PROP_NONE,
+                                     &def->deprecated_feats) < 0)
+            return -1;
     }
 
     if (def->type == VIR_CPU_TYPE_HOST) {
@@ -748,6 +754,11 @@ virCPUDefFormatBufFull(virBuffer *buf,
             virBufferAsprintf(&attributeBuf, " migratable='%s'",
                               virTristateSwitchTypeToString(def->migratable));
         }
+
+        if (def->deprecated_feats) {
+            virBufferAsprintf(&attributeBuf, " deprecated_features='%s'",
+                              virTristateSwitchTypeToString(def->deprecated_feats));
+        }
     }
 
     /* Format children */
index f71d942ce64cfc00e3969e668b00a881805d146e..28e26303ef046ba823ed7c74f3c2aa1adcc072fe 100644 (file)
@@ -161,6 +161,7 @@ struct _virCPUDef {
     virCPUMaxPhysAddrDef *addr;
     virHostCPUTscInfo *tsc;
     virTristateSwitch migratable; /* for host-passthrough mode */
+    virTristateSwitch deprecated_feats;
 };
 
 virCPUDef *virCPUDefNew(void);
index 3a8910e09f2df924148730ead7de8967477718ab..8edf1d14e316aff68ebc222789e5e5009f0dbb18 100644 (file)
       <optional>
         <ref name="cpuCheck"/>
       </optional>
+      <optional>
+        <attribute name="deprecated_features">
+          <ref name="virOnOff"/>
+        </attribute>
+      </optional>
       <optional>
         <attribute name="migratable">
           <ref name="virOnOff"/>
index bee7a39e4e7a17b14a0234e2f0246910389a1c12..5f2e2781562516d821011a520efdbfd64b343a7f 100644 (file)
@@ -6399,6 +6399,17 @@ qemuProcessUpdateGuestCPU(virDomainDef *def,
                                 &def->os.arch) < 0)
         return -1;
 
+    if (def->cpu->deprecated_feats &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("toggling deprecated features for CPU model is unsupported"));
+        return -1;
+    }
+
+    if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) {
+        virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu);
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.err b/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.err
new file mode 100644 (file)
index 0000000..936d1d5
--- /dev/null
@@ -0,0 +1 @@
+unsupported configuration: toggling deprecated features for CPU model is unsupported
diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.xml b/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.xml
new file mode 100644 (file)
index 0000000..e1f7ba3
--- /dev/null
@@ -0,0 +1,25 @@
+<domain type='kvm'>
+  <name>guest</name>
+  <uuid>22782664-6b93-46bf-9595-317220dd2d1c</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio-8.2'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='host-model' check='partial' deprecated_features='off'/>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <controller type='pci' index='0' model='pci-root'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.args b/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.args
new file mode 100644 (file)
index 0000000..ba6e7c5
--- /dev/null
@@ -0,0 +1,32 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-guest \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-guest/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-guest/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
+/usr/bin/qemu-system-s390x \
+-name guest=guest,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \
+-machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \
+-accel kvm \
+-cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=off,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=off,ais=on,bpb=off,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=off,cmm=on,vxpdeh2=on \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 22782664-6b93-46bf-9595-317220dd2d1c \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device '{"driver":"virtio-balloon-ccw","id":"balloon0","devno":"fe.0.0000"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.xml b/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.xml
new file mode 100644 (file)
index 0000000..fdd87ac
--- /dev/null
@@ -0,0 +1,25 @@
+<domain type='kvm'>
+  <name>guest</name>
+  <uuid>22782664-6b93-46bf-9595-317220dd2d1c</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='host-model' check='partial' deprecated_features='off'/>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <controller type='pci' index='0' model='pci-root'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml b/tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml
new file mode 100644 (file)
index 0000000..6795071
--- /dev/null
@@ -0,0 +1,15 @@
+<domain type='kvm'>
+  <name>guest</name>
+  <uuid>22782664-6b93-46bf-9595-317220dd2d1c</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </os>
+  <cpu mode='host-model' check='partial' deprecated_features='off'/>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+  </devices>
+</domain>
index f3c8d0ae34d3fa1aff092c43431894dc4ea25029..23f1d9eab7f82f4879e9fb08b35c814944a39da3 100644 (file)
@@ -2295,6 +2295,9 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("cpu-s390-zEC12", "s390x");
     DO_TEST_CAPS_ARCH_LATEST("cpu-s390-features", "s390x");
 
+    DO_TEST_CAPS_ARCH_VER_FAILURE("cpu-model-deprecated-features-off", "s390x", "8.2.0");
+    DO_TEST_CAPS_ARCH_LATEST("cpu-model-deprecated-features-off", "s390x");
+
     DO_TEST_CAPS_ARCH_LATEST_FULL("cpu-Haswell", "x86_64", ARG_CAPS_HOST_CPU_MODEL, QEMU_CPU_DEF_HASWELL);
     DO_TEST_CAPS_ARCH_LATEST_FULL("cpu-Haswell2", "x86_64", ARG_CAPS_HOST_CPU_MODEL, QEMU_CPU_DEF_HASWELL);
     DO_TEST_CAPS_ARCH_LATEST_FULL("cpu-Haswell3", "x86_64", ARG_CAPS_HOST_CPU_MODEL, QEMU_CPU_DEF_HASWELL);