mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemu: support for kvm-hint-dedicated performance hint
QEMU version 2.12.1 introduced a performance feature under commit be7773268d98 ("target-i386: add KVM_HINTS_DEDICATED performance hint") This patch adds a new KVM feature 'hint-dedicated' to set this performance hint for KVM guests. The feature is off by default. To enable this hint and have libvirt add "-cpu host,kvm-hint-dedicated=on" to the QEMU command line, the following XML code needs to be added to the guest's domain description in conjunction with CPU mode='host-passthrough'. <features> <kvm> <hint-dedicated state='on'/> </kvm> </features> ... <cpu mode='host-passthrough ... /> Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Signed-off-by: Menno Lageman <menno.lageman@oracle.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8daefcf60e
commit
cb12c59dac
@ -2044,6 +2044,7 @@
|
||||
</hyperv>
|
||||
<kvm>
|
||||
<hidden state='on'/>
|
||||
<hint-dedicated state='on'/>
|
||||
</kvm>
|
||||
<pvspinlock state='on'/>
|
||||
<gic version='2'/>
|
||||
@ -2217,6 +2218,12 @@
|
||||
<td>on, off</td>
|
||||
<td><span class="since">1.2.8 (QEMU 2.1.0)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>hint-dedicated</td>
|
||||
<td>Allows a guest to enable optimizations when running on dedicated vCPUs</td>
|
||||
<td>on, off</td>
|
||||
<td><span class="since">5.7.0 (QEMU 2.12.1)</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><code>pmu</code></dt>
|
||||
|
@ -5965,6 +5965,11 @@
|
||||
<ref name="featurestate"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="hint-dedicated">
|
||||
<ref name="featurestate"/>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
|
@ -202,6 +202,7 @@ VIR_ENUM_IMPL(virDomainHyperv,
|
||||
VIR_ENUM_IMPL(virDomainKVM,
|
||||
VIR_DOMAIN_KVM_LAST,
|
||||
"hidden",
|
||||
"hint-dedicated",
|
||||
);
|
||||
|
||||
VIR_ENUM_IMPL(virDomainMsrsUnknown,
|
||||
@ -20412,6 +20413,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
|
||||
switch ((virDomainKVM) feature) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
if (!(tmp = virXMLPropString(nodes[i], "state"))) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("missing 'state' attribute for "
|
||||
@ -22624,6 +22626,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
|
||||
for (i = 0; i < VIR_DOMAIN_KVM_LAST; i++) {
|
||||
switch ((virDomainKVM) i) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
if (src->kvm_features[i] != dst->kvm_features[i]) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("State of KVM feature '%s' differs: "
|
||||
@ -28124,6 +28127,7 @@ virDomainDefFormatFeatures(virBufferPtr buf,
|
||||
for (j = 0; j < VIR_DOMAIN_KVM_LAST; j++) {
|
||||
switch ((virDomainKVM) j) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
if (def->kvm_features[j])
|
||||
virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
|
||||
virDomainKVMTypeToString(j),
|
||||
|
@ -1765,6 +1765,7 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_KVM_HIDDEN = 0,
|
||||
VIR_DOMAIN_KVM_DEDICATED,
|
||||
|
||||
VIR_DOMAIN_KVM_LAST
|
||||
} virDomainKVM;
|
||||
|
@ -7212,6 +7212,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
|
||||
virBufferAddLit(&buf, ",kvm=off");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
virBufferAddLit(&buf, ",kvm-hint-dedicated=on");
|
||||
break;
|
||||
|
||||
/* coverity[dead_error_begin] */
|
||||
case VIR_DOMAIN_KVM_LAST:
|
||||
break;
|
||||
|
@ -4449,6 +4449,16 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_KVM:
|
||||
if (def->kvm_features[VIR_DOMAIN_KVM_DEDICATED] == VIR_TRISTATE_SWITCH_ON &&
|
||||
(!def->cpu || def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("kvm-hint-dedicated=on is only applicable "
|
||||
"for cpu host-passthrough"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_ACPI:
|
||||
case VIR_DOMAIN_FEATURE_APIC:
|
||||
case VIR_DOMAIN_FEATURE_PAE:
|
||||
@ -4456,7 +4466,6 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
|
||||
case VIR_DOMAIN_FEATURE_VIRIDIAN:
|
||||
case VIR_DOMAIN_FEATURE_PRIVNET:
|
||||
case VIR_DOMAIN_FEATURE_HYPERV:
|
||||
case VIR_DOMAIN_FEATURE_KVM:
|
||||
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
|
||||
case VIR_DOMAIN_FEATURE_CAPABILITIES:
|
||||
case VIR_DOMAIN_FEATURE_PMU:
|
||||
|
Loading…
Reference in New Issue
Block a user