This patch adds the implementation of the IBS pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_IBS capability added
in the previous patch.
IBS can have the following values: "broken", "workaround",
"fixed-ibs", "fixed-ccd" and "fixed-na".
This is the XML format for the cap:
<features>
<ibs value='fixed-ibs'/>
</features>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
docs/formatdomain.html.in | 14 ++++++
docs/schemas/domaincommon.rng | 17 +++++++
src/conf/domain_conf.c | 46 +++++++++++++++++++
src/conf/domain_conf.h | 14 ++++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 5 ++
src/qemu/qemu_validate.c | 11 +++++
tests/qemuxml2argvdata/pseries-features.args | 2 +-
tests/qemuxml2argvdata/pseries-features.xml | 1 +
tests/qemuxml2argvtest.c | 25 ++++++++--
tests/qemuxml2xmloutdata/pseries-features.xml | 1 +
tests/qemuxml2xmltest.c | 3 +-
12 files changed, 135 insertions(+), 5 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 2146374475..01aa825fc6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2076,6 +2076,7 @@
<msrs unknown='ignore'/>
<cfpc value='workaround'/>
<sbbc value='workaround'/>
+ <ibs value='fixed-na'/>
</features>
...</pre>
@@ -2401,6 +2402,19 @@
default will be used.
<span class="since">Since 6.3.0</span> (QEMU/KVM only)
</dd>
+ <dt><code>ibs</code></dt>
+ <dd>Configure ibs (Indirect Branch Speculation) availability for
+ pSeries guests.
+ Possible values for the <code>value</code> attribute
+ are <code>broken</code> (no protection),
<code>workaround</code>
+ (count cache flush), <code>fixed-ibs</code> (fixed by
+ serializing indirect branches), <code>fixed-ccd</code> (fixed by
+ disabling the cache count) and <code>fixed-na (fixed in
+ hardware - no longer applicable)</code>.
+ 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 72c281aa8f..75d5cd3271 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5436,6 +5436,9 @@
<optional>
<ref name="sbbc"/>
</optional>
+ <optional>
+ <ref name="ibs"/>
+ </optional>
</interleave>
</element>
</optional>
@@ -5719,6 +5722,20 @@
</element>
</define>
+ <define name="ibs">
+ <element name="ibs">
+ <attribute name="value">
+ <choice>
+ <value>broken</value>
+ <value>workaround</value>
+ <value>fixed-ibs</value>
+ <value>fixed-ccd</value>
+ <value>fixed-na</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 5373b29263..dfa7421249 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -175,6 +175,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"ccf-assist",
"cfpc",
"sbbc",
+ "ibs",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -1269,6 +1270,16 @@ VIR_ENUM_IMPL(virDomainSBBC,
"fixed",
);
+VIR_ENUM_IMPL(virDomainIBS,
+ VIR_DOMAIN_IBS_LAST,
+ "none",
+ "broken",
+ "workaround",
+ "fixed-ibs",
+ "fixed-ccd",
+ "fixed-na",
+);
+
/* Internal mapping: subset of block job types that can be present in
* <mirror> XML (remaining types are not two-phase). */
VIR_ENUM_DECL(virDomainBlockJob);
@@ -21009,6 +21020,21 @@ virDomainDefParseXML(xmlDocPtr xml,
}
break;
+ case VIR_DOMAIN_FEATURE_IBS:
+ tmp = virXMLPropString(nodes[i], "value");
+ if (tmp) {
+ int value = virDomainIBSTypeFromString(tmp);
+ if (value < 0 || value == VIR_DOMAIN_IBS_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:
@@ -23338,6 +23364,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
}
break;
+ case VIR_DOMAIN_FEATURE_IBS:
+ 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",
virDomainIBSTypeToString(src->features[i]),
+ "value",
virDomainIBSTypeToString(dst->features[i]));
+ return false;
+ }
+ break;
+
case VIR_DOMAIN_FEATURE_MSRS:
break;
@@ -29112,6 +29150,14 @@ virDomainDefFormatFeatures(virBufferPtr buf,
virDomainSBBCTypeToString(def->features[i]));
break;
+ case VIR_DOMAIN_FEATURE_IBS:
+ if (def->features[i] == VIR_DOMAIN_IBS_NONE)
+ break;
+
+ virBufferAsprintf(&childBuf, "<ibs
value='%s'/>\n",
+ virDomainIBSTypeToString(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 c04441e587..a5582f7a34 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1816,6 +1816,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_CCF_ASSIST,
VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_SBBC,
+ VIR_DOMAIN_FEATURE_IBS,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@@ -1994,6 +1995,19 @@ typedef enum {
VIR_ENUM_DECL(virDomainSBBC);
+typedef enum {
+ VIR_DOMAIN_IBS_NONE = 0,
+ VIR_DOMAIN_IBS_BROKEN,
+ VIR_DOMAIN_IBS_WORKAROUND,
+ VIR_DOMAIN_IBS_FIXEDIBS,
+ VIR_DOMAIN_IBS_FIXEDCCD,
+ VIR_DOMAIN_IBS_FIXEDNA,
+
+ VIR_DOMAIN_IBS_LAST
+} virDomainIBS;
+
+VIR_ENUM_DECL(virDomainIBS);
+
/* Operating system configuration data & machine / arch */
struct _virDomainOSEnv {
char *name;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 99e74eee84..09a6ca8956 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -455,6 +455,7 @@ virDomainHubTypeFromString;
virDomainHubTypeToString;
virDomainHypervTypeFromString;
virDomainHypervTypeToString;
+virDomainIBSTypeToString;
virDomainInputBusTypeToString;
virDomainInputDefFind;
virDomainInputDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0c3b37760a..32565b49a9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7173,6 +7173,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",cap-sbbc=%s", str);
}
+ if (def->features[VIR_DOMAIN_FEATURE_IBS] != VIR_DOMAIN_IBS_NONE) {
+ const char *str =
virDomainIBSTypeToString(def->features[VIR_DOMAIN_FEATURE_IBS]);
+ virBufferAsprintf(&buf, ",cap-ibs=%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 f75cec93c2..7d356f683a 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -156,6 +156,16 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
return -1;
}
+ break;
+
+ case VIR_DOMAIN_FEATURE_IBS:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_IBS)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ibs configuration is not supported by "
+ "this QEMU binary"));
+ return -1;
+ }
+
break;
}
@@ -216,6 +226,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
case VIR_DOMAIN_FEATURE_CFPC:
case VIR_DOMAIN_FEATURE_SBBC:
+ case VIR_DOMAIN_FEATURE_IBS:
if (qemuValidateDomainDefPSeriesFeature(def, qemuCaps, i) < 0)
return -1;
break;
diff --git a/tests/qemuxml2argvdata/pseries-features.args
b/tests/qemuxml2argvdata/pseries-features.args
index 9a64df7593..668eeb157b 100644
--- a/tests/qemuxml2argvdata/pseries-features.args
+++ b/tests/qemuxml2argvdata/pseries-features.args
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
-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-cfpc=fixed,cap-sbbc=broken \
+cap-cfpc=fixed,cap-sbbc=broken,cap-ibs=fixed-ccd \
-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 ef431b0067..6e4700a56a 100644
--- a/tests/qemuxml2argvdata/pseries-features.xml
+++ b/tests/qemuxml2argvdata/pseries-features.xml
@@ -15,6 +15,7 @@
<ccf-assist state='on'/>
<cfpc value='fixed'/>
<sbbc value='broken'/>
+ <ibs value='fixed-ccd'/>
</features>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0b4dc0dec5..eb509e0bc0 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1965,6 +1965,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */
@@ -1975,7 +1976,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
- QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
+ QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */
DO_TEST_PARSE_ERROR("pseries-features",
@@ -1985,6 +1987,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */
@@ -1995,6 +1998,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */
@@ -2005,6 +2009,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */
@@ -2015,6 +2020,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */
@@ -2025,7 +2031,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_CAP_SBBC);
+ QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_SBBC */
DO_TEST_PARSE_ERROR("pseries-features",
@@ -2035,7 +2042,19 @@ 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_CAP_CFPC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
+
+ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_IBS */
+ 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,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml
b/tests/qemuxml2xmloutdata/pseries-features.xml
index 3700ffa195..e1c1d7306e 100644
--- a/tests/qemuxml2xmloutdata/pseries-features.xml
+++ b/tests/qemuxml2xmloutdata/pseries-features.xml
@@ -17,6 +17,7 @@
<ccf-assist state='on'/>
<cfpc value='fixed'/>
<sbbc value='broken'/>
+ <ibs value='fixed-ccd'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 9e1b5be13c..78fa9060e1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -696,7 +696,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
- QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
+ QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
DO_TEST("pseries-serial-native",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
--
2.25.2