[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: call hotplug scripts from xl for NetBSD
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxx> # Date 1343821607 -3600 # Node ID 84a78045e701ad743bcd369acbae6d0fb258a0f8 # Parent e20085770cb556940d41b8f6ef8f860787da88bf 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@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Acked-by: Christoph Egger <Christoph.Egger@xxxxxxx> Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- diff -r e20085770cb5 -r 84a78045e701 tools/libxl/libxl_netbsd.c --- a/tools/libxl/libxl_netbsd.c Wed Aug 01 12:46:47 2012 +0100 +++ b/tools/libxl/libxl_netbsd.c Wed Aug 01 12:46:47 2012 +0100 @@ -32,10 +32,65 @@ char *libxl__devid_to_localdev(libxl__gc } /* 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; } diff -r e20085770cb5 -r 84a78045e701 tools/xenbackendd/xenbackendd.c --- a/tools/xenbackendd/xenbackendd.c Wed Aug 01 12:46:47 2012 +0100 +++ b/tools/xenbackendd/xenbackendd.c Wed Aug 01 12:46:47 2012 +0100 @@ -33,6 +33,7 @@ #define DEVTYPE_UNKNOWN 0 #define DEVTYPE_VIF 1 #define DEVTYPE_VBD 2 +#define DISABLE_EXEC "libxl/disable_udev" #define DOMAIN_PATH "/local/domain/0" @@ -149,7 +150,7 @@ main(int argc, char * const argv[]) unsigned int num; char *s; int state; - char *sstate; + char *sstate, *sdisable; char *p; char buf[80]; int type; @@ -245,6 +246,10 @@ main(int argc, char * const argv[]) continue; } + sdisable = xs_read(xs, XBT_NULL, DISABLE_EXEC, 0); + if (sdisable) + goto next1; + if (strlen(vec[XS_WATCH_PATH]) < sizeof("state")) goto next1; @@ -314,6 +319,7 @@ next2: free(sstate); next1: + free(sdisable); free(vec); } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |