[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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




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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.