Qemu-3.1 supports Hyper-V Enlightened VMCS feature which significantly
speeds up nested Hyper-V on KVM environments.
Signed-off-by: Vitaly Kuznetsov <vkuznets(a)redhat.com>
---
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/cpu/cpu_x86.c | 3 +++
src/cpu/cpu_x86_data.h | 1 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_parse_command.c | 1 +
src/qemu/qemu_process.c | 1 +
tests/qemuxml2argvdata/hyperv-off.xml | 1 +
tests/qemuxml2argvdata/hyperv.args | 2 +-
tests/qemuxml2argvdata/hyperv.xml | 1 +
tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
tests/qemuxml2xmloutdata/hyperv.xml | 1 +
14 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 24d4b68d7b..ad58f3f1c7 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1982,6 +1982,7 @@
<reenlightenment state='on'/>
<tlbflush state='on'/>
<ipi state='on'/>
+ <evmcs state='on'/>
</hyperv>
<kvm>
<hidden state='on'/>
@@ -2128,6 +2129,12 @@
<td> on, off</td>
<td><span class="since">4.10.0 (QEMU
3.1)</span></td>
</tr>
+ <tr>
+ <td>evmcs</td>
+ <td>Enable Enlightened VMCS</td>
+ <td> on, off</td>
+ <td><span class="since">4.10.0 (QEMU
3.1)</span></td>
+ </tr>
</table>
</dd>
<dt><code>pvspinlock</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 26019b3279..ff57ce1015 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5774,6 +5774,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="evmcs">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c8cde90808..b0bb162d46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -173,7 +173,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"frequencies",
"reenlightenment",
"tlbflush",
- "ipi")
+ "ipi",
+ "evmcs")
VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
"hidden")
@@ -19992,6 +19993,7 @@ virDomainDefParseXML(xmlDocPtr xml,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22187,6 +22189,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
if (src->hyperv_features[i] != dst->hyperv_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27952,6 +27955,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9eea75548d..061185e779 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1796,6 +1796,7 @@ typedef enum {
VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
VIR_DOMAIN_HYPERV_TLBFLUSH,
VIR_DOMAIN_HYPERV_IPI,
+ VIR_DOMAIN_HYPERV_EVMCS,
VIR_DOMAIN_HYPERV_LAST
} virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 33252e927e..ebfa74fccd 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -116,6 +116,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_TLBFLUSH,
0x40000004, 0x00000004);
KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_IPI,
0x40000004, 0x00000400);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_EVMCS,
+ 0x40000004, 0x00004000);
static virCPUx86Feature x86_kvm_features[] =
{
@@ -140,6 +142,7 @@ static virCPUx86Feature x86_kvm_features[] =
KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_TLBFLUSH),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_IPI),
+ KVM_FEATURE(VIR_CPU_x86_KVM_HV_EVMCS),
};
typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index 8c51d88e1a..f52bba821f 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -66,6 +66,7 @@ struct _virCPUx86CPUID {
# define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment"
# define VIR_CPU_x86_KVM_HV_TLBFLUSH "__kvm_hv_tlbflush"
# define VIR_CPU_x86_KVM_HV_IPI "__kvm_hv_ipi"
+# define VIR_CPU_x86_KVM_HV_EVMCS "__kvm_hv_evmcs"
# define VIR_CPU_X86_DATA_INIT { 0 }
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6fc8deff00..d543ada2a1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6883,6 +6883,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index a15f4d1121..d91fc8d901 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1540,6 +1540,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 85e2f7046b..ebe8e244ae 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3954,6 +3954,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
+ case VIR_DOMAIN_HYPERV_EVMCS:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("host doesn't support hyperv '%s'
feature"),
virDomainHypervTypeToString(i));
diff --git a/tests/qemuxml2argvdata/hyperv-off.xml
b/tests/qemuxml2argvdata/hyperv-off.xml
index e51cca45b5..59c1e17ccd 100644
--- a/tests/qemuxml2argvdata/hyperv-off.xml
+++ b/tests/qemuxml2argvdata/hyperv-off.xml
@@ -24,6 +24,7 @@
<reenlightenment state='off'/>
<tlbflush state='off'/>
<ipi state='off'/>
+ <evmcs state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index 0800e4f79d..5d59788e14 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\
hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\
-hv_reenlightenment,hv_tlbflush,hv_ipi' \
+hv_reenlightenment,hv_tlbflush,hv_ipi,hv_evmcs' \
-m 214 \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml
index 05c7d478f7..c6feaed528 100644
--- a/tests/qemuxml2argvdata/hyperv.xml
+++ b/tests/qemuxml2argvdata/hyperv.xml
@@ -24,6 +24,7 @@
<reenlightenment state='on'/>
<tlbflush state='on'/>
<ipi state='on'/>
+ <evmcs state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv-off.xml
b/tests/qemuxml2xmloutdata/hyperv-off.xml
index 2282b763b5..1b7d82b14a 100644
--- a/tests/qemuxml2xmloutdata/hyperv-off.xml
+++ b/tests/qemuxml2xmloutdata/hyperv-off.xml
@@ -24,6 +24,7 @@
<reenlightenment state='off'/>
<tlbflush state='off'/>
<ipi state='off'/>
+ <evmcs state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml
index 97f387c172..5510d3dfad 100644
--- a/tests/qemuxml2xmloutdata/hyperv.xml
+++ b/tests/qemuxml2xmloutdata/hyperv.xml
@@ -24,6 +24,7 @@
<reenlightenment state='on'/>
<tlbflush state='on'/>
<ipi state='on'/>
+ <evmcs state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
--
2.17.2