[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 11 of 13 RFC] libxl: add hotplug script calling for NetBSD
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1326728652 -3600 # Node ID d0eb0f3a305fbcdb5fca853e7c674b9b59719e4a # Parent 70359826f535461fedbbd86c18c772117030bc91 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 70359826f535 -r d0eb0f3a305f 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 Mon Jan 16 16:44:12 2012 +0100 @@ -31,5 +31,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 |