On Thu, Jul 25, 2019 at 03:52:17PM +0200, Vitaly Kuznetsov wrote:
QEMU-4.1 supports 'Direct Mode' for Hyper-V synthetic timers (hv-stimer-direct CPU flag): Windows guests can request that timer expiration notifications are delivered as normal interrupts (and not VMBus messages). This is used by Hyper-V on KVM. Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> --- src/qemu/qemu_command.c | 22 ++++++++++++++-- src/qemu/qemu_process.c | 39 +++++++++++++++++++++++++++-- tests/qemuxml2argvdata/hyperv.args | 4 +-- tests/qemuxml2argvdata/hyperv.xml | 4 ++- tests/qemuxml2xmloutdata/hyperv.xml | 4 ++- 5 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1cf165079f..12229e879e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7096,7 +7096,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, int ret = -1; virBuffer cpu_buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER; - size_t i; + size_t i, j; if (def->cpu && (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) { @@ -7158,7 +7158,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, case VIR_DOMAIN_HYPERV_VPINDEX: case VIR_DOMAIN_HYPERV_RUNTIME: case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: @@ -7170,6 +7169,25 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virDomainHypervTypeToString(i)); break; + case VIR_DOMAIN_HYPERV_STIMER: + if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",hv_%s", + virDomainHypervTypeToString(i));
+ for (j = 0; j < VIR_DOMAIN_HYPERV_STIMER_LAST; j++) { + switch ((virDomainHypervStimer) j) { + case VIR_DOMAIN_HYPERV_STIMER_DIRECT: + if (def->hyperv_stimer_features[j] == VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",hv_stimer_%s", + virDomainHypervStimerTypeToString(j)); + break; + + /* coverity[dead_error_begin] */ + case VIR_DOMAIN_HYPERV_STIMER_LAST: + break; + } + }
if (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON) virBufferAddLit(&buf, "hv-stimer-direct");
+ break; + case VIR_DOMAIN_HYPERV_SPINLOCKS: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) virBufferAsprintf(&buf, ",hv_spinlocks=0x%x", diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 75205bc121..0235cfd022 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4111,10 +4111,45 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def, rc = virCPUDataCheckFeature(cpu, cpuFeature); VIR_FREE(cpuFeature); - if (rc < 0) + if (rc < 0) { return -1; - else if (rc == 1) + } else if (rc == 1) { + if ((i == VIR_DOMAIN_HYPERV_STIMER)) { + size_t j; +
Fails compilation with my Clang: qemu/qemu_process.c:4117:20: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if ((i == VIR_DOMAIN_HYPERV_STIMER)) { ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ qemu/qemu_process.c:4117:20: note: remove extraneous parentheses around the comparison to silence this warning if ((i == VIR_DOMAIN_HYPERV_STIMER)) { ~ ^ ~ qemu/qemu_process.c:4117:20: note: use '=' to turn this equality comparison into an assignment if ((i == VIR_DOMAIN_HYPERV_STIMER)) { ^~ = 1 error generated. make[5]: *** [Makefile:11191: qemu/libvirt_driver_qemu_impl_la-qemu_process.lo] Error 1
+ for (j = 0; j < VIR_DOMAIN_HYPERV_STIMER_LAST; j++) { + switch ((virDomainHypervStimer) j) { + case VIR_DOMAIN_HYPERV_STIMER_DIRECT: + if (def->hyperv_stimer_features[j] != VIR_TRISTATE_SWITCH_ON) + continue; + + if (virAsprintf(&cpuFeature, "__kvm_hv_stimer_%s", + virDomainHypervStimerTypeToString(j)) < 0) + return -1; + + rc = virCPUDataCheckFeature(cpu, cpuFeature); + VIR_FREE(cpuFeature); + + if (rc < 0) + return -1; + else if (rc == 1) + continue; + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("host doesn't support hyperv stimer '%s' feature"), + virDomainHypervStimerTypeToString(i)); + return -1; + + /* coverity[dead_error_begin] */ + case VIR_DOMAIN_HYPERV_STIMER_LAST: + break; + } + } + + } + continue; + } switch ((virDomainHyperv) i) { case VIR_DOMAIN_HYPERV_RELAXED:
Jano
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list