[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 4/5] libxl: call hotplug scripts from xl for NetBSD
On 07/26/12 21:54, Roger Pau Monne wrote: > Add the missing NetBSD functions to call hotplug scripts, and disable > xenbackendd if libxl/disable_udev is not set. > > Cc: Christoph Egger <Christoph.Egger@xxxxxxx> > Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> > Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Acked-by: Christoph Egger <Christoph.Egger@xxxxxxx> > Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx> > --- > tools/libxl/libxl_netbsd.c | 57 > ++++++++++++++++++++++++++++++++++++++- > tools/xenbackendd/xenbackendd.c | 8 +++++- > 2 files changed, 63 insertions(+), 2 deletions(-) > > diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c > index 28cdf21..9587833 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; > } > diff --git a/tools/xenbackendd/xenbackendd.c b/tools/xenbackendd/xenbackendd.c > index 6b5bb8e..5381a2a 100644 > --- a/tools/xenbackendd/xenbackendd.c > +++ b/tools/xenbackendd/xenbackendd.c > @@ -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); > } > -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |