Commit ddd63359 authored by Roger Pau Monne's avatar Roger Pau Monne

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: default avatarRoger Pau Monne <roger.pau@citrix.com>
Acked-by: default avatarIan Jackson <ian.jackson@eu.citrix.com>
Acked-by: default avatarChristoph Egger <Christoph.Egger@amd.com>
Committed-by: default avatarIan Campbell <ian.campbell@citrix.com>
parent 1f9a62e8
......@@ -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;
}
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment