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

[Xen-changelog] [linux-2.6.18-xen] netback: read hotplug script once at start of day


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
  • Date: Tue, 02 Jun 2015 14:22:02 +0000
  • Delivery-date: Tue, 02 Jun 2015 14:22:11 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1433253806 -7200
# Node ID 43dfca4e7fa04cfd90a8c195d592c7ab43d54b2b
# Parent  afe2ac5137b8c247dea886c732d09791fe44ac91
netback: read hotplug script once at start of day

When we come to tear things down in netback_remove() and generate the
uevent it is possible that the xenstore directory has already been
removed (details below).

In such cases netback_uevent() won't be able to read the hotplug
script and will write a xenstore error node.

A recent change to the hypervisor exposed this race such that we now
sometimes lose it (where apparently we didn't ever before).

Instead read the hotplug script configuration during setup and use it
for the lifetime of the backend device.

The apparently more obvious fix of moving the transition to
state=Closed in netback_remove() to after the uevent does not work
because it is possible that we are already in state=Closed (in
reaction to the guest having disconnected as it shutdown). Being
already in Closed means the toolstack is at liberty to start tearing
down the xenstore directories. In principal it might be possible to
arrange to unregister the device sooner (e.g on transition to Closing)
such that xenstore would still be there but this state machine is
fragile and prone to anger...

A modern Xen system only relies on the hotplug uevent for driver
domains, when the backend is in the same domain as the toolstack it
will run the necessary setup/teardown directly in the correct sequence
wrt xenstore changes.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Committed-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r afe2ac5137b8 -r 43dfca4e7fa0 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h      Tue Mar 10 14:38:39 2015 +0100
+++ b/drivers/xen/netback/common.h      Tue Jun 02 16:03:26 2015 +0200
@@ -147,6 +147,8 @@ struct backend_info {
        struct xenbus_watch hotplug_status_watch;
        int have_hotplug_status_watch:1;
 
+       const char *hotplug_script;
+
        /* State relating to the netback accelerator */
        void *netback_accel_priv;
        /* The accelerator that this backend is currently using */
diff -r afe2ac5137b8 -r 43dfca4e7fa0 drivers/xen/netback/xenbus.c
--- a/drivers/xen/netback/xenbus.c      Tue Mar 10 14:38:39 2015 +0100
+++ b/drivers/xen/netback/xenbus.c      Tue Jun 02 16:03:26 2015 +0200
@@ -42,6 +42,7 @@ static int netback_remove(struct xenbus_
        netback_remove_accelerators(be, dev);
 
        netback_disconnect(&dev->dev);
+       kfree(be->hotplug_script);
        kfree(be);
        dev->dev.driver_data = NULL;
        return 0;
@@ -71,6 +72,7 @@ static int netback_probe(struct xenbus_d
        struct xenbus_transaction xbt;
        int err;
        int sg;
+       const char *script;
        struct backend_info *be = kzalloc(sizeof(struct backend_info),
                                          GFP_KERNEL);
        if (!be) {
@@ -133,6 +135,15 @@ static int netback_probe(struct xenbus_d
 
        netback_probe_accelerators(be, dev);
 
+       script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL);
+       if (IS_ERR(script)) {
+               err = PTR_ERR(script);
+               xenbus_dev_fatal(dev, err, "reading script");
+               goto fail;
+       }
+
+       be->hotplug_script = script;
+
        err = xenbus_switch_state(dev, XenbusStateInitWait);
        if (err)
                goto fail;
@@ -165,22 +176,11 @@ static int netback_uevent(struct xenbus_
        struct backend_info *be = xdev->dev.driver_data;
        netif_t *netif = be->netif;
        int i = 0, length = 0;
-       char *val;
 
        DPRINTK("netback_uevent");
 
-       val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
-       if (IS_ERR(val)) {
-               int err = PTR_ERR(val);
-               xenbus_dev_fatal(xdev, err, "reading script");
-               return err;
-       }
-       else {
-               add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
-                              &length, "script=%s", val);
-               kfree(val);
-       }
-
+       add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+                      "script=%s", be->hotplug_script);
        add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
                       "vif=%s", netif->dev->name);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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