mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxenlight: do not try to set memory target with a number we haven't
verified in set-mem. checking that memory string conversion what done properly instead of sending a request to balloon a domain to 0 memory. Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
This commit is contained in:
1 parent
f777e25427
commit
0d8907b049
1 file changed
+9
-1
+9
-1
@@ -993,6 +993,8 @@ void set_memory_target(char *p, char *mem)
|
||||
{
|
||||
struct libxl_ctx ctx;
|
||||
uint32_t domid;
|
||||
uint32_t memorykb;
|
||||
char *endptr;
|
||||
|
||||
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 = strtoul(mem, &endptr, 10);
|
||||
if (*endptr != '\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);
|
||||
}
|
||||
|
||||
int main_memset(int argc, char **argv)
|
||||
|
||||