aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-08-03 09:54:06 +0100
committerIan Campbell <ian.campbell@citrix.com>2012-08-03 09:54:06 +0100
commitf9e84f5c78248b39f2ac885de6efa8f025ccfa50 (patch)
tree282b2cebaaf3b80df1269001c535b381b5b96aba
parent01580ccdb2063766ad4570ac1f16115b0f94007e (diff)
downloadxen-f9e84f5c78248b39f2ac885de6efa8f025ccfa50.tar.gz
xen-f9e84f5c78248b39f2ac885de6efa8f025ccfa50.tar.bz2
xen-f9e84f5c78248b39f2ac885de6efa8f025ccfa50.zip
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@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
-rw-r--r--tools/libxl/libxl_linux.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 9ae0b4b88f..1fed3cd521 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -80,22 +80,14 @@ char *libxl__devid_to_localdev(libxl__gc *gc, int devid)
/* 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 *gc, libxl__device *dev,
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 *gc, libxl__device *dev,
goto error;
}
- *env = get_hotplug_env(gc, dev);
+ *env = get_hotplug_env(gc, script, dev);
if (!*env) {
rc = ERROR_FAIL;
goto error;