This patch adds the implementation of the CFPC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC capability added
in the previous patch.
CPFC can have the values "broken", "workaround" or "fixed".
Extra
code is required to handle it since it's not a regular tristate
capability.
This is the XML format for the cap:
<features>
<cfpc value='workaround'/>
</features>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
docs/formatdomain.html.in | 11 +++++
docs/schemas/domaincommon.rng | 15 +++++++
src/conf/domain_conf.c | 45 +++++++++++++++++++
src/conf/domain_conf.h | 12 +++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 5 +++
src/qemu/qemu_validate.c | 11 +++++
tests/qemuxml2argvdata/pseries-features.args | 3 +-
tests/qemuxml2argvdata/pseries-features.xml | 1 +
tests/qemuxml2argvtest.c | 17 ++++++-
tests/qemuxml2xmloutdata/pseries-features.xml | 1 +
tests/qemuxml2xmltest.c | 3 +-
12 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0077666862..607e815413 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2074,6 +2074,7 @@
<htm state='on'/>
<ccf-assist state='on'/>
<msrs unknown='ignore'/>
+ <cfpc value='workaround'/>
</features>
...</pre>
@@ -2379,6 +2380,16 @@
defined, the hypervisor default will be used.
<span class="since">Since 5.9.0</span> (QEMU/KVM only)
</dd>
+ <dt><code>cfpc</code></dt>
+ <dd>Configure cfpc (Cache Flush on Privilege Change) availability for
+ pSeries guests.
+ Possible values for the <code>value</code> attribute
+ are <code>broken</code> (no protection),
<code>workaround</code>
+ (software workaround available) and <code>fixed</code> (fixed in
+ hardware). If the attribute is not defined, the hypervisor
+ default will be used.
+ <span class="since">Since 6.3.0</span> (QEMU/KVM only)
+ </dd>
</dl>
<h3><a id="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 65d6580434..40785752f7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5430,6 +5430,9 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <ref name="cfpc"/>
+ </optional>
</interleave>
</element>
</optional>
@@ -5689,6 +5692,18 @@
</element>
</define>
+ <define name="cfpc">
+ <element name="cfpc">
+ <attribute name="value">
+ <choice>
+ <value>broken</value>
+ <value>workaround</value>
+ <value>fixed</value>
+ </choice>
+ </attribute>
+ </element>
+ </define>
+
<define name="address">
<element name="address">
<choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8700d56761..4bfb17b7c8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -173,6 +173,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"nested-hv",
"msrs",
"ccf-assist",
+ "cfpc",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -1251,6 +1252,14 @@ VIR_ENUM_IMPL(virDomainOsDefFirmware,
"efi",
);
+VIR_ENUM_IMPL(virDomainCFPC,
+ VIR_DOMAIN_CFPC_LAST,
+ "none",
+ "broken",
+ "workaround",
+ "fixed",
+);
+
/* Internal mapping: subset of block job types that can be present in
* <mirror> XML (remaining types are not two-phase). */
VIR_ENUM_DECL(virDomainBlockJob);
@@ -20961,6 +20970,22 @@ virDomainDefParseXML(xmlDocPtr xml,
}
break;
+ case VIR_DOMAIN_FEATURE_CFPC:
+ tmp = virXMLPropString(nodes[i], "value");
+ if (tmp) {
+ int value = virDomainCFPCTypeFromString(tmp);
+ if (value < 0 || value == VIR_DOMAIN_CFPC_NONE) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unknown value: %s"),
+ tmp);
+ goto error;
+ }
+ def->features[val] = value;
+ VIR_FREE(tmp);
+ }
+ break;
+
+
case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
@@ -23266,6 +23291,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
}
break;
+ case VIR_DOMAIN_FEATURE_CFPC:
+ if (src->features[i] != dst->features[i]) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("State of feature '%s' differs: "
+ "source: '%s=%s', destination:
'%s=%s'"),
+ featureName,
+ "value",
virDomainCFPCTypeToString(src->features[i]),
+ "value",
virDomainCFPCTypeToString(dst->features[i]));
+ return false;
+ }
+ break;
+
case VIR_DOMAIN_FEATURE_MSRS:
break;
@@ -29024,6 +29061,14 @@ virDomainDefFormatFeatures(virBufferPtr buf,
virDomainMsrsUnknownTypeToString(def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN]));
break;
+ case VIR_DOMAIN_FEATURE_CFPC:
+ if (def->features[i] == VIR_DOMAIN_CFPC_NONE)
+ break;
+
+ virBufferAsprintf(&childBuf, "<cfpc
value='%s'/>\n",
+ virDomainCFPCTypeToString(def->features[i]));
+ break;
+
/* coverity[dead_error_begin] */
case VIR_DOMAIN_FEATURE_LAST:
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 7d8f1aa31b..a59e3cd41a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1814,6 +1814,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_NESTED_HV,
VIR_DOMAIN_FEATURE_MSRS,
VIR_DOMAIN_FEATURE_CCF_ASSIST,
+ VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@@ -1970,6 +1971,17 @@ typedef enum {
VIR_ENUM_DECL(virDomainHPTResizing);
+typedef enum {
+ VIR_DOMAIN_CFPC_NONE = 0,
+ VIR_DOMAIN_CFPC_BROKEN,
+ VIR_DOMAIN_CFPC_WORKAROUND,
+ VIR_DOMAIN_CFPC_FIXED,
+
+ VIR_DOMAIN_CFPC_LAST
+} virDomainCFPC;
+
+VIR_ENUM_DECL(virDomainCFPC);
+
/* Operating system configuration data & machine / arch */
struct _virDomainOSEnv {
char *name;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ec367653d5..df48176e6a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -235,6 +235,7 @@ virDomainBlockIoTuneInfoHasMaxLength;
virDomainBootTypeFromString;
virDomainBootTypeToString;
virDomainCapabilitiesPolicyTypeToString;
+virDomainCFPCTypeToString;
virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 95402fc4ff..302cee79ad 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7163,6 +7163,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",cap-ccf-assist=%s", str);
}
+ if (def->features[VIR_DOMAIN_FEATURE_CFPC] != VIR_DOMAIN_CFPC_NONE) {
+ const char *str =
virDomainCFPCTypeToString(def->features[VIR_DOMAIN_FEATURE_CFPC]);
+ virBufferAsprintf(&buf, ",cap-cfpc=%s", str);
+ }
+
if (cpu && cpu->model &&
cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
qemuDomainIsPSeries(def) &&
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 971e4a945a..11d310ed8f 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -136,6 +136,16 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
return -1;
}
+ break;
+
+ case VIR_DOMAIN_FEATURE_CFPC:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("cfpc configuration is not supported by "
+ "this QEMU binary"));
+ return -1;
+ }
+
break;
}
@@ -194,6 +204,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
+ case VIR_DOMAIN_FEATURE_CFPC:
if (qemuValidateDomainDefPSeriesFeature(def, qemuCaps, i) < 0)
return -1;
break;
diff --git a/tests/qemuxml2argvdata/pseries-features.args
b/tests/qemuxml2argvdata/pseries-features.args
index 7aa357a54e..8540252c17 100644
--- a/tests/qemuxml2argvdata/pseries-features.args
+++ b/tests/qemuxml2argvdata/pseries-features.args
@@ -11,7 +11,8 @@ QEMU_AUDIO_DRV=none \
-name guest \
-S \
-machine pseries,accel=tcg,usb=off,dump-guest-core=off,resize-hpt=required,\
-cap-hpt-max-page-size=1048576k,cap-htm=on,cap-nested-hv=off,cap-ccf-assist=on \
+cap-hpt-max-page-size=1048576k,cap-htm=on,cap-nested-hv=off,cap-ccf-assist=on,\
+cap-cfpc=fixed \
-m 512 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/pseries-features.xml
b/tests/qemuxml2argvdata/pseries-features.xml
index 8ccc1b73d8..f07a204cb7 100644
--- a/tests/qemuxml2argvdata/pseries-features.xml
+++ b/tests/qemuxml2argvdata/pseries-features.xml
@@ -13,6 +13,7 @@
<htm state='on'/>
<nested-hv state='off'/>
<ccf-assist state='on'/>
+ <cfpc value='fixed'/>
</features>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 66472a5ee5..8cb53b2416 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1963,6 +1963,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */
@@ -1971,7 +1972,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
- QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST);
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */
DO_TEST_PARSE_ERROR("pseries-features",
@@ -1979,6 +1981,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */
@@ -1987,6 +1990,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */
@@ -1995,6 +1999,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */
@@ -2003,8 +2008,18 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
+ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */
+ DO_TEST_PARSE_ERROR("pseries-features",
+ QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
+ QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST);
+
DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
DO_TEST("pseries-serial-native",
diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml
b/tests/qemuxml2xmloutdata/pseries-features.xml
index a5df840394..1b5d78ce74 100644
--- a/tests/qemuxml2xmloutdata/pseries-features.xml
+++ b/tests/qemuxml2xmloutdata/pseries-features.xml
@@ -15,6 +15,7 @@
<htm state='on'/>
<nested-hv state='off'/>
<ccf-assist state='on'/>
+ <cfpc value='fixed'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index cf5abeac35..41510fd17a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -694,7 +694,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
- QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
+ QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC);
DO_TEST("pseries-serial-native",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
--
2.25.2