From: Stefan Berger Subject: [PATCH][REPOST] Additional states for Xenbus: Suspend/Resume Date: Fri, 20 Jan 2006 00:15:31 -0500 Message-ID: <1137734131.31494.11.camel@jlfb-2.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-6RqxrFaBwenqUpEiWeQC" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-6RqxrFaBwenqUpEiWeQC Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello! I have previously posted a version of this patch. The problem that I have encountered with driver backends was that they were unaware of the reason why a frontend was disappearing or why it was created. The following patch allows the backend to see whether a frontend is going into suspend mode and disappearing vs. disappearing due to domain destruction or being created due to a resume vs a domain creation. I have separated out the code that actually uses this awareness in the TPM driver for another patch. Backend drivers can now be written such that it allows hotplug scripts to react differently depending on this reason. Please let me know about comments regarding this patch. Signed-off-by: Stefan Berger --=-6RqxrFaBwenqUpEiWeQC Content-Disposition: attachment; filename=xenbus-susres-state.diff Content-Type: text/x-patch; name=xenbus-susres-state.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -803,6 +803,7 @@ static int suspend_dev(struct device *de if (err) printk(KERN_WARNING "xenbus: suspend %s failed: %i\n", dev->bus_id, err); + xenbus_switch_state(xdev, XBT_NULL, XenbusStateSuspend); return 0; } @@ -835,6 +836,7 @@ static int resume_dev(struct device *dev return err; } + xenbus_switch_state(xdev, XBT_NULL, XenbusStateResume); if (drv->resume) err = drv->resume(xdev); if (err) Index: root/xen-unstable.hg/xen/include/public/io/xenbus.h =================================================================== --- root.orig/xen-unstable.hg/xen/include/public/io/xenbus.h +++ root/xen-unstable.hg/xen/include/public/io/xenbus.h @@ -26,7 +26,9 @@ typedef enum XenbusStateConnected = 4, XenbusStateClosing = 5, /* The device is being closed due to an error or an unplug event. */ - XenbusStateClosed = 6 + XenbusStateClosed = 6, + XenbusStateSuspend = 7, + XenbusStateResume = 8 } XenbusState; Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -254,6 +254,8 @@ static void frontend_changed(struct xenb switch (frontend_state) { case XenbusStateInitialising: case XenbusStateConnected: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateInitialised: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -268,6 +268,8 @@ static void backend_changed(struct xenbu case XenbusStateInitWait: case XenbusStateInitialised: case XenbusStateClosed: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c @@ -205,6 +205,8 @@ static void frontend_changed(struct xenb switch (frontend_state) { case XenbusStateInitialising: case XenbusStateInitialised: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -402,6 +402,8 @@ static void backend_changed(struct xenbu case XenbusStateConnected: case XenbusStateUnknown: case XenbusStateClosed: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateClosing: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -320,6 +320,8 @@ static void backend_changed(struct xenbu case XenbusStateInitWait: case XenbusStateInitialised: case XenbusStateUnknown: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -166,6 +166,8 @@ static void frontend_changed(struct xenb switch (frontend_state) { case XenbusStateInitialising: case XenbusStateConnected: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateInitialised: --=-6RqxrFaBwenqUpEiWeQC Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-6RqxrFaBwenqUpEiWeQC--