From: Ian Campbell Date: Tue, 27 Sep 2011 17:03:11 +0000 (+0100) Subject: libxl: make libxl__wait_for_device_model use libxl__spawn_starrting directly X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~9859 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9baf395529416d54844fcc7bff0b9b9445c7d023;p=xen.git libxl: make libxl__wait_for_device_model use libxl__spawn_starrting directly Instead of indirecting via libxl_device_model_starting. This fixes a segmentation fault using stubdomains where starting->for_spawn is (validly) NULL because starting a stubdom doesn't need to spawn a process. Most callers of libxl__wait_for_device_model already pass NULL for this variable (because they are not on the starting path) so on libxl__confirm_device_model_startup needs to change. Reported-by: Jeremy Fitzhardinge Signed-off-by: Ian Campbell Acked-by: Ian Jackson Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 1b9e984e39..7931b11abc 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -522,7 +522,7 @@ out: int libxl__wait_for_device_model(libxl__gc *gc, uint32_t domid, char *state, - libxl__device_model_starting *starting, + libxl__spawn_starting *spawning, int (*check_callback)(libxl__gc *gc, uint32_t domid, const char *state, @@ -552,12 +552,12 @@ int libxl__wait_for_device_model(libxl__gc *gc, tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT; tv.tv_usec = 0; nfds = xs_fileno(xsh) + 1; - if (starting && starting->for_spawn->fd > xs_fileno(xsh)) - nfds = starting->for_spawn->fd + 1; + if (spawning && spawning->fd > xs_fileno(xsh)) + nfds = spawning->fd + 1; while (rc > 0 || (!rc && tv.tv_sec > 0)) { - if ( starting ) { - rc = libxl__spawn_check(gc, starting->for_spawn); + if ( spawning ) { + rc = libxl__spawn_check(gc, spawning); if ( rc ) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model died during startup"); @@ -586,8 +586,8 @@ again: free(p); FD_ZERO(&rfds); FD_SET(xs_fileno(xsh), &rfds); - if (starting) - FD_SET(starting->for_spawn->fd, &rfds); + if (spawning) + FD_SET(spawning->fd, &rfds); rc = select(nfds, &rfds, NULL, NULL, &tv); if (rc > 0) { if (FD_ISSET(xs_fileno(xsh), &rfds)) { @@ -597,9 +597,9 @@ again: else goto again; } - if (starting && FD_ISSET(starting->for_spawn->fd, &rfds)) { + if (spawning && FD_ISSET(spawning->fd, &rfds)) { unsigned char dummy; - if (read(starting->for_spawn->fd, &dummy, sizeof(dummy)) != 1) + if (read(spawning->fd, &dummy, sizeof(dummy)) != 1) LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG, "failed to read spawn status pipe"); } diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index e854a50462..254f016889 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -920,7 +920,7 @@ int libxl__confirm_device_model_startup(libxl__gc *gc, { int detach; int problem = libxl__wait_for_device_model(gc, starting->domid, "running", - starting, NULL, NULL); + starting->for_spawn, NULL, NULL); detach = detach_device_model(gc, starting); return problem ? problem : detach; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b73b6c46cd..0e1aac8fa0 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -283,7 +283,7 @@ _hidden int libxl__confirm_device_model_startup(libxl__gc *gc, _hidden int libxl__detach_device_model(libxl__gc *gc, libxl__device_model_starting *starting); _hidden int libxl__wait_for_device_model(libxl__gc *gc, uint32_t domid, char *state, - libxl__device_model_starting *starting, + libxl__spawn_starting *spawning, int (*check_callback)(libxl__gc *gc, uint32_t domid, const char *state,