mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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@eu.citrix.com> Acked-by: Jonathan Knowles <Jonathan.Knowles@eu.citrix.com>=20
This commit is contained in:
1 parent
98c10bc898
commit
3921297ea2
3 files changed
+10
-10
No files matched your search
+8
-8
@@ -2468,7 +2468,6 @@ int libxl_domain_setmaxmem(struct libxl_ctx *ctx, uint32_t domid, uint32_t max_m
|
||||
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_ctx *ctx, uint32_t domid, uint32_t max_m
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 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_ctx *ctx, uint32_t domid, uint32_t targ
|
||||
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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -340,7 +340,7 @@ int libxl_domain_pause(struct libxl_ctx *ctx, uint32_t domid);
|
||||
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);
|
||||
|
||||
|
||||
@@ -1262,7 +1262,7 @@ void set_memory_target(char *p, char *mem)
|
||||
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)
|
||||
|
||||