From: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
To: roger.pau@citrix.com, George.Dunlap@eu.citrix.com,
xen-devel@lists.xenproject.org
Cc: Dario Faggioli <dario.faggioli@citrix.com>,
Paulina Szubarczyk <paulinaszubarczyk@gmail.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 04/11] xl: improve return code for freemem function
Date: Wed, 30 Mar 2016 17:02:43 +0200 [thread overview]
Message-ID: <1459350170-9573-5-git-send-email-paulinaszubarczyk@gmail.com> (raw)
In-Reply-To: <1459350170-9573-1-git-send-email-paulinaszubarczyk@gmail.com>
- Return 0 or 1 for freemem function
- Correct the condition of checking return values of freemem.
Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Dario Faggioli <dario.faggioli@citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
---
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@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-30 15:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 15:02 [PATCH 00/11] Return failure on failure for more xl commands Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 01/11] libxl_pci: improve return codes " Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 02/11] libxl_pci: clean an unused return variable Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 03/11] libxl_pci: Return error code for more pci-* functions Paulina Szubarczyk
2016-03-30 15:02 ` Paulina Szubarczyk [this message]
2016-03-30 15:02 ` [PATCH 05/11] xl: Make set_memory_target return an error code on failure Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 06/11] xl: Return an error on failed cd-insert Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 07/11] xl: Return error codes for pci* commands Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 08/11] xl: improve main_tmem_* return codes Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 09/11] libxl: Remove pointless hypercall from libxl_set_memory_target Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 10/11] libxl: Fix libxl_set_memory_target return value Paulina Szubarczyk
2016-03-30 15:02 ` [PATCH 11/11] libxl: libxl_tmem functions improving coding style Paulina Szubarczyk
2016-03-30 15:14 ` [PATCH 00/11] Return failure on failure for more xl commands Wei Liu
2016-03-30 17:19 ` Paulina Szubarczyk
2016-03-31 15:06 ` Wei Liu
2016-04-01 9:55 ` Paulina Szubarczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459350170-9573-5-git-send-email-paulinaszubarczyk@gmail.com \
--to=paulinaszubarczyk@gmail.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).