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 | 44 +++++++++++++++++++
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, 121 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c5305739d2..a99407675f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2078,6 +2078,7 @@
<htm state='on'/>
<ccf-assist state='on'/>
<msrs unknown='ignore'/>
+ <cfpc value='workaround'/>
</features>
...</pre>
@@ -2406,6 +2407,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 7f18e5b669..6441e01717 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5434,6 +5434,9 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <ref name="cfpc"/>
+ </optional>
</interleave>
</element>
</optional>
@@ -5693,6 +5696,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 89cd8c5f32..e53586cdf2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -174,6 +174,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"msrs",
"ccf-assist",
"xen",
+ "cfpc",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -1266,6 +1267,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);
@@ -19326,6 +19335,21 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
}
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:
@@ -23377,6 +23401,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;
@@ -29211,6 +29247,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 ecb80ef8f2..8594049e52 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1816,6 +1816,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_MSRS,
VIR_DOMAIN_FEATURE_CCF_ASSIST,
VIR_DOMAIN_FEATURE_XEN,
+ VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@@ -1987,6 +1988,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 a9694f34c0..308959b493 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 45dd830781..4cb454769a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7171,6 +7171,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 cb0ff8d636..31d36e938b 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 1a1b9026c4..1bad60bfce 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1964,6 +1964,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 */
@@ -1972,7 +1973,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",
@@ -1980,6 +1982,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 */
@@ -1988,6 +1991,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 */
@@ -1996,6 +2000,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 */
@@ -2004,8 +2009,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 4e43fa6fc6..2a89c289a4 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -695,7 +695,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.4