diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-05-11 18:59:06 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-05-11 18:59:06 +0100 |
commit | b71db3824995ca27b106a2d9fab1a24f93244a4f (patch) | |
tree | 4febbd9b3677745cfb28f740eec744bccd729c19 /tools/libxl/xl_cmdimpl.c | |
parent | 172af31d56bad27a570c3f4e2bd1e82083afa0b0 (diff) | |
download | xen-b71db3824995ca27b106a2d9fab1a24f93244a4f.tar.gz xen-b71db3824995ca27b106a2d9fab1a24f93244a4f.tar.bz2 xen-b71db3824995ca27b106a2d9fab1a24f93244a4f.zip |
libxl: convert console callback to libxl_asyncprogress_how
Remove the old console callback. (Its reentrancy properties were
troublesome: in principle, the event loop might be reentered during
the callback, and the libxl__domain_create_state swept out from under
the feet of the domain creation.)
As a side effect of the new code arrangements, the console callback
for non-bootloader-using PV guests now occurs near the end of domain
creation, in the same place as for HVM guests, rather than near the
start.
The new arrangements should in principle mean that by the time the
console is described as ready by the callback, the xenstore key is
indeed ready. So in the future the timeout might be removed from
the console client.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/xl_cmdimpl.c')
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 621aeaf9b3..b91a2d5911 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1457,16 +1457,18 @@ static int freemem(libxl_domain_build_info *b_info) return ERROR_NOMEM; } -static int autoconnect_console(libxl_ctx *ctx, uint32_t domid, void *priv) +static void autoconnect_console(libxl_ctx *ctx, libxl_event *ev, void *priv) { pid_t *pid = priv; + libxl_event_free(ctx, ev); + *pid = fork(); if (*pid < 0) { perror("unable to fork xenconsole"); - return ERROR_FAIL; + return; } else if (*pid > 0) - return 0; + return; postfork(); @@ -1533,7 +1535,7 @@ static int create_domain(struct domain_create *dom_info) int config_len = 0; int restore_fd = -1; int status = 0; - libxl_console_ready cb; + const libxl_asyncprogress_how *autoconnect_console_how; pid_t child_console_pid = -1; struct save_file_header hdr; @@ -1687,24 +1689,27 @@ start: goto error_out; } + libxl_asyncprogress_how autoconnect_console_how_buf; if ( dom_info->console_autoconnect ) { - cb = autoconnect_console; + autoconnect_console_how_buf.callback = autoconnect_console; + autoconnect_console_how_buf.for_callback = &child_console_pid; + autoconnect_console_how = &autoconnect_console_how_buf; }else{ - cb = NULL; + autoconnect_console_how = 0; } if ( restore_file ) { ret = libxl_domain_create_restore(ctx, &d_config, - cb, &child_console_pid, - &domid, restore_fd, 0); + &domid, restore_fd, + 0, autoconnect_console_how); /* * On subsequent reboot etc we should create the domain, not * restore/migrate-receive it again. */ restore_file = NULL; }else{ - ret = libxl_domain_create_new(ctx, &d_config, - cb, &child_console_pid, &domid, 0); + ret = libxl_domain_create_new(ctx, &d_config, &domid, + 0, autoconnect_console_how); } if ( ret ) goto error_out; |