From: Vincent Hanquez Subject: [PATCH 2/6] do not try to set memory target with a number we haven't verified in set-mem. Date: Mon, 11 Jan 2010 21:48:22 +0000 Message-ID: <1263246506-5488-3-git-send-email-vincent.hanquez@eu.citrix.com> References: <1263246506-5488-1-git-send-email-vincent.hanquez@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.6.6" Return-path: In-Reply-To: <1263246506-5488-1-git-send-email-vincent.hanquez@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Vincent Hanquez List-Id: xen-devel@lists.xenproject.org --------------1.6.6 Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: quoted-printable checking that memory string conversion what done properly instead of send= ing a request to balloon a domain to 0 memory. Signed-off-by: Vincent Hanquez --- tools/libxl/xl.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) --------------1.6.6 Content-Type: text/x-patch; name="0002-do-not-try-to-set-memory-target-with-a-number-we-hav.patch" Content-Disposition: attachment; filename="0002-do-not-try-to-set-memory-target-with-a-number-we-hav.patch" Content-Transfer-Encoding: quoted-printable diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 851519f..2cf08cd 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -993,6 +993,8 @@ void set_memory_target(char *p, char *mem) { struct libxl_ctx ctx; uint32_t domid; + uint32_t memorykb; + char *endptr; =20 if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { fprintf(stderr, "cannot init xl context\n"); @@ -1004,7 +1006,13 @@ void set_memory_target(char *p, char *mem) fprintf(stderr, "%s is an invalid domain identifier\n", p); exit(2); } - libxl_set_memory_target(&ctx, domid, atoi(mem)); + memorykb =3D strtoul(mem, &endptr, 10); + if (*endptr !=3D '\0') { + fprintf(stderr, "invalid memory size: %s\n", mem); + exit(3); + } + printf("setting domid %d memory to : %d\n", domid, memorykb); + libxl_set_memory_target(&ctx, domid, memorykb); } =20 int main_memset(int argc, char **argv) --------------1.6.6 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------1.6.6--