[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: abolish libxl_ctx_postfork
# HG changeset patch # User Ian Jackson <ian.jackson@xxxxxxxxxxxxx> # Date 1334150057 -3600 # Node ID 24bb3350102c130985c2f04849c64446c2c1144f # Parent 8a99e1944bd09c690272cbda9eac346fcbdefde8 libxl: abolish libxl_ctx_postfork libxl's task has become too complicated (particularly in the presence of both forking and multithreading) to support reuse of the same libxl_ctx after fork. So abolish libxl_ctx_fork. xl instead simply initialises a new libxl_ctx. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- diff -r 8a99e1944bd0 -r 24bb3350102c tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 11 14:14:16 2012 +0100 +++ b/tools/libxl/libxl.h Wed Apr 11 14:14:17 2012 +0100 @@ -461,7 +461,6 @@ int libxl_ctx_alloc(libxl_ctx **pctx, in unsigned flags /* none currently defined */, xentoollog_logger *lg); int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */); -int libxl_ctx_postfork(libxl_ctx *ctx); /* domain related functions */ typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv); diff -r 8a99e1944bd0 -r 24bb3350102c tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Wed Apr 11 14:14:16 2012 +0100 +++ b/tools/libxl/libxl_utils.c Wed Apr 11 14:14:17 2012 +0100 @@ -365,13 +365,6 @@ READ_WRITE_EXACTLY(read, 1, /* */) READ_WRITE_EXACTLY(write, 0, const) -int libxl_ctx_postfork(libxl_ctx *ctx) { - if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh); - ctx->xsh = xs_daemon_open(); - if (!ctx->xsh) return ERROR_FAIL; - return 0; -} - pid_t libxl_fork(libxl_ctx *ctx) { pid_t pid; diff -r 8a99e1944bd0 -r 24bb3350102c tools/libxl/xl.c --- a/tools/libxl/xl.c Wed Apr 11 14:14:16 2012 +0100 +++ b/tools/libxl/xl.c Wed Apr 11 14:14:17 2012 +0100 @@ -94,6 +94,14 @@ static void parse_global_config(const ch xlu_cfg_destroy(config); } +void postfork(void) +{ + if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, (xentoollog_logger*)logger)) { + fprintf(stderr, "cannot reinit xl context after fork\n"); + exit(-1); + } +} + int main(int argc, char **argv) { int opt = 0; diff -r 8a99e1944bd0 -r 24bb3350102c tools/libxl/xl.h --- a/tools/libxl/xl.h Wed Apr 11 14:14:16 2012 +0100 +++ b/tools/libxl/xl.h Wed Apr 11 14:14:17 2012 +0100 @@ -105,6 +105,7 @@ struct cmd_spec *cmdtable_lookup(const c extern libxl_ctx *ctx; extern xentoollog_logger_stdiostream *logger; +void postfork(void); /* global options */ extern int autoballoon; diff -r 8a99e1944bd0 -r 24bb3350102c tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 11 14:14:16 2012 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 11 14:14:17 2012 +0100 @@ -1441,7 +1441,7 @@ static int autoconnect_console(libxl_ctx } else if (*pid > 0) return 0; - libxl_ctx_postfork(ctx); + postfork(); sleep(1); libxl_primary_console_exec(ctx, domid); @@ -1728,11 +1728,7 @@ start: goto out; } - rc = libxl_ctx_postfork(ctx); - if (rc) { - LOG("failed to reinitialise context after fork"); - exit(-1); - } + postfork(); if (asprintf(&name, "xl-%s", d_config.c_info.name) < 0) { LOG("Failed to allocate memory in asprintf"); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |