From 004171b9879af86d3c14654d0080b5559ee48267 Mon Sep 17 00:00:00 2001 Message-Id: <004171b9879af86d3c14654d0080b5559ee48267.1345545736.git.minovotn@redhat.com> From: Amit Shah Date: Wed, 1 Aug 2012 07:34:23 +0200 Subject: [PATCH 1/8] kvmclock: guest stop notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Amit Shah Message-id: Patchwork-id: 40488 O-Subject: [RHEL6 qemu PATCH 1/1] kvmclock: guest stop notification Bugzilla: 831614 RH-Acked-by: Paolo Bonzini RH-Acked-by: Laszlo Ersek RH-Acked-by: Amos Kong From: Eric B Munson Often when a guest is stopped from the qemu console, it will report spurious soft lockup warnings on resume. There are kernel patches being discussed that will give the host the ability to tell the guest that it is being stopped and should ignore the soft lockup warning that generates. This patch uses the qemu Notifier system to tell the guest it is about to be stopped. Signed-off-by: Eric B Munson Signed-off-by: Raghavendra K T Reviewed-by: Andreas Färber Signed-off-by: Marcelo Tosatti (cherry picked from commit f349c12c0434e29c79ecde89029320c4002f7253) Bugzilla: 831614 Signed-off-by: Amit Shah --- hw/kvmclock.c | 16 ++++++++++++++++ kvm/include/linux/kvm.h | 2 ++ 2 files changed, 18 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- hw/kvmclock.c | 16 ++++++++++++++++ kvm/include/linux/kvm.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/hw/kvmclock.c b/hw/kvmclock.c index 39dffb2..e90d61f 100644 --- a/hw/kvmclock.c +++ b/hw/kvmclock.c @@ -66,9 +66,25 @@ static int kvmclock_post_load(void *opaque, int version_id) static void kvmclock_vm_state_change(void *opaque, int running, RunState state) { KVMClockState *s = opaque; + CPUState *penv = first_cpu; + int cap_clock_ctrl = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL); + int ret; if (running) { s->clock_valid = false; + + if (!cap_clock_ctrl) { + return; + } + for (penv = first_cpu; penv != NULL; penv = penv->next_cpu) { + ret = kvm_vcpu_ioctl(penv, KVM_KVMCLOCK_CTRL, 0); + if (ret) { + if (ret != -EINVAL) { + fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); + } + return; + } + } } } diff --git a/kvm/include/linux/kvm.h b/kvm/include/linux/kvm.h index e61104e..f566e7b 100644 --- a/kvm/include/linux/kvm.h +++ b/kvm/include/linux/kvm.h @@ -530,6 +530,7 @@ struct kvm_enable_cap { #ifdef __KVM_HAVE_XCRS #define KVM_CAP_XCRS 56 #endif +#define KVM_CAP_KVMCLOCK_CTRL 76 #ifdef KVM_CAP_IRQ_ROUTING @@ -726,6 +727,7 @@ struct kvm_clock_data { /* Available with KVM_CAP_XCRS */ #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) +#define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) -- 1.7.11.2