WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xl: Add command 'xl mem-max'

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: Add command 'xl mem-max'
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2010 00:40:32 -0700
Delivery-date: Fri, 14 May 2010 00:42:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1273650779 -3600
# Node ID 21e3bc1c0ec2b08de8ec9853ea2627da956eae57
# Parent  4bf0ea1482238adbf943fe8e9cfb9b05ba0337ef
xl: Add command 'xl mem-max'

Add subcommand 'xl mem-max', can be used to set static max memory

Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
---
 tools/libxl/libxl.c       |   33 ++++++++++++++++++++++++++++
 tools/libxl/libxl.h       |    1 
 tools/libxl/xl_cmdimpl.c  |   53 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdimpl.h  |    1 
 tools/libxl/xl_cmdtable.c |    5 ++++
 5 files changed, 93 insertions(+)

diff -r 4bf0ea148223 -r 21e3bc1c0ec2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed May 12 08:52:30 2010 +0100
+++ b/tools/libxl/libxl.c       Wed May 12 08:52:59 2010 +0100
@@ -2346,6 +2346,39 @@ int libxl_device_pci_shutdown(struct lib
     return 0;
 }
 
+int libxl_domain_setmaxmem(struct libxl_ctx *ctx, uint32_t domid, uint32_t 
max_memkb)
+{
+    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) {
+        XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot get memory info from 
%s/memory/target\n", dompath);
+        return 1;
+    }
+    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);
+        return 1;
+    }
+
+    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");
+        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)
 {
     int rc = 0;
diff -r 4bf0ea148223 -r 21e3bc1c0ec2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Wed May 12 08:52:30 2010 +0100
+++ b/tools/libxl/libxl.h       Wed May 12 08:52:59 2010 +0100
@@ -339,6 +339,7 @@ int libxl_domain_pause(struct libxl_ctx 
 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_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num);
diff -r 4bf0ea148223 -r 21e3bc1c0ec2 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed May 12 08:52:30 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed May 12 08:52:59 2010 +0100
@@ -1187,6 +1187,59 @@ void help(char *command)
     }
 }
 
+int set_memory_max(char *p, char *mem)
+{
+    char *endptr;
+    uint32_t memorykb;
+    int rc;
+
+    find_domain(p);
+
+    memorykb = strtoul(mem, &endptr, 10);
+    if (*endptr != '\0') {
+        fprintf(stderr, "invalid memory size: %s\n", mem);
+        exit(3);
+    }
+
+    rc = libxl_domain_setmaxmem(&ctx, domid, memorykb);
+
+    return rc;
+}
+
+int main_memmax(int argc, char **argv)
+{
+    int opt = 0;
+    char *p = NULL, *mem;
+    int rc;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("mem-max");
+            exit(0);
+        default:
+            fprintf(stderr, "option not supported\n");
+            break;
+        }
+    }
+    if (optind >= argc - 1) {
+        help("mem-max");
+        exit(2);
+    }
+
+    p = argv[optind];
+    mem = argv[optind + 1];
+
+    rc = set_memory_max(p, mem);
+    if (rc) {
+        fprintf(stderr, "cannot set domid %d static max memory to : %s\n", 
domid, mem);
+        exit(1);
+    }
+
+    printf("setting domid %d static max memory to : %s\n", domid, mem);
+    exit(0);
+}
+
 void set_memory_target(char *p, char *mem)
 {
     char *endptr;
diff -r 4bf0ea148223 -r 21e3bc1c0ec2 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h  Wed May 12 08:52:30 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h  Wed May 12 08:52:59 2010 +0100
@@ -33,6 +33,7 @@ int main_button_press(int argc, char **a
 int main_button_press(int argc, char **argv);
 int main_vcpupin(int argc, char **argv);
 int main_vcpuset(int argc, char **argv);
+int main_memmax(int argc, char **argv);
 int main_memset(int argc, char **argv);
 int main_sched_credit(int argc, char **argv);
 int main_domid(int argc, char **argv);
diff -r 4bf0ea148223 -r 21e3bc1c0ec2 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Wed May 12 08:52:30 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed May 12 08:52:59 2010 +0100
@@ -108,6 +108,11 @@ struct cmd_spec cmd_table[] = {
       "Eject a cdrom from a guest's cd drive",
       "<Domain> <VirtualDevice>",
     },
+    { "mem-max",
+      &main_memmax,
+      "Set the maximum amount reservation for a domain",
+      "<Domain> <MemKB>",
+    },
     { "mem-set",
       &main_memset,
       "Set the current memory usage for a domain",

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: Add command 'xl mem-max', Xen patchbot-unstable <=