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/
Home Products Support Community News


[Xen-devel] [PATCH 10/11] xen kexec: reset device state to Initializing

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 10/11] xen kexec: reset device state to Initializing during reboot
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Thu, 28 Jul 2011 15:23:10 +0200
Delivery-date: Thu, 28 Jul 2011 06:38:10 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1311859435; l=2241; s=domk; d=aepfle.de; h=References:Subject:To:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=T9WiykDrpE0/vmT+a0pKHheimbQ=; b=NkZC25txVv3yMHZB0b2x39zWqaAGOq0GPKi57A2afraLlwW3LrKk9S3gxBvoc5xQ5Rw YQVf+T/TkkrgEyHgUKTV83acXRsjOs+YIu0PcE5rlpK96JCCj61/codPlatsgpDPf2NuY VqgUwVUSb5t2J4Uk9qDBCfedc44O65oyJgU=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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: <20110728132300.248098023@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.48-16.4
During kexec all devices will be shutdown, the backend drivers enter the
Closed state. But in this state the kexec kernel can not connect to the
backend because it expects the devices in InitWait state.
After triggering the Closing event, trigger also the Initializing event
and wait until the backend has changed its state. Without this waiting
the kexec kernel may find a device where a state change from Closed to
InitWait is still in progress.

 unregister the watch on the /local/domain/0/backend/<dev>/<domid>/0/state
 node to avoid memory corruption in the kexec kernel

 use kexec_is_loaded() function

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

 drivers/xen/xenbus/xenbus_probe.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

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
@@ -46,6 +46,7 @@
 #include <linux/mutex.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/kexec.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
@@ -192,8 +193,19 @@ void xenbus_otherend_changed(struct xenb
         * work that can fail e.g., when the rootfs is gone.
        if (system_state > SYSTEM_RUNNING) {
-               if (ignore_on_shutdown && (state == XenbusStateClosing))
-                       xenbus_frontend_closed(dev);
+               if (ignore_on_shutdown) {
+                       switch (state) {
+                       case XenbusStateClosing:
+                               xenbus_frontend_closed(dev);
+                               break;
+                       case XenbusStateInitialising:
+                       case XenbusStateInitWait:
+                               complete(&dev->down);
+                               break;
+                       default:
+                               break;
+                       }
+               }
@@ -284,6 +296,15 @@ void xenbus_dev_shutdown(struct device *
        if (!timeout)
                printk(KERN_INFO "%s: %s timeout closing device\n",
                       __func__, dev->nodename);
+       if (system_state > SYSTEM_RUNNING && kexec_is_loaded()) {
+               xenbus_switch_state(dev, XenbusStateInitialising);
+               timeout = wait_for_completion_timeout(&dev->down, timeout);
+               if (!timeout)
+                       printk(KERN_INFO "%s: %s timeout initializing device\n",
+                              __func__, dev->nodename);
+               free_otherend_watch(dev);
+       }

Xen-devel mailing list

<Prev in Thread] Current Thread [Next in Thread>