[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 12 of 29 RFC] libxl: add hotplug script calling for NetBSD
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1328177424 -3600 # Node ID 6c2690921fba580dd7dd836da3be484dee049be0 # Parent 5e488e0c02b8c769e94c2f734c0c209739d9cb01 libxl: add hotplug script calling for NetBSD Hotplug scripts in NetBSD are in charge of adding the virtual DomU network interface to the desired bridge and also mount the vnd device to use virtual images as block devices. The following scripts are currently implemented: * block: executed when a vbd is used, is in charge mounting the virtual image to the vnd device and setting the state of xenstore to 4 (connected). When using a physical partition, the script only sets the state to 4. * vif-bridge: adds the virtual DomU interface to the desired bridge. * vif-ip: configures the physical network interface assigned to the DomU. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> diff -r 5e488e0c02b8 -r 6c2690921fba tools/libxl/libxl_netbsd.c --- a/tools/libxl/libxl_netbsd.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_netbsd.c Thu Feb 02 11:10:24 2012 +0100 @@ -30,5 +30,50 @@ int libxl__try_phy_backend(mode_t st_mod int libxl__device_hotplug(libxl__gc *gc, libxl__device *dev, libxl__hotplug_action action) { - return 0; + libxl_ctx *ctx = libxl__gc_owner(gc); + char *be_path = libxl__device_backend_path(gc, dev); + char *script, *what; + char **args; + int status, nr = 0; + int rc = -1; + flexarray_t *f_args; + + if (dev->backend_kind != LIBXL__DEVICE_KIND_VIF && + dev->backend_kind != LIBXL__DEVICE_KIND_VBD) + return 0; + + script = libxl__xs_read(gc, XBT_NULL, + libxl__sprintf(gc, "%s/%s", be_path, "script")); + if (!script) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to read script from %s", + be_path); + return -1; + } + + f_args = flexarray_make(4, 1); + if (!f_args) + return -1; + + flexarray_set(f_args, nr++, script); + flexarray_set(f_args, nr++, be_path); + flexarray_set(f_args, nr++, libxl__sprintf(gc, "%d", action)); + flexarray_set(f_args, nr++, NULL); + + args = (char **) flexarray_contents(f_args); + + what = libxl__sprintf(gc, "%s %s", args[0], + action == CONNECT ? "connect" : "disconnect"); + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, + "Calling hotplug script: %s %s %s", + args[0], args[1], args[2]); + status = libxl__forkexec(gc, -1, -1, -1, args[0], args, NULL, what); + if (status) { + rc = -1; + goto out; + } + rc = 0; + +out: + free(args); + return rc; } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |