[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 04/11] xl: improve return code for freemem function
- Return 0 or 1 for freemem function - Correct the condition of checking return values of freemem. Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@xxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> CC: Dario Faggioli <dario.faggioli@xxxxxxxxxx> CC: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/xl_cmdimpl.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 990d3c9..173cd28 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2573,38 +2573,34 @@ static int preserve_domain(uint32_t *r_domid, libxl_event *event, static int freemem(uint32_t domid, libxl_domain_build_info *b_info) { - int rc, retries = 3; + int retries = 3; uint32_t need_memkb, free_memkb; if (!autoballoon) return 0; - rc = libxl_domain_need_memory(ctx, b_info, &need_memkb); - if (rc < 0) - return rc; + if (libxl_domain_need_memory(ctx, b_info, &need_memkb) < 0) + return 1; do { - rc = libxl_get_free_memory(ctx, &free_memkb); - if (rc < 0) - return rc; + if (libxl_get_free_memory(ctx, &free_memkb) < 0) + return 1; if (free_memkb >= need_memkb) return 0; - rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0); - if (rc < 0) - return rc; + if (libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0) < 0) + return 1; /* wait until dom0 reaches its target, as long as we are making * progress */ - rc = libxl_wait_for_memory_target(ctx, 0, 10); - if (rc < 0) - return rc; + if (libxl_wait_for_memory_target(ctx, 0, 10) < 0) + return 1; retries--; } while (retries > 0); - return ERROR_NOMEM; + return 1; } static void autoconnect_console(libxl_ctx *ctx_ignored, @@ -2870,7 +2866,7 @@ start: if (domid_soft_reset == INVALID_DOMID) { ret = freemem(domid, &d_config.b_info); - if (ret < 0) { + if (ret) { fprintf(stderr, "failed to free memory for the domain\n"); ret = ERROR_FAIL; goto error_out; -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |