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@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
Roger Pau Monne committed 2012-08-01 12:46:47 +01:00
1 parent 108fdb564b
commit 7c3e7ad39c
2 files changed
+63 -2

No files matched your search

+56 -1
View File
@@ -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;
}
+7 -1
View File
@@ -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);
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.