diff options
author | Roger Pau Monne <roger.pau@citrix.com> | 2012-08-01 12:46:47 +0100 |
---|---|---|
committer | Roger Pau Monne <roger.pau@citrix.com> | 2012-08-01 12:46:47 +0100 |
commit | 7c3e7ad39ce2c8d1c07cd63e6983d7581bad1f2a (patch) | |
tree | d87cb33fc228c200726b8152ae021a4bc9440360 /tools/libxl/libxl_netbsd.c | |
parent | 108fdb564b06e58087a3ccfdad5996a878d39b9a (diff) | |
download | xen-7c3e7ad39ce2c8d1c07cd63e6983d7581bad1f2a.tar.gz xen-7c3e7ad39ce2c8d1c07cd63e6983d7581bad1f2a.tar.bz2 xen-7c3e7ad39ce2c8d1c07cd63e6983d7581bad1f2a.zip |
libxl: call hotplug scripts from xl for NetBSD
Add the missing NetBSD functions to call hotplug scripts, and disable
xenbackendd if libxl/disable_udev is not set.
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_netbsd.c')
-rw-r--r-- | tools/libxl/libxl_netbsd.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c index 28cdf21d73..9587833452 100644 --- a/tools/libxl/libxl_netbsd.c +++ b/tools/libxl/libxl_netbsd.c @@ -32,10 +32,65 @@ char *libxl__devid_to_localdev(libxl__gc *gc, int devid) } /* Hotplug scripts caller functions */ +static int libxl__hotplug(libxl__gc *gc, libxl__device *dev, char ***args, + libxl__device_action action) +{ + char *be_path = libxl__device_backend_path(gc, dev); + char *script; + int nr = 0, rc = 0, arraysize = 4; + + 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); + rc = ERROR_FAIL; + goto out; + } + + GCNEW_ARRAY(*args, arraysize); + (*args)[nr++] = script; + (*args)[nr++] = be_path; + (*args)[nr++] = GCSPRINTF("%d", action == DEVICE_CONNECT ? + XenbusStateInitWait : XenbusStateClosed); + (*args)[nr++] = NULL; + assert(nr == arraysize); + +out: + return rc; +} + int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, char ***args, char ***env, libxl__device_action action, int num_exec) { - return 0; + char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH); + int rc; + + /* Check if we have to run hotplug scripts */ + if (!disable_udev || num_exec > 0) { + rc = 0; + goto out; + } + + switch (dev->backend_kind) { + case LIBXL__DEVICE_KIND_VBD: + case LIBXL__DEVICE_KIND_VIF: + if (num_exec != 0) { + rc = 0; + goto out; + } + rc = libxl__hotplug(gc, dev, args, action); + if (!rc) rc = 1; + break; + default: + /* If no need to execute any hotplug scripts, + * call the callback manually + */ + rc = 0; + break; + } + +out: + return rc; } |