currently xcinfo2xlinfo reads tot_pages and uses that data to calculate
max_memkb, while tot_pages is the memory currently used by the domain
and max_pages is the theoretical maximum.
Remove max_memkb from libxl_dominfo, add current_memkb instead.
Make max_memkb completely opaque to the users, therefore remove
max_memkb from libxl_domain_build_info and remove libxl_domain_setmaxmem
too.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
diff -r ae0cd4e5cc01 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Sep 01 10:19:14 2010 +0100
+++ b/tools/libxl/libxl.c Wed Sep 01 11:48:09 2010 +0100
@@ -543,7 +543,7 @@ static void xcinfo2xlinfo(const xc_domai
else
xlinfo->shutdown_reason = ~0;
- xlinfo->max_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages);
+ xlinfo->current_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages);
xlinfo->cpu_time = xcinfo->cpu_time;
xlinfo->vcpu_max_id = xcinfo->max_vcpu_id;
xlinfo->vcpu_online = xcinfo->nr_online_vcpus;
@@ -1511,8 +1511,7 @@ static int libxl_create_stubdom(libxl_ct
memset(&b_info, 0x00, sizeof(libxl_domain_build_info));
b_info.max_vcpus = 1;
- b_info.max_memkb = 32 * 1024;
- b_info.target_memkb = b_info.max_memkb;
+ b_info.target_memkb = 32 * 1024;
b_info.kernel.path = libxl_abs_path(&gc, "ioemu-stubdom.gz",
libxl_xenfirmwaredir_path());
b_info.u.pv.cmdline = libxl_sprintf(&gc, " -d %d", info->domid);
b_info.u.pv.ramdisk.path = "";
@@ -2721,39 +2720,6 @@ int libxl_device_vfb_hard_shutdown(libxl
/******************************************************************************/
-int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
-{
- libxl_gc gc = LIBXL_INIT_GC(ctx);
- char *mem, *endptr;
- uint32_t memorykb;
- char *dompath = libxl_xs_get_dompath(&gc, domid);
- int rc = 1;
-
- mem = libxl_xs_read(&gc, XBT_NULL, libxl_sprintf(&gc, "%s/memory/target",
dompath));
- if (!mem) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot get memory info from
%s/memory/target\n", dompath);
- goto out;
- }
- memorykb = strtoul(mem, &endptr, 10);
- if (*endptr != '\0') {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "invalid memory %s from
%s/memory/target\n", mem, dompath);
- goto out;
- }
-
- if (max_memkb < memorykb) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "memory_static_max must be greater
than or or equal to memory_dynamic_max\n");
- goto out;
- }
-
- if (domid != 0)
- libxl_xs_write(&gc, XBT_NULL, libxl_sprintf(&gc,
"%s/memory/static-max", dompath), "%"PRIu32, max_memkb);
-
- rc = 0;
-out:
- libxl_free_all(&gc);
- return rc;
-}
-
int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t
target_memkb, int enforce)
{
libxl_gc gc = LIBXL_INIT_GC(ctx);
diff -r ae0cd4e5cc01 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Sep 01 10:19:14 2010 +0100
+++ b/tools/libxl/libxl.h Wed Sep 01 11:48:09 2010 +0100
@@ -320,7 +320,6 @@ int libxl_domain_unpause(libxl_ctx *ctx,
int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, const char
*filename);
-int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t
target_memkb);
int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t
target_memkb, int enforce);
int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
diff -r ae0cd4e5cc01 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Sep 01 10:19:14 2010 +0100
+++ b/tools/libxl/libxl.idl Wed Sep 01 11:48:09 2010 +0100
@@ -36,7 +36,7 @@ libxl_dominfo = Struct("dominfo",[
Otherwise set to a value guaranteed not to clash with any valid
SHUTDOWN_* constant."""),
- ("max_memkb", uint64),
+ ("current_memkb", uint64),
("cpu_time", uint64),
("vcpu_max_id", uint32),
("vcpu_online", uint32),
@@ -91,7 +91,6 @@ libxl_domain_build_info = Struct("domain
("max_vcpus", integer),
("cur_vcpus", integer),
("tsc_mode", integer),
- ("max_memkb", uint32),
("target_memkb", uint32),
("video_memkb", uint32),
("shadow_memkb", uint32),
diff -r ae0cd4e5cc01 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Wed Sep 01 10:19:14 2010 +0100
+++ b/tools/libxl/libxl_dom.c Wed Sep 01 11:48:09 2010 +0100
@@ -65,8 +65,8 @@ int build_pre(libxl_ctx *ctx, uint32_t d
xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
LIBXL_MAXMEM_CONSTANT);
xc_domain_set_memmap_limit(ctx->xch, domid,
- (info->hvm) ? info->max_memkb :
- (info->max_memkb + info->u.pv.slack_memkb));
+ (info->hvm) ? info->target_memkb :
+ (info->target_memkb + info->u.pv.slack_memkb));
xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0);
if ( info->disable_migrate )
xc_domain_disable_migrate(ctx->xch, domid);
@@ -98,7 +98,7 @@ int build_post(libxl_ctx *ctx, uint32_t
ents = libxl_calloc(&gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
ents[0] = "memory/static-max";
- ents[1] = libxl_sprintf(&gc, "%d", info->max_memkb);
+ ents[1] = libxl_sprintf(&gc, "%d", info->target_memkb);
ents[2] = "memory/target";
ents[3] = libxl_sprintf(&gc, "%d", info->target_memkb);
ents[4] = "memory/videoram";
@@ -230,7 +230,7 @@ int build_hvm(libxl_ctx *ctx, uint32_t d
ret = xc_hvm_build_target_mem(
ctx->xch,
domid,
- (info->max_memkb - info->video_memkb) / 1024,
+ (info->target_memkb - info->video_memkb) / 1024,
(info->target_memkb - info->video_memkb) / 1024,
libxl_abs_path(&gc, (char *)info->kernel.path,
libxl_xenfirmwaredir_path()));
diff -r ae0cd4e5cc01 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Sep 01 10:19:14 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Sep 01 11:48:09 2010 +0100
@@ -265,8 +265,7 @@ static void init_build_info(libxl_domain
{
memset(b_info, '\0', sizeof(*b_info));
b_info->max_vcpus = 1;
- b_info->max_memkb = 32 * 1024;
- b_info->target_memkb = b_info->max_memkb;
+ b_info->target_memkb = 32 * 1024;
b_info->disable_migrate = 0;
if (c_info->hvm) {
b_info->shadow_memkb = 0; /* Set later */
@@ -428,7 +427,6 @@ static void printf_info(int domid,
printf("\t(domain_build_info)\n");
printf("\t(max_vcpus %d)\n", b_info->max_vcpus);
printf("\t(tsc_mode %d)\n", b_info->tsc_mode);
- printf("\t(max_memkb %d)\n", b_info->max_memkb);
printf("\t(target_memkb %d)\n", b_info->target_memkb);
printf("\t(nomigrate %d)\n", b_info->disable_migrate);
@@ -627,10 +625,8 @@ static void parse_config_data(const char
b_info->cur_vcpus = (1 << l) - 1;
}
- if (!xlu_cfg_get_long (config, "memory", &l)) {
- b_info->max_memkb = l * 1024;
- b_info->target_memkb = b_info->max_memkb;
- }
+ if (!xlu_cfg_get_long (config, "memory", &l))
+ b_info->target_memkb = l * 1024;
if (xlu_cfg_get_string (config, "on_poweroff", &buf))
buf = "destroy";
@@ -666,7 +662,7 @@ static void parse_config_data(const char
* calculation depends on those values. */
b_info->shadow_memkb = !xlu_cfg_get_long(config, "shadow_memory", &l)
? l * 1024
- : libxl_get_required_shadow_memory(b_info->max_memkb,
+ : libxl_get_required_shadow_memory(b_info->target_memkb,
b_info->max_vcpus);
if (!xlu_cfg_get_long (config, "nomigrate", &l))
@@ -1708,7 +1704,7 @@ static int set_memory_max(char *p, char
exit(3);
}
- rc = libxl_domain_setmaxmem(&ctx, domid, memorykb);
+ rc = libxl_set_memory_target(&ctx, domid, memorykb, 1);
return rc;
}
@@ -2209,7 +2205,7 @@ static void list_domains(int verbose, co
printf("%-40s %5d %5lu %5d %c%c%c%c%c%c %8.1f",
domname,
info[i].domid,
- (unsigned long) (info[i].max_memkb / 1024),
+ (unsigned long) (info[i].current_memkb / 1024),
info[i].vcpu_online,
info[i].running ? 'r' : '-',
info[i].blocked ? 'b' : '-',
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|