libxl_set_memory_target: retain the same maxmem offset on top of the current target
PATCH v4 1/1 libxl_set_memory_target: retain the same maxmem offset on top of the current target
In libxl_set_memory_target when setting the new maxmem, retain the same offset on top of the current target. In the future the offset will include memory allocated by QEMU for rom files.
---
Changes in v4:
- remove new_target_memkb <= 0 check.
Changes in v3:
- move call to libxl__uuid2string and libxl_dominfo_dispose earlier;
- error out if new_target_memkb <= 0.
Changes in v2:
- remove LIBXL_MAXMEM_CONSTANT from LIBXL__LOG_ERRNO.
--- tools/libxl/libxl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +7 -5
@@ -4681,6 +4681,12 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,char *uuid;xs_transaction_t t; +if (libxl_domain_info (ctx, &ptr, domid) <0 ) + goto out_no_transaction; + + uuid =libxl__uuid2string (gc, ptr.uuid); +libxl_dominfo_dispose (&ptr); + retry_transaction: t =xs_transaction_start (ctx->xsh);
@@ -4756,7 +4762,7 @@ retry_transaction: }if (enforce) { - memorykb = new_target_memkb + videoram; + 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,
@@ -4786,12 +4792,8 @@ 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 ); -libxl_dominfo_dispose (&ptr); out: if (!xs_transaction_end(ctx->xsh, t, abort_transaction)
Signature · 1 line
1.7.10.4
Quoted 26 lines · Stefano Stabellini
In
libxl_set_memory_targetwhen setting the new maxmem, retain the same offset on top of the current target. In the future the offset will include memory allocated by QEMU for rom files.Signed-off-by Stefano Stabellini <[email protected]>---
Changes in v4:
- removenew_target_memkb<= 0 check.Changes in v3:
- move call tolibxl__uuid2stringandlibxl_dominfo_disposeearlier;
- error out ifnew_target_memkb<= 0.Changes in v2:
- removeLIBXL_MAXMEM_CONSTANTfromLIBXL__LOG_ERRNO.--- tools/libxl/libxl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, · line 4683
Quoted 3 lines
tools/libxl/libxl.c +0
-0@@ -4681,6 +4681,12 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,char *uuid;xs_transaction_t t;
Should have:
libxl_dominfo_init(&ptr);
tools/libxl/libxl.c int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, · line 4689
Quoted 6 lines
tools/libxl/libxl.c +6
-0+if (libxl_domain_info (ctx, &ptr, domid) <0 ) + goto out_no_transaction; + + uuid =libxl__uuid2string (gc, ptr.uuid); +libxl_dominfo_dispose (&ptr); +
Since you need to use ptr later, you cannot dispose it here.
You can safely call dispose before returning to caller.
Quoted 13 lines
tools/libxl/libxl.c +1
-1retry_transaction: t =xs_transaction_start (ctx->xsh);@@ -4756,7 +4762,7 @@ retry_transaction: }if (enforce) { - memorykb = new_target_memkb + videoram; + 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,
tools/libxl/libxl.c retry_transaction: · line 4790
Quoted 5 lines
tools/libxl/libxl.c +0
-2@@ -4786,12 +4792,8 @@ retry_transaction: goto out; } -libxl_dominfo_init (&ptr); -xcinfo2xlinfo (ctx, &info, &ptr);
If I'm not mistaken, &info is only used here. I think you can delete info and relevant code all together.
Wei.
Quoted 9 lines
tools/libxl/libxl.c +0
-2- uuid =libxl__uuid2string (gc, ptr.uuid);libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid),"%" PRIu32, new_target_memkb /1024 ); -libxl_dominfo_dispose (&ptr); out: if (!xs_transaction_end(ctx->xsh, t, abort_transaction)Signature · 1 line
1.7.10.4
Quoted 62 lines · Wei Liu
Quoted 26 lines · Stefano Stabellini
In
libxl_set_memory_targetwhen setting the new maxmem, retain the same offset on top of the current target. In the future the offset will include memory allocated by QEMU for rom files.Signed-off-by Stefano Stabellini <[email protected]>---
Changes in v4:
- removenew_target_memkb<= 0 check.Changes in v3:
- move call tolibxl__uuid2stringandlibxl_dominfo_disposeearlier;
- error out ifnew_target_memkb<= 0.Changes in v2:
- removeLIBXL_MAXMEM_CONSTANTfromLIBXL__LOG_ERRNO.--- tools/libxl/libxl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0tools/libxl/libxl.c int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, · line 4683
Quoted 3 lines
tools/libxl/libxl.c +0
-0@@ -4681,6 +4681,12 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,char *uuid;xs_transaction_t t;Should have:
libxl_dominfo_init(&ptr);tools/libxl/libxl.c int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, · line 4689
Quoted 6 lines
tools/libxl/libxl.c +6
-0+if (libxl_domain_info (ctx, &ptr, domid) <0 ) + goto out_no_transaction; + + uuid =libxl__uuid2string (gc, ptr.uuid); +libxl_dominfo_dispose (&ptr); +Since you need to use ptr later, you cannot dispose it here.
You can safely call dispose before returning to caller.
Quoted 16 lines
tools/libxl/libxl.c +1
-1retry_transaction: t =xs_transaction_start (ctx->xsh);@@ -4756,7 +4762,7 @@ retry_transaction: }if (enforce) { - memorykb = new_target_memkb + videoram; + 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,@@ -4786,12 +4792,8 @@ retry_transaction: goto out; }
Quoted 5 lines
tools/libxl/libxl.c retry_transaction: · line 4790
Quoted 2 lines
tools/libxl/libxl.c +0
-2-libxl_dominfo_init (&ptr); -xcinfo2xlinfo (ctx, &info, &ptr);If I'm not mistaken, &info is only used here. I think you can delete info and relevant code all together.
info is used later as an argument to xc_domain_getinfolist
Quoted 11 lines
Quoted 10 lines
tools/libxl/libxl.c +0
-2- uuid =libxl__uuid2string (gc, ptr.uuid);libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid),"%" PRIu32, new_target_memkb /1024 ); -libxl_dominfo_dispose (&ptr); out: if (!xs_transaction_end(ctx->xsh, t, abort_transaction)Signature · 1 line
1.7.10.4
On Thu, Feb 26, 2015 at 06:53:29PM +0000, Stefano Stabellini wrote:
[...]
Quoted 11 lines
Quoted 7 lines
tools/libxl/libxl.c retry_transaction: · line 4790
Quoted 4 lines
}tools/libxl/libxl.c +0
-2-libxl_dominfo_init (&ptr); -xcinfo2xlinfo (ctx, &info, &ptr);If I'm not mistaken, &info is only used here. I think you can delete info and relevant code all together.
info is used later as an argument to
xc_domain_getinfolist
What I meant was, the sole purpose of info and two function calls xc_domain_getinfolist + xcinfo2xlinfo is to fill in ptr, which is done by a single call to libxl_domain_info at the beginning of your patch, so it's possible to remove info and those two function calls all together.
Wei.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
tools/libxl/libxl.c +0
-2- uuid =libxl__uuid2string (gc, ptr.uuid);libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid),"%" PRIu32, new_target_memkb /1024 ); -libxl_dominfo_dispose (&ptr); out: if (!xs_transaction_end(ctx->xsh, t, abort_transaction)Signature · 1 line
1.7.10.4
Quoted 14 lines · Wei Liu
On Thu, Feb 26, 2015 at 06:53:29PM +0000, Stefano Stabellini wrote:
[...]Quoted 11 lines
Quoted 7 lines
tools/libxl/libxl.c retry_transaction: · line 4790
Quoted 4 lines
}tools/libxl/libxl.c +0
-2-libxl_dominfo_init (&ptr); -xcinfo2xlinfo (ctx, &info, &ptr);If I'm not mistaken, &info is only used here. I think you can delete info and relevant code all together.
info is used later as an argument to
xc_domain_getinfolist
Quoted 5 lines
What I meant was, the sole purpose of info and two function calls
xc_domain_getinfolist+ xcinfo2xlinfo is to fill in ptr, which is done by a single call tolibxl_domain_infoat the beginning of your patch, so it's possible to remove info and those two function calls all together.
You are right! I'll resend.