提交 104dadcf 编写于 作者: D Daniel Henrique Barboza 提交者: Michal Privoznik

qemu: Implement the SBBC pSeries feature

This patch adds the implementation of the SBBC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC capability added
in the previous patch.

Like the previously added CFPC feature, SBBC 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>
  <sbbc value='workaround'/>
</features>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 249a5c78
...@@ -2079,6 +2079,7 @@ ...@@ -2079,6 +2079,7 @@
&lt;ccf-assist state='on'/&gt; &lt;ccf-assist state='on'/&gt;
&lt;msrs unknown='ignore'/&gt; &lt;msrs unknown='ignore'/&gt;
&lt;cfpc value='workaround'/&gt; &lt;cfpc value='workaround'/&gt;
&lt;sbbc value='workaround'/&gt;
&lt;/features&gt; &lt;/features&gt;
...</pre> ...</pre>
...@@ -2417,6 +2418,16 @@ ...@@ -2417,6 +2418,16 @@
default will be used. default will be used.
<span class="since">Since 6.3.0</span> (QEMU/KVM only) <span class="since">Since 6.3.0</span> (QEMU/KVM only)
</dd> </dd>
<dt><code>sbbc</code></dt>
<dd>Configure sbbc (Speculation Barrier Bounds Checking) 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> </dl>
<h3><a id="elementsTime">Time keeping</a></h3> <h3><a id="elementsTime">Time keeping</a></h3>
......
...@@ -5437,6 +5437,9 @@ ...@@ -5437,6 +5437,9 @@
<optional> <optional>
<ref name="cfpc"/> <ref name="cfpc"/>
</optional> </optional>
<optional>
<ref name="sbbc"/>
</optional>
</interleave> </interleave>
</element> </element>
</optional> </optional>
...@@ -5708,6 +5711,18 @@ ...@@ -5708,6 +5711,18 @@
</element> </element>
</define> </define>
<define name="sbbc">
<element name="sbbc">
<attribute name="value">
<choice>
<value>broken</value>
<value>workaround</value>
<value>fixed</value>
</choice>
</attribute>
</element>
</define>
<define name="address"> <define name="address">
<element name="address"> <element name="address">
<choice> <choice>
......
...@@ -175,6 +175,7 @@ VIR_ENUM_IMPL(virDomainFeature, ...@@ -175,6 +175,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"ccf-assist", "ccf-assist",
"xen", "xen",
"cfpc", "cfpc",
"sbbc",
); );
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
...@@ -1275,6 +1276,14 @@ VIR_ENUM_IMPL(virDomainCFPC, ...@@ -1275,6 +1276,14 @@ VIR_ENUM_IMPL(virDomainCFPC,
"fixed", "fixed",
); );
VIR_ENUM_IMPL(virDomainSBBC,
VIR_DOMAIN_SBBC_LAST,
"none",
"broken",
"workaround",
"fixed",
);
/* Internal mapping: subset of block job types that can be present in /* Internal mapping: subset of block job types that can be present in
* <mirror> XML (remaining types are not two-phase). */ * <mirror> XML (remaining types are not two-phase). */
VIR_ENUM_DECL(virDomainBlockJob); VIR_ENUM_DECL(virDomainBlockJob);
...@@ -19350,6 +19359,21 @@ virDomainFeaturesDefParse(virDomainDefPtr def, ...@@ -19350,6 +19359,21 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
} }
break; break;
case VIR_DOMAIN_FEATURE_SBBC:
tmp = virXMLPropString(nodes[i], "value");
if (tmp) {
int value = virDomainSBBCTypeFromString(tmp);
if (value < 0 || value == VIR_DOMAIN_SBBC_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_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST: case VIR_DOMAIN_FEATURE_CCF_ASSIST:
...@@ -23413,6 +23437,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, ...@@ -23413,6 +23437,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
} }
break; break;
case VIR_DOMAIN_FEATURE_SBBC:
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", virDomainSBBCTypeToString(src->features[i]),
"value", virDomainSBBCTypeToString(dst->features[i]));
return false;
}
break;
case VIR_DOMAIN_FEATURE_MSRS: case VIR_DOMAIN_FEATURE_MSRS:
break; break;
...@@ -29255,6 +29291,14 @@ virDomainDefFormatFeatures(virBufferPtr buf, ...@@ -29255,6 +29291,14 @@ virDomainDefFormatFeatures(virBufferPtr buf,
virDomainCFPCTypeToString(def->features[i])); virDomainCFPCTypeToString(def->features[i]));
break; break;
case VIR_DOMAIN_FEATURE_SBBC:
if (def->features[i] == VIR_DOMAIN_SBBC_NONE)
break;
virBufferAsprintf(&childBuf, "<sbbc value='%s'/>\n",
virDomainSBBCTypeToString(def->features[i]));
break;
/* coverity[dead_error_begin] */ /* coverity[dead_error_begin] */
case VIR_DOMAIN_FEATURE_LAST: case VIR_DOMAIN_FEATURE_LAST:
break; break;
...@@ -1817,6 +1817,7 @@ typedef enum { ...@@ -1817,6 +1817,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_CCF_ASSIST, VIR_DOMAIN_FEATURE_CCF_ASSIST,
VIR_DOMAIN_FEATURE_XEN, VIR_DOMAIN_FEATURE_XEN,
VIR_DOMAIN_FEATURE_CFPC, VIR_DOMAIN_FEATURE_CFPC,
VIR_DOMAIN_FEATURE_SBBC,
VIR_DOMAIN_FEATURE_LAST VIR_DOMAIN_FEATURE_LAST
} virDomainFeature; } virDomainFeature;
...@@ -1999,6 +2000,17 @@ typedef enum { ...@@ -1999,6 +2000,17 @@ typedef enum {
VIR_ENUM_DECL(virDomainCFPC); VIR_ENUM_DECL(virDomainCFPC);
typedef enum {
VIR_DOMAIN_SBBC_NONE = 0,
VIR_DOMAIN_SBBC_BROKEN,
VIR_DOMAIN_SBBC_WORKAROUND,
VIR_DOMAIN_SBBC_FIXED,
VIR_DOMAIN_SBBC_LAST
} virDomainSBBC;
VIR_ENUM_DECL(virDomainSBBC);
/* Operating system configuration data & machine / arch */ /* Operating system configuration data & machine / arch */
struct _virDomainOSEnv { struct _virDomainOSEnv {
char *name; char *name;
......
...@@ -583,6 +583,8 @@ virDomainRNGModelTypeToString; ...@@ -583,6 +583,8 @@ virDomainRNGModelTypeToString;
virDomainRNGRemove; virDomainRNGRemove;
virDomainRunningReasonTypeFromString; virDomainRunningReasonTypeFromString;
virDomainRunningReasonTypeToString; virDomainRunningReasonTypeToString;
virDomainSBBCTypeFromString;
virDomainSBBCTypeToString;
virDomainSCSIDriveAddressIsUsed; virDomainSCSIDriveAddressIsUsed;
virDomainSeclabelTypeFromString; virDomainSeclabelTypeFromString;
virDomainSeclabelTypeToString; virDomainSeclabelTypeToString;
......
...@@ -7176,6 +7176,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, ...@@ -7176,6 +7176,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",cap-cfpc=%s", str); virBufferAsprintf(&buf, ",cap-cfpc=%s", str);
} }
if (def->features[VIR_DOMAIN_FEATURE_SBBC] != VIR_DOMAIN_SBBC_NONE) {
const char *str = virDomainSBBCTypeToString(def->features[VIR_DOMAIN_FEATURE_SBBC]);
virBufferAsprintf(&buf, ",cap-sbbc=%s", str);
}
if (cpu && cpu->model && if (cpu && cpu->model &&
cpu->mode == VIR_CPU_MODE_HOST_MODEL && cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
qemuDomainIsPSeries(def) && qemuDomainIsPSeries(def) &&
......
...@@ -146,6 +146,16 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def, ...@@ -146,6 +146,16 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
return -1; return -1;
} }
break;
case VIR_DOMAIN_FEATURE_SBBC:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("sbbc configuration is not supported by "
"this QEMU binary"));
return -1;
}
break; break;
} }
...@@ -205,6 +215,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, ...@@ -205,6 +215,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST: case VIR_DOMAIN_FEATURE_CCF_ASSIST:
case VIR_DOMAIN_FEATURE_CFPC: case VIR_DOMAIN_FEATURE_CFPC:
case VIR_DOMAIN_FEATURE_SBBC:
if (qemuValidateDomainDefPSeriesFeature(def, qemuCaps, i) < 0) if (qemuValidateDomainDefPSeriesFeature(def, qemuCaps, i) < 0)
return -1; return -1;
break; break;
......
...@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \ ...@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
-S \ -S \
-machine pseries,accel=tcg,usb=off,dump-guest-core=off,resize-hpt=required,\ -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 \ cap-cfpc=fixed,cap-sbbc=broken \
-m 512 \ -m 512 \
-realtime mlock=off \ -realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \ -smp 1,sockets=1,cores=1,threads=1 \
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<nested-hv state='off'/> <nested-hv state='off'/>
<ccf-assist state='on'/> <ccf-assist state='on'/>
<cfpc value='fixed'/> <cfpc value='fixed'/>
<sbbc value='broken'/>
</features> </features>
<devices> <devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator> <emulator>/usr/bin/qemu-system-ppc64</emulator>
......
...@@ -1965,6 +1965,7 @@ mymain(void) ...@@ -1965,6 +1965,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */
...@@ -1974,7 +1975,8 @@ mymain(void) ...@@ -1974,7 +1975,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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); QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */
DO_TEST_PARSE_ERROR("pseries-features", DO_TEST_PARSE_ERROR("pseries-features",
...@@ -1983,6 +1985,7 @@ mymain(void) ...@@ -1983,6 +1985,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */
...@@ -1992,6 +1995,7 @@ mymain(void) ...@@ -1992,6 +1995,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */
...@@ -2001,6 +2005,7 @@ mymain(void) ...@@ -2001,6 +2005,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST, QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */
...@@ -2010,6 +2015,7 @@ mymain(void) ...@@ -2010,6 +2015,7 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC, QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */ /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */
...@@ -2019,7 +2025,18 @@ mymain(void) ...@@ -2019,7 +2025,18 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE, QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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_SBBC);
/* parse error: no QEMU_CAPS_MACHINE_PSERIES_SBBC */
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);
DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE); DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<nested-hv state='off'/> <nested-hv state='off'/>
<ccf-assist state='on'/> <ccf-assist state='on'/>
<cfpc value='fixed'/> <cfpc value='fixed'/>
<sbbc value='broken'/>
</features> </features>
<clock offset='utc'/> <clock offset='utc'/>
<on_poweroff>destroy</on_poweroff> <on_poweroff>destroy</on_poweroff>
......
...@@ -696,7 +696,8 @@ mymain(void) ...@@ -696,7 +696,8 @@ mymain(void)
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, 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_RESIZE_HPT, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC); QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
DO_TEST("pseries-serial-native", DO_TEST("pseries-serial-native",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册