# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317142991 -3600
# Node ID bfa65eb40b2a78c78491617af3897f0d86007046
# Parent b113d626cfaf7c8faa7be9d528816ed944e59ba8
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 <jeremy@xxxxxxxx>
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
diff -r b113d626cfaf -r bfa65eb40b2a tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Tue Sep 27 17:32:16 2011 +0100
+++ b/tools/libxl/libxl_device.c Tue Sep 27 18:03:11 2011 +0100
@@ -522,7 +522,7 @@
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 @@
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 @@
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 @@
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 -r b113d626cfaf -r bfa65eb40b2a tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Tue Sep 27 17:32:16 2011 +0100
+++ b/tools/libxl/libxl_dm.c Tue Sep 27 18:03:11 2011 +0100
@@ -920,7 +920,7 @@
{
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 -r b113d626cfaf -r bfa65eb40b2a tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Tue Sep 27 17:32:16 2011 +0100
+++ b/tools/libxl/libxl_internal.h Tue Sep 27 18:03:11 2011 +0100
@@ -283,7 +283,7 @@
_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,
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|