[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] tools/libxl: Make libxl__conversion_helper_abort() safe to use
commit 2b8ba04cd150250d23ff0a396851b7ec9a500f07 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Tue Aug 4 18:16:31 2015 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Wed Aug 5 10:40:35 2015 +0100 tools/libxl: Make libxl__conversion_helper_abort() safe to use Previously, in the case of an error causing a call to libxl__conversion_helper_abort() on a stream without legacy conversion, libxl would fall over a NULL pointer because chs->ao was not set up. Arrange for all ->ao's to be set up at _init() time, by having each _init() function assert that their caller has done the right thing. While doing so, introduce a previously-missing save_helper_init() in stream_read_init(). Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx> --- tools/libxl/libxl_convert_callout.c | 2 ++ tools/libxl/libxl_internal.h | 4 ++-- tools/libxl/libxl_stream_read.c | 11 ++++++++--- tools/libxl/libxl_stream_write.c | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_convert_callout.c b/tools/libxl/libxl_convert_callout.c index 65b4df9..5e5678b 100644 --- a/tools/libxl/libxl_convert_callout.c +++ b/tools/libxl/libxl_convert_callout.c @@ -34,6 +34,8 @@ static void helper_done(libxl__egc *egc, void libxl__conversion_helper_init(libxl__conversion_helper_state *chs) { + assert(chs->ao); + chs->v2_carefd = NULL; chs->rc = 0; libxl__ao_abortable_init(&chs->abrt); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 29e0429..0253b49 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2945,9 +2945,9 @@ _hidden int libxl__netbuffer_enabled(libxl__gc *gc); typedef struct libxl__conversion_helper_state libxl__conversion_helper_state; struct libxl__conversion_helper_state { - /* public */ + /* Public - Must be filled by caller unless noted. */ libxl__ao *ao; - int legacy_fd; + int legacy_fd; /* fd to read the legacy stream from. */ bool hvm; /* pv or hvm domain? */ libxl__carefd *v2_carefd; /* Filled by successful call to * libxl__convert_legacy_stream(). Caller diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c index fd3675c..c555542 100644 --- a/tools/libxl/libxl_stream_read.c +++ b/tools/libxl/libxl_stream_read.c @@ -173,12 +173,18 @@ static void free_record(libxl__sr_record_buf *rec) void libxl__stream_read_init(libxl__stream_read_state *stream) { + assert(stream->ao); + + stream->shs.ao = stream->ao; + libxl__save_helper_init(&stream->shs); + + stream->chs.ao = stream->ao; + libxl__conversion_helper_init(&stream->chs); + stream->rc = 0; stream->running = false; stream->in_checkpoint = false; stream->sync_teardown = false; - libxl__save_helper_init(&stream->shs); - libxl__conversion_helper_init(&stream->chs); FILLZERO(stream->dc); FILLZERO(stream->hdr); LIBXL_STAILQ_INIT(&stream->record_queue); @@ -205,7 +211,6 @@ void libxl__stream_read_start(libxl__egc *egc, /* Convert the legacy stream. */ libxl__conversion_helper_state *chs = &stream->chs; - chs->ao = stream->ao; chs->legacy_fd = stream->fd; chs->hvm = (stream->dcs->guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM); diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c index 9e9c998..be8f548 100644 --- a/tools/libxl/libxl_stream_write.c +++ b/tools/libxl/libxl_stream_write.c @@ -155,6 +155,11 @@ static void write_done(libxl__egc *egc, void libxl__stream_write_init(libxl__stream_write_state *stream) { + assert(stream->ao); + + stream->shs.ao = stream->ao; + libxl__save_helper_init(&stream->shs); + stream->rc = 0; stream->running = false; stream->in_checkpoint = false; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |