[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: Adjustments to memset/memmax handling
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1273819996 -3600 # Node ID b29e42cb4727d718025b4b7039b35a824c8a11d3 # Parent 9b9a277d8a51de049068d3251b5d84b73a24196b libxl: Adjustments to memset/memmax handling I think xl memset should change the memory currently used by the guest and xl memmax should change the size of the guest's address space and not the population. For this reason libxl_set_memory_target should provide a way to enforce the memory target, calling xc_domain_setmaxmem. On the other hand xl memmax shouldn't call xc_domain_setmaxmem because that is the upper bound of the memory reservation, it should just change static-max, that at the moment wouldn't do much, but we can imagine that in the future could trigger something useful in the guest. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Jonathan Knowles <Jonathan.Knowles@xxxxxxxxxxxxx>=20 --- tools/libxl/libxl.c | 20 ++++++++++---------- tools/libxl/libxl.h | 2 +- tools/libxl/xl_cmdimpl.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff -r 9b9a277d8a51 -r b29e42cb4727 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Fri May 14 07:52:24 2010 +0100 +++ b/tools/libxl/libxl.c Fri May 14 07:53:16 2010 +0100 @@ -2468,7 +2468,6 @@ int libxl_domain_setmaxmem(struct libxl_ char *mem, *endptr; uint32_t memorykb; char *dompath = libxl_xs_get_dompath(ctx, domid); - int rc; mem = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/memory/target", dompath)); if (!mem) { @@ -2486,20 +2485,16 @@ int libxl_domain_setmaxmem(struct libxl_ return 1; } - rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb); - if (rc != 0) - return rc; - if (domid != 0) libxl_xs_write(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/memory/static-max", dompath), "%lu", max_memkb); - return rc; -} - -int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb) + return 0; +} + +int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb, int enforce) { int rc = 0; - uint32_t memorykb, videoram; + uint32_t memorykb = 0, videoram = 0; char *memmax, *endptr, *videoram_s = NULL; char *dompath = libxl_xs_get_dompath(ctx, domid); xc_domaininfo_t info; @@ -2539,6 +2534,11 @@ int libxl_set_memory_target(struct libxl uuid = libxl_uuid2string(ctx, ptr.uuid); libxl_xs_write(ctx, XBT_NULL, libxl_sprintf(ctx, "/vm/%s/memory", uuid), "%lu", target_memkb / 1024); + if (enforce || !domid) + memorykb = target_memkb; + rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb + LIBXL_MAXMEM_CONSTANT); + if (rc != 0) + return rc; rc = xc_domain_memory_set_pod_target(ctx->xch, domid, (target_memkb - videoram) / 4, NULL, NULL, NULL); return rc; } diff -r 9b9a277d8a51 -r b29e42cb4727 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Fri May 14 07:52:24 2010 +0100 +++ b/tools/libxl/libxl.h Fri May 14 07:53:16 2010 +0100 @@ -340,7 +340,7 @@ int libxl_domain_unpause(struct libxl_ct int libxl_domain_unpause(struct libxl_ctx *ctx, uint32_t domid); int libxl_domain_setmaxmem(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb); -int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb); +int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb, int enforce); int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num); diff -r 9b9a277d8a51 -r b29e42cb4727 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri May 14 07:52:24 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Fri May 14 07:53:16 2010 +0100 @@ -1262,7 +1262,7 @@ void set_memory_target(char *p, char *me exit(3); } printf("setting domid %d memory to : %d\n", domid, memorykb); - libxl_set_memory_target(&ctx, domid, memorykb); + libxl_set_memory_target(&ctx, domid, memorykb, /* enforce */ 1); } int main_memset(int argc, char **argv) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |