From: Stefano Stabellini Subject: [PATCH] libxl_set_memory_target: retain the same maxmem offset on top of the current target Date: Tue, 25 Nov 2014 17:54:30 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Ian Jackson , "Wei Liu (Intern)" , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org In libxl_set_memory_target when setting the new maxmem, retain the same offset on top of the current target. The offset includes memory allocated by QEMU for rom files. Signed-off-by: Stefano Stabellini diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index de23fec..8381c3e 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -4767,10 +4767,12 @@ retry_transaction: "%s/memory/videoram", dompath)); videoram = videoram_s ? atoi(videoram_s) : 0; - if (enforce) { - memorykb = new_target_memkb; - rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb + - LIBXL_MAXMEM_CONSTANT); + libxl_dominfo_init(&ptr); + xcinfo2xlinfo(ctx, &info, &ptr); + + if (enforce && new_target_memkb > 0) { + memorykb = ptr.max_memkb - current_target_memkb + new_target_memkb; + rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb); if (rc != 0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_domain_setmaxmem domid=%d memkb=%d failed " @@ -4800,8 +4802,6 @@ retry_transaction: goto out; } - libxl_dominfo_init(&ptr); - xcinfo2xlinfo(ctx, &info, &ptr); uuid = libxl__uuid2string(gc, ptr.uuid); libxl__xs_write(gc, t, libxl__sprintf(gc, "/vm/%s/memory", uuid), "%"PRIu32, new_target_memkb / 1024);