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

Re: [Xen-devel] request for the hotplug scripts

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>, Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] request for the hotplug scripts
From: Stefan Berger <stefanb@xxxxxxxxxx>
Date: Mon, 21 Nov 2005 15:32:41 -0500
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 21 Nov 2005 20:33:08 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <e1ac5b2e9ab00e684660ce527535572c@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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx

Keir Fraser <Keir.Fraser@xxxxxxxxxxxx> wrote on 11/21/2005 04:56:15 AM:

>
> On 20 Nov 2005, at 23:42, Stefan Berger wrote:
>
> >
> > Hello!
> >
> >   I have a question for the hotplug scripts that are used for the
> > network, block and soon the TPM interface. Would it be possible if an
> > environment variable 'REASON' was set that reflects whether a domain
> > was 'creat'ed or 'resume'd after a suspend. This can be very helpful
> > in initializing devices differently depending on the 'reason', such as
> > a 'reset' if it is 'created' and not doing a 'reset' if it was
> > resumed. I would try to add this 'REASON' variable myself - but where
> > for example is the 'ACTION' being set? I see XENBUS_PATH and
> > XENBUS_TYPE stem from xenbus_probe.c, but I could not find the origin
> > of the 'ACTION' variable.
>
> ACTION is a standard hotplug env var, set up by the generic hotplug
> subsystem. You would add a new var such as REASON in the same place
> that XENBUS_TYPE/PATH are set.


I added the REASON parameter to the function where the XENBUS_TYPE/PATH are set. It only differentiates between 'hibernation' (=suspend/resume) and 'creation' (create/destroy). However, this makes the REASON only correctly visible to the user domain and not domain 0 where I need to know about it. Could it be that the backend side of the driver as well as the xenbus on the backend side do not know that the corresponding frontend is changing state due to a suspend vs. a destroy?

experimental patch below.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>

-- Stefan


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
@@ -247,6 +247,11 @@ static int xenbus_hotplug_backend(struct
                             buffer, buffer_size, &length,
                             "XENBUS_PATH=%s", xdev->nodename);
 
+        add_hotplug_env_var(envp, num_envp, &i,
+                            buffer, buffer_size, &length,
+                            "REASON=%s", xdev->is_hibernating ? "hibernation"
+                                                              : "creation");
+        xdev->is_hibernating = 0;
         /* terminate, set to next free slot, shrink available space */
         envp[i] = NULL;
         envp = &envp[i];
@@ -789,8 +794,10 @@ static int suspend_dev(struct device *de
                 return 0;
         drv = to_xenbus_driver(dev->driver);
         xdev = container_of(dev, struct xenbus_device, dev);
-        if (drv->suspend)
+        xdev->is_hibernating = 1;
+        if (drv->suspend) {
                 err = drv->suspend(xdev);
+        }
         if (err)
                 printk(KERN_WARNING
                        "xenbus: suspend %s failed: %i\n", dev->bus_id, err);
@@ -818,8 +825,10 @@ static int resume_dev(struct device *dev
                 return err;
         }
 
-        if (drv->resume)
+        xdev->is_hibernating = 1;
+        if (drv->resume) {
                 err = drv->resume(xdev);
+        }
         if (err)
                 printk(KERN_WARNING
                        "xenbus: resume %s failed: %i\n", dev->bus_id, err);
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-xen/xenbus.h
===================================================================
--- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-xen/xenbus.h
+++ root/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-xen/xenbus.h
@@ -79,6 +79,7 @@ struct xenbus_device {
         struct xenbus_watch otherend_watch;
         struct device dev;
         int has_error;
+        int is_hibernating;
         void *data;
 };
 

>
>   -- Keir
>
>
> > Cheers!
> >  Stefan
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxxxxxxxx
> > http://lists.xensource.com/xen-devel
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>