[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxenlight: don't ignore ctx_init errors if there is one.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1262951055 0 # Node ID 5a5c2ed76aaf125beadcfc65c2a8e5450c19588e # Parent f909045c2284d4e96a133a3c0ceff73f554aa8ae libxenlight: don't ignore ctx_init errors if there is one. ctx_init can return error, and ignoring the errors, would lead to segfault later. fix all call sites to check return values. Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx> --- tools/libxl/xl.c | 61 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 12 deletions(-) diff -r f909045c2284 -r 5a5c2ed76aaf tools/libxl/xl.c --- a/tools/libxl/xl.c Fri Jan 08 11:39:33 2010 +0000 +++ b/tools/libxl/xl.c Fri Jan 08 11:44:15 2010 +0000 @@ -762,7 +762,11 @@ start: start: domid = 0; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } + libxl_ctx_set_log(&ctx, log_callback, NULL); libxl_domain_make(&ctx, &info1, &domid); @@ -974,7 +978,10 @@ void set_memory_target(char *p, char *me struct libxl_ctx ctx; uint32_t domid; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { @@ -1016,7 +1023,10 @@ void console(char *p, int cons_num) struct libxl_ctx ctx; uint32_t domid; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { @@ -1033,7 +1043,10 @@ void cd_insert(char *dom, char *virtdev, libxl_device_disk disk; char *p; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, dom, &domid) < 0) { @@ -1166,7 +1179,10 @@ void pcilist(char *dom) libxl_device_pci *pcidevs; int num, i; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, dom, &domid) < 0) { @@ -1216,7 +1232,10 @@ void pcidetach(char *dom, char *bdf) libxl_device_pci pcidev; unsigned int domain, bus, dev, func; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, dom, &domid) < 0) { @@ -1262,7 +1281,10 @@ void pciattach(char *dom, char *bdf, cha libxl_device_pci pcidev; unsigned int domain, bus, dev, func; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, dom, &domid) < 0) { @@ -1310,7 +1332,10 @@ void pause_domain(char *p) struct libxl_ctx ctx; uint32_t domid; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { @@ -1325,7 +1350,10 @@ void unpause_domain(char *p) struct libxl_ctx ctx; uint32_t domid; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { @@ -1340,7 +1368,10 @@ void destroy_domain(char *p) struct libxl_ctx ctx; uint32_t domid; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { @@ -1356,7 +1387,10 @@ void list_domains(void) struct libxl_dominfo *info; int nb_domain, i; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + return; + } libxl_ctx_set_log(&ctx, log_callback, NULL); info = libxl_domain_list(&ctx, &nb_domain); @@ -1383,7 +1417,10 @@ int save_domain(char *p, char *filename, uint32_t domid; int fd; - libxl_ctx_init(&ctx, LIBXL_VERSION); + if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { + fprintf(stderr, "cannot init xl context\n"); + exit(2); + } libxl_ctx_set_log(&ctx, log_callback, NULL); if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) { _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |