Patchwork xen: Support guest reboots

login
register
mail settings
Submitter Anthony PERARD
Date April 16, 2012, 3:38 p.m.
Message ID <1334590729-6971-1-git-send-email-anthony.perard@citrix.com>
Download mbox | patch
Permalink /patch/152904/
State New
Headers show

Comments

Anthony PERARD - April 16, 2012, 3:38 p.m.
From: John V. Baboval <john.baboval@virtualcomputer.com>

Call xc_domain_shutdown with the reboot flag when the guest requests a reboot.

Signed-off-by: John V. Baboval <john.baboval@virtualcomputer.com>
Signed-off-by: Tom Goetz <tom.goetz@virtualcomputer.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

---
 hw/xen_common.h |    2 +-
 xen-all.c       |   18 +++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)
Stefano Stabellini - April 17, 2012, 2:32 p.m.
On Mon, 16 Apr 2012, Anthony PERARD wrote:
> From: John V. Baboval <john.baboval@virtualcomputer.com>
> 
> Call xc_domain_shutdown with the reboot flag when the guest requests a reboot.
> 
> Signed-off-by: John V. Baboval <john.baboval@virtualcomputer.com>
> Signed-off-by: Tom Goetz <tom.goetz@virtualcomputer.com>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>


Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Patch

diff --git a/hw/xen_common.h b/hw/xen_common.h
index 0409ac7..bb5a12f 100644
--- a/hw/xen_common.h
+++ b/hw/xen_common.h
@@ -133,6 +133,6 @@  static inline int xc_fd(xc_interface *xen_xc)
 }
 #endif
 
-void destroy_hvm_domain(void);
+void destroy_hvm_domain(bool reboot);
 
 #endif /* QEMU_HW_XEN_COMMON_H */
diff --git a/xen-all.c b/xen-all.c
index 3e6de41..4eb2270 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -832,7 +832,7 @@  static void cpu_handle_ioreq(void *opaque)
                     "data: %"PRIx64", count: %" FMT_ioreq_size ", size: %" FMT_ioreq_size "\n",
                     req->state, req->data_is_ptr, req->addr,
                     req->data, req->count, req->size);
-            destroy_hvm_domain();
+            destroy_hvm_domain(false);
             return;
         }
 
@@ -846,10 +846,11 @@  static void cpu_handle_ioreq(void *opaque)
          */
         if (runstate_is_running()) {
             if (qemu_shutdown_requested_get()) {
-                destroy_hvm_domain();
+                destroy_hvm_domain(false);
             }
             if (qemu_reset_requested_get()) {
                 qemu_system_reset(VMRESET_REPORT);
+                destroy_hvm_domain(true);
             }
         }
 
@@ -1121,7 +1122,7 @@  int xen_hvm_init(void)
     return 0;
 }
 
-void destroy_hvm_domain(void)
+void destroy_hvm_domain(bool reboot)
 {
     XenXC xc_handle;
     int sts;
@@ -1130,12 +1131,15 @@  void destroy_hvm_domain(void)
     if (xc_handle == XC_HANDLER_INITIAL_VALUE) {
         fprintf(stderr, "Cannot acquire xenctrl handle\n");
     } else {
-        sts = xc_domain_shutdown(xc_handle, xen_domid, SHUTDOWN_poweroff);
+        sts = xc_domain_shutdown(xc_handle, xen_domid,
+                                 reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff);
         if (sts != 0) {
-            fprintf(stderr, "? xc_domain_shutdown failed to issue poweroff, "
-                    "sts %d, %s\n", sts, strerror(errno));
+            fprintf(stderr, "xc_domain_shutdown failed to issue %s, "
+                    "sts %d, %s\n", reboot ? "reboot" : "poweroff",
+                    sts, strerror(errno));
         } else {
-            fprintf(stderr, "Issued domain %d poweroff\n", xen_domid);
+            fprintf(stderr, "Issued domain %d %s\n", xen_domid,
+                    reboot ? "reboot" : "poweroff");
         }
         xc_interface_close(xc_handle);
     }