WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xen/pv-on-hvm kexec: add xs_reset to shutdown watche

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xen/pv-on-hvm kexec: add xs_reset to shutdown watches from old kernel
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Fri, 12 Aug 2011 08:42:23 +0200
Delivery-date: Thu, 11 Aug 2011 23:44:15 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1313131406; l=4222; s=domk; d=aepfle.de; h=In-Reply-To:Content-Type:MIME-Version:References:Subject:To:From: Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=EVvUUKhaTJ0F5Za1rTbPiMYlacA=; b=B7Hxe+1q0352HdVSig2CEHU8iIeiUNqctrOB8XKxKTprUxnFgHw0V1XaRqsAEhQgYj5 /iFouOkitOmRsFm1jmwYd1ZhcsXisyhJko/pazg6b6QZ+666nV9rg68gbKTd9huOmPuaI utB9n5CCtd1OVG+/vqZJRpvoK6BK4Nuy1/4=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <31687c9a9e3edfae7cf2.1313130830@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <31687c9a9e3edfae7cf2.1313130830@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.21.rev5535 (2011-07-01)

Add new xs_reset function to shutdown watches from old kernel after
kexec boot.  The old kernel does not unregister all watches in the
shutdown path.  They are still active, the double registration can not
be detected by the new kernel.  When the watches fire, unexpected events
will arrive and the xenwatch thread will crash (jumps to NULL).  An
orderly reboot of a hvm guest will destroy the entire guest with all its
resources (including the watches) before it is rebuilt from scratch, so
the missing unregister is not an issue in that case.

With this change the xenstored is instructed to wipe all active watches
for the guest.  However, a patch for xenstored is required so that it
accepts the XS_RESET request from a guest.

http://lists.xensource.com/archives/html/xen-devel/2011-08/ <tbd.html>

Also sync the XS_* enum with xen-unstable version.


v3:
  - use XS_RESET instead of XS_INTRODUCE
  - sync XS_* enum from xen-unstable

v2:
  - move all code which deals with XS_INTRODUCE into xs_introduce()
    (based on feedback from Ian Campbell)
  - remove casts from kvec assignment

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

---
 drivers/xen/xenbus/xenbus_comms.h  |    2 +-
 drivers/xen/xenbus/xenbus_probe.c  |    2 +-
 drivers/xen/xenbus/xenbus_xs.c     |   29 ++++++++++++++++++++++++++++-
 include/xen/interface/io/xs_wire.h |    6 +++++-
 4 files changed, 35 insertions(+), 4 deletions(-)

Index: linux-3.0/drivers/xen/xenbus/xenbus_comms.h
===================================================================
--- linux-3.0.orig/drivers/xen/xenbus/xenbus_comms.h
+++ linux-3.0/drivers/xen/xenbus/xenbus_comms.h
@@ -31,7 +31,7 @@
 #ifndef _XENBUS_COMMS_H
 #define _XENBUS_COMMS_H
 
-int xs_init(void);
+int xs_init(unsigned long xen_store_mfn);
 int xb_init_comms(void);
 
 /* Low level routines. */
Index: linux-3.0/drivers/xen/xenbus/xenbus_probe.c
===================================================================
--- linux-3.0.orig/drivers/xen/xenbus/xenbus_probe.c
+++ linux-3.0/drivers/xen/xenbus/xenbus_probe.c
@@ -757,7 +757,7 @@ static int __init xenbus_init(void)
        }
 
        /* Initialize the interface to xenstore. */
-       err = xs_init();
+       err = xs_init(xen_store_mfn);
        if (err) {
                printk(KERN_WARNING
                       "XENBUS: Error initializing xenstore comms: %i\n", err);
Index: linux-3.0/drivers/xen/xenbus/xenbus_xs.c
===================================================================
--- linux-3.0.orig/drivers/xen/xenbus/xenbus_xs.c
+++ linux-3.0/drivers/xen/xenbus/xenbus_xs.c
@@ -620,6 +620,29 @@ static struct xenbus_watch *find_watch(c
        return NULL;
 }
 
+static void xs_reset(unsigned long xen_store_mfn)
+{
+       struct kvec iov[3];
+       char domid[12], mfn[24], port[24];
+       int err;
+
+       snprintf(domid, sizeof(domid), "%u", DOMID_SELF);
+       snprintf(mfn, sizeof(mfn), "%lu", xen_store_mfn);
+       snprintf(port, sizeof(port), "%d", xen_store_evtchn);
+
+       iov[0].iov_base = domid;
+       iov[0].iov_len = strlen(domid) + 1;
+       iov[1].iov_base = mfn;
+       iov[1].iov_len = strlen(mfn) + 1;
+       iov[2].iov_base = port;
+       iov[2].iov_len = strlen(port) + 1;
+
+       err = xs_error(xs_talkv(XBT_NIL, XS_RESET, iov,
+                                ARRAY_SIZE(iov), NULL));
+       if (err)
+               printk(KERN_WARNING "xs_reset failed: %d\n", err);
+}
+
 /* Register callback to watch this node. */
 int register_xenbus_watch(struct xenbus_watch *watch)
 {
@@ -867,7 +890,7 @@ static int xenbus_thread(void *unused)
        return 0;
 }
 
-int xs_init(void)
+int xs_init(unsigned long xen_store_mfn)
 {
        int err;
        struct task_struct *task;
@@ -897,5 +920,9 @@ int xs_init(void)
        if (IS_ERR(task))
                return PTR_ERR(task);
 
+       /* shutdown watches for kexec boot */
+       if (xen_hvm_domain())
+               xs_reset(xen_store_mfn);
+
        return 0;
 }
Index: linux-3.0/include/xen/interface/io/xs_wire.h
===================================================================
--- linux-3.0.orig/include/xen/interface/io/xs_wire.h
+++ linux-3.0/include/xen/interface/io/xs_wire.h
@@ -26,7 +26,11 @@ enum xsd_sockmsg_type
     XS_SET_PERMS,
     XS_WATCH_EVENT,
     XS_ERROR,
-    XS_IS_DOMAIN_INTRODUCED
+    XS_IS_DOMAIN_INTRODUCED,
+    XS_RESUME,
+    XS_SET_TARGET,
+    XS_RESTRICT,
+    XS_RESET
 };
 
 #define XS_WRITE_NONE "NONE"

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel