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

[Xen-changelog] [xen-unstable] libxl: only read script once in libxl__hotplug_*


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Tue, 07 Aug 2012 20:33:11 +0000
  • Delivery-date: Tue, 07 Aug 2012 20:33:25 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1343984046 -3600
# Node ID 428014e272914d21cb2fc63a651a556543242a7d
# Parent  a3cfa3666857ada79c3fad002a41e382568332b6
libxl: only read script once in libxl__hotplug_*

instead of duplicating the error handling etc in get_hotplug_env just pass the
script already read by the caller down.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r a3cfa3666857 -r 428014e27291 tools/libxl/libxl_linux.c
--- a/tools/libxl/libxl_linux.c Fri Aug 03 09:54:05 2012 +0100
+++ b/tools/libxl/libxl_linux.c Fri Aug 03 09:54:06 2012 +0100
@@ -80,22 +80,14 @@ char *libxl__devid_to_localdev(libxl__gc
 
 /* Hotplug scripts helpers */
 
-static char **get_hotplug_env(libxl__gc *gc, libxl__device *dev)
+static char **get_hotplug_env(libxl__gc *gc,
+                              char *script, libxl__device *dev)
 {
-    char *be_path = libxl__device_backend_path(gc, dev);
-    char *script;
     const char *type = libxl__device_kind_to_string(dev->backend_kind);
     char **env;
     int nr = 0;
     libxl_nic_type nictype;
 
-    script = libxl__xs_read(gc, XBT_NULL,
-                            GCSPRINTF("%s/%s", be_path, "script"));
-    if (!script) {
-        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
-        return NULL;
-    }
-
     const int arraysize = 13;
     GCNEW_ARRAY(env, arraysize);
     env[nr++] = "script";
@@ -170,7 +162,7 @@ static int libxl__hotplug_nic(libxl__gc 
         goto out;
     }
 
-    *env = get_hotplug_env(gc, dev);
+    *env = get_hotplug_env(gc, script, dev);
     if (!env) {
         rc = ERROR_FAIL;
         goto out;
@@ -212,7 +204,7 @@ static int libxl__hotplug_disk(libxl__gc
         goto error;
     }
 
-    *env = get_hotplug_env(gc, dev);
+    *env = get_hotplug_env(gc, script, dev);
     if (!*env) {
         rc = ERROR_FAIL;
         goto error;

_______________________________________________
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®.