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 dd8172fff2..91d6f6c0d3 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2080,6 +2080,7 @@
<msrs unknown='ignore'/>
<cfpc value='workaround'/>
<sbbc value='workaround'/>
+ <ibs value='fixed-na'/>
</features>
...</pre>
@@ -2428,6 +2429,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 2a7a433c03..9d60b090f3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5440,6 +5440,9 @@
<optional>
<ref name="sbbc"/>
</optional>
+ <optional>
+ <ref name="ibs"/>
+ </optional>
</interleave>
</element>
</optional>
@@ -5723,6 +5726,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 226a0012fc..8a87586936 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -176,6 +176,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"xen",
"cfpc",
"sbbc",
+ "ibs",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -1284,6 +1285,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);
@@ -19374,6 +19385,21 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
}
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:
@@ -23449,6 +23475,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;
@@ -29299,6 +29337,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 ac84591b17..4afd8f04bc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1818,6 +1818,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_XEN,
VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_SBBC,
+ VIR_DOMAIN_FEATURE_IBS,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@@ -2011,6 +2012,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 cccae12323..c70ea9e642 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 b7c6be0d50..a76e7d6f61 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7181,6 +7181,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 0d5df6f426..cd297aa734 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 83f451f750..d3c8b048cb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1966,6 +1966,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 */
@@ -1976,7 +1977,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",
@@ -1986,6 +1988,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 */
@@ -1996,6 +1999,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 */
@@ -2006,6 +2010,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 */
@@ -2016,6 +2021,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 */
@@ -2026,7 +2032,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",
@@ -2036,7 +2043,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 c2596161c3..06145e767a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -697,7 +697,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.4