Patchwork [V4] Guest stop notification

login
register
mail settings
Submitter Eric B Munson
Date Dec. 5, 2011, 8:18 p.m.
Message ID <1323116314-17843-1-git-send-email-emunson@mgebm.net>
Download mbox | patch
Permalink /patch/129416/
State New
Headers show

Comments

Eric B Munson - Dec. 5, 2011, 8:18 p.m.
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 <emunson@mgebm.net>
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: ryanh@linux.vnet.ibm.com
Cc: aliguori@us.ibm.com
Cc: kvm@vger.kernel.org

---
Changes from V3:
 Collapse new state change notification function into existsing function.
 Correct whitespace issues
 Change ioctl name to KVMCLOCK_GUEST_PAUSED
 Use for loop to iterate vpcu's

Changes from V2:
 Move ioctl into hw/kvmclock.c so as other arches can use it as it is
implemented

Changes from V1:
 Remove unnecessary encapsulating function

 hw/kvmclock.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index 5388bc4..fa11dd7 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -16,6 +16,7 @@ 
 #include "sysbus.h"
 #include "kvm.h"
 #include "kvmclock.h"
+#include "cpu-all.h"
 
 #include <linux/kvm.h>
 #include <linux/kvm_para.h>
@@ -62,10 +63,24 @@  static int kvmclock_post_load(void *opaque, int version_id)
 static void kvmclock_vm_state_change(void *opaque, int running,
                                      RunState state)
 {
+    int ret;
+    CPUState *penv = first_cpu;
     KVMClockState *s = opaque;
 
     if (running) {
         s->clock_valid = false;
+
+        for (penv = first_cpu; penv != NULL; penv = penv->next_cpu) {
+            ret = kvm_vcpu_ioctl(penv, KVMCLOCK_GUEST_PAUSED, 0);
+            if (ret) {
+                if (ret != -EINVAL) {
+                    fprintf(stderr,
+                            "kvmclock_vm_state_change: %s\n",
+                            strerror(-ret));
+                }
+                return;
+            }
+        }
     }
 }