xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6]xl: Add 'xl tmem-*' commands
@ 2010-05-19  8:22 Yang Hongyang
  2010-05-19  8:26 ` [PATCH 1/6]xl: Add 'xl tmem-list' command Yang Hongyang
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:22 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add tmem-* commands, did some simple tests.

[PATCH 1/6]xl: Add 'xl tmem-list' command
[PATCH 2/6]xl: Add 'xl tmem-freeze' command
[PATCH 3/6]xl: Add 'xl tmem-destroy' command
[PATCH 4/6]xl: Add 'xl tmem-thaw' command
[PATCH 5/6]xl: Add 'xl tmem-set' command
[PATCH 6/6]xl: Add 'xl tmem-shared-auth' command

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6]xl: Add 'xl tmem-list' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
@ 2010-05-19  8:26 ` Yang Hongyang
  2010-05-19  8:29 ` [PATCH 2/6]xl: Add 'xl tmem-freeze' command Yang Hongyang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:26 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-list' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r baccadfd9418 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.c	Wed May 19 23:25:29 2010 +0800
@@ -2825,3 +2825,18 @@
     return strtoul(start_time, NULL, 10);
 }
 
+char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long)
+{
+    int rc;
+    char _buf[32768];
+
+    rc = xc_tmem_control(ctx->xch, -1, TMEMC_LIST, domid, 32768, use_long,
+                         0, _buf);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not get tmem list");
+        return NULL;
+    }
+
+    return strdup(_buf);
+}
diff -r baccadfd9418 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.h	Wed May 19 23:25:29 2010 +0800
@@ -513,5 +513,7 @@
 int libxl_send_sysrq(struct libxl_ctx *ctx, uint32_t domid, char sysrq);
 uint32_t libxl_vm_get_start_time(struct libxl_ctx *ctx, uint32_t domid);
 
+char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long);
+
 #endif /* LIBXL_H */
 
diff -r baccadfd9418 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 19 23:25:29 2010 +0800
@@ -3667,3 +3667,49 @@
 
     exit(0);
 }
+
+int main_tmem_list(int argc, char **argv)
+{
+    char *dom = NULL;
+    char *buf = NULL;
+    int use_long = 0;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "alh")) != -1) {
+        switch (opt) {
+        case 'l':
+            use_long = 1;
+            break;
+        case 'a':
+            all = 1;
+            break;
+        case 'h':
+            help("tmem-list");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-list");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    buf = libxl_tmem_list(&ctx, domid, use_long);
+    if (buf == NULL)
+        exit(-1);
+
+    printf("%s\n", buf);
+    free(buf);
+    exit(0);
+}
diff -r baccadfd9418 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 19 23:25:29 2010 +0800
@@ -52,6 +52,7 @@
 int main_blocklist(int argc, char **argv);
 int main_blockdetach(int argc, char **argv);
 int main_uptime(int argc, char **argv);
+int main_tmem_list(int argc, char **argv);
 
 void help(char *command);
 
diff -r baccadfd9418 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Wed May 19 23:25:29 2010 +0800
@@ -224,6 +224,12 @@
       "Print uptime for all/some domains",
       "[-s] [Domain]",
     },
+    { "tmem-list",
+      &main_tmem_list,
+      "List tmem pools",
+      "[-l] [<Domain>|-a]",
+      "  -l                             List tmem stats",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/6]xl: Add 'xl tmem-freeze' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
  2010-05-19  8:26 ` [PATCH 1/6]xl: Add 'xl tmem-list' command Yang Hongyang
@ 2010-05-19  8:29 ` Yang Hongyang
  2010-05-19  8:31 ` [PATCH 3/6]xl: Add 'xl tmem-destroy' command Yang Hongyang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:29 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-freeze' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r 540720cb1f64 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed May 19 23:25:41 2010 +0800
+++ b/tools/libxl/libxl.c	Wed May 19 23:28:56 2010 +0800
@@ -2840,3 +2840,18 @@
 
     return strdup(_buf);
 }
+
+int libxl_tmem_freeze(struct libxl_ctx *ctx, uint32_t domid)
+{
+    int rc;
+
+    rc = xc_tmem_control(ctx->xch, -1, TMEMC_FREEZE, domid, 0, 0,
+                         0, NULL);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not freeze tmem pools");
+        return -1;
+    }
+
+    return rc;
+}
diff -r 540720cb1f64 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Wed May 19 23:25:41 2010 +0800
+++ b/tools/libxl/libxl.h	Wed May 19 23:28:56 2010 +0800
@@ -514,6 +514,7 @@
 uint32_t libxl_vm_get_start_time(struct libxl_ctx *ctx, uint32_t domid);
 
 char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long);
+int libxl_tmem_freeze(struct libxl_ctx *ctx, uint32_t domid);
 
 #endif /* LIBXL_H */
 
diff -r 540720cb1f64 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed May 19 23:25:41 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 19 23:28:56 2010 +0800
@@ -3713,3 +3713,40 @@
     free(buf);
     exit(0);
 }
+
+int main_tmem_freeze(int argc, char **argv)
+{
+    char *dom = NULL;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "ah")) != -1) {
+        switch (opt) {
+        case 'a':
+            all = 1;
+            break;
+        case 'h':
+            help("tmem-freeze");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-freeze");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    libxl_tmem_freeze(&ctx, domid);
+    exit(0);
+}
+
diff -r 540720cb1f64 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Wed May 19 23:25:41 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 19 23:28:56 2010 +0800
@@ -53,6 +53,7 @@
 int main_blockdetach(int argc, char **argv);
 int main_uptime(int argc, char **argv);
 int main_tmem_list(int argc, char **argv);
+int main_tmem_freeze(int argc, char **argv);
 
 void help(char *command);
 
diff -r 540720cb1f64 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Wed May 19 23:25:41 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Wed May 19 23:28:56 2010 +0800
@@ -230,6 +230,12 @@
       "[-l] [<Domain>|-a]",
       "  -l                             List tmem stats",
     },
+    { "tmem-freeze",
+      &main_tmem_freeze,
+      "Freeze tmem pools",
+      "[<Domain>|-a]",
+      "  -a                             Freeze all tmem",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/6]xl: Add 'xl tmem-destroy' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
  2010-05-19  8:26 ` [PATCH 1/6]xl: Add 'xl tmem-list' command Yang Hongyang
  2010-05-19  8:29 ` [PATCH 2/6]xl: Add 'xl tmem-freeze' command Yang Hongyang
@ 2010-05-19  8:31 ` Yang Hongyang
  2010-05-19  8:32 ` [PATCH 4/6]xl: Add 'xl tmem-thaw' command Yang Hongyang
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:31 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-destroy' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r 6b8ccb78dffe tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed May 19 23:29:07 2010 +0800
+++ b/tools/libxl/libxl.c	Wed May 19 23:32:52 2010 +0800
@@ -2855,3 +2855,18 @@
 
     return rc;
 }
+
+int libxl_tmem_destroy(struct libxl_ctx *ctx, uint32_t domid)
+{
+    int rc;
+
+    rc = xc_tmem_control(ctx->xch, -1, TMEMC_DESTROY, domid, 0, 0,
+                         0, NULL);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not destroy tmem pools");
+        return -1;
+    }
+
+    return rc;
+}
diff -r 6b8ccb78dffe tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Wed May 19 23:29:07 2010 +0800
+++ b/tools/libxl/libxl.h	Wed May 19 23:32:52 2010 +0800
@@ -515,6 +515,6 @@
 
 char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long);
 int libxl_tmem_freeze(struct libxl_ctx *ctx, uint32_t domid);
-
+int libxl_tmem_destroy(struct libxl_ctx *ctx, uint32_t domid);
 #endif /* LIBXL_H */
 
diff -r 6b8ccb78dffe tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed May 19 23:29:07 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 19 23:32:52 2010 +0800
@@ -3750,3 +3750,39 @@
     exit(0);
 }
 
+int main_tmem_destroy(int argc, char **argv)
+{
+    char *dom = NULL;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "ah")) != -1) {
+        switch (opt) {
+        case 'a':
+            all = 1;
+            break;
+        case 'h':
+            help("tmem-destroy");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-destroy");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    libxl_tmem_destroy(&ctx, domid);
+    exit(0);
+}
+
diff -r 6b8ccb78dffe tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Wed May 19 23:29:07 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 19 23:32:52 2010 +0800
@@ -54,6 +54,7 @@
 int main_uptime(int argc, char **argv);
 int main_tmem_list(int argc, char **argv);
 int main_tmem_freeze(int argc, char **argv);
+int main_tmem_destroy(int argc, char **argv);
 
 void help(char *command);
 
diff -r 6b8ccb78dffe tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Wed May 19 23:29:07 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Wed May 19 23:32:52 2010 +0800
@@ -236,6 +236,12 @@
       "[<Domain>|-a]",
       "  -a                             Freeze all tmem",
     },
+    { "tmem-destroy",
+      &main_tmem_destroy,
+      "Destroy tmem pools",
+      "[<Domain>|-a]",
+      "  -a                             Destroy all tmem",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/6]xl: Add 'xl tmem-thaw' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
                   ` (2 preceding siblings ...)
  2010-05-19  8:31 ` [PATCH 3/6]xl: Add 'xl tmem-destroy' command Yang Hongyang
@ 2010-05-19  8:32 ` Yang Hongyang
  2010-05-19  8:33 ` [PATCH 5/6]xl: Add 'xl tmem-set' command Yang Hongyang
  2010-05-19  8:35 ` [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command Yang Hongyang
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:32 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-thaw' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r 6997a436e0ed tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed May 19 23:33:08 2010 +0800
+++ b/tools/libxl/libxl.c	Wed May 19 23:35:06 2010 +0800
@@ -2870,3 +2870,18 @@
 
     return rc;
 }
+
+int libxl_tmem_thaw(struct libxl_ctx *ctx, uint32_t domid)
+{
+    int rc;
+
+    rc = xc_tmem_control(ctx->xch, -1, TMEMC_THAW, domid, 0, 0,
+                         0, NULL);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not thaw tmem pools");
+        return -1;
+    }
+
+    return rc;
+}
diff -r 6997a436e0ed tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Wed May 19 23:33:08 2010 +0800
+++ b/tools/libxl/libxl.h	Wed May 19 23:35:06 2010 +0800
@@ -516,5 +516,6 @@
 char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long);
 int libxl_tmem_freeze(struct libxl_ctx *ctx, uint32_t domid);
 int libxl_tmem_destroy(struct libxl_ctx *ctx, uint32_t domid);
+int libxl_tmem_thaw(struct libxl_ctx *ctx, uint32_t domid);
 #endif /* LIBXL_H */
 
diff -r 6997a436e0ed tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed May 19 23:33:08 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 19 23:35:06 2010 +0800
@@ -3786,3 +3786,39 @@
     exit(0);
 }
 
+int main_tmem_thaw(int argc, char **argv)
+{
+    char *dom = NULL;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "ah")) != -1) {
+        switch (opt) {
+        case 'a':
+            all = 1;
+            break;
+        case 'h':
+            help("tmem-thaw");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-thaw");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    libxl_tmem_thaw(&ctx, domid);
+    exit(0);
+}
+
diff -r 6997a436e0ed tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Wed May 19 23:33:08 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 19 23:35:06 2010 +0800
@@ -55,6 +55,7 @@
 int main_tmem_list(int argc, char **argv);
 int main_tmem_freeze(int argc, char **argv);
 int main_tmem_destroy(int argc, char **argv);
+int main_tmem_thaw(int argc, char **argv);
 
 void help(char *command);
 
diff -r 6997a436e0ed tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Wed May 19 23:33:08 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Wed May 19 23:35:06 2010 +0800
@@ -242,6 +242,12 @@
       "[<Domain>|-a]",
       "  -a                             Destroy all tmem",
     },
+    { "tmem-thaw",
+      &main_tmem_thaw,
+      "Thaw tmem pools",
+      "[<Domain>|-a]",
+      "  -a                             Thaw all tmem",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/6]xl: Add 'xl tmem-set' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
                   ` (3 preceding siblings ...)
  2010-05-19  8:32 ` [PATCH 4/6]xl: Add 'xl tmem-thaw' command Yang Hongyang
@ 2010-05-19  8:33 ` Yang Hongyang
  2010-05-19  8:35 ` [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command Yang Hongyang
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:33 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-set' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r f5c579127b26 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed May 19 23:35:17 2010 +0800
+++ b/tools/libxl/libxl.c	Wed May 19 23:37:09 2010 +0800
@@ -2885,3 +2885,35 @@
 
     return rc;
 }
+
+static int32_t tmem_setop_from_string(char *set_name)
+{
+    if (!strcmp(set_name, "weight"))
+        return TMEMC_SET_WEIGHT;
+    else if (!strcmp(set_name, "cap"))
+        return TMEMC_SET_CAP;
+    else if (!strcmp(set_name, "compress"))
+        return TMEMC_SET_COMPRESS;
+    else
+        return -1;
+}
+
+int libxl_tmem_set(struct libxl_ctx *ctx, uint32_t domid, char* name, uint32_t set)
+{
+    int rc;
+    int32_t subop = tmem_setop_from_string(name);
+
+    if (subop == -1) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1,
+            "Invalid set, valid sets are <weight|cap|compress>");
+        return -1;
+    }
+    rc = xc_tmem_control(ctx->xch, -1, subop, domid, set, 0, 0, NULL);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not set tmem %s", name);
+        return -1;
+    }
+
+    return rc;
+}
diff -r f5c579127b26 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Wed May 19 23:35:17 2010 +0800
+++ b/tools/libxl/libxl.h	Wed May 19 23:37:09 2010 +0800
@@ -517,5 +517,7 @@
 int libxl_tmem_freeze(struct libxl_ctx *ctx, uint32_t domid);
 int libxl_tmem_destroy(struct libxl_ctx *ctx, uint32_t domid);
 int libxl_tmem_thaw(struct libxl_ctx *ctx, uint32_t domid);
+int libxl_tmem_set(struct libxl_ctx *ctx, uint32_t domid, char* name,
+                   uint32_t set);
 #endif /* LIBXL_H */
 
diff -r f5c579127b26 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed May 19 23:35:17 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 19 23:37:09 2010 +0800
@@ -3822,3 +3822,64 @@
     exit(0);
 }
 
+int main_tmem_set(int argc, char **argv)
+{
+    char *dom = NULL;
+    uint32_t weight = 0, cap = 0, compress = 0;
+    int opt_w = 0, opt_c = 0, opt_p = 0;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "aw:c:p:h")) != -1) {
+        switch (opt) {
+        case 'a':
+            all = 1;
+            break;
+        case 'w':
+            weight = strtol(optarg, NULL, 10);
+            opt_w = 1;
+            break;
+        case 'c':
+            cap = strtol(optarg, NULL, 10);
+            opt_c = 1;
+            break;
+        case 'p':
+            compress = strtol(optarg, NULL, 10);
+            opt_p = 1;
+            break;
+        case 'h':
+            help("tmem-set");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-set");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    if (!opt_w && !opt_c && !opt_p) {
+        fprintf(stderr, "No set value specified.\n\n");
+        help("tmem-set");
+        exit(1);
+    }
+
+    if (opt_w)
+        libxl_tmem_set(&ctx, domid, "weight", weight);
+    if (opt_c)
+        libxl_tmem_set(&ctx, domid, "cap", cap);
+    if (opt_p)
+        libxl_tmem_set(&ctx, domid, "compress", compress);
+
+    exit(0);
+}
diff -r f5c579127b26 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Wed May 19 23:35:17 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 19 23:37:09 2010 +0800
@@ -56,6 +56,7 @@
 int main_tmem_freeze(int argc, char **argv);
 int main_tmem_destroy(int argc, char **argv);
 int main_tmem_thaw(int argc, char **argv);
+int main_tmem_set(int argc, char **argv);
 
 void help(char *command);
 
diff -r f5c579127b26 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Wed May 19 23:35:17 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Wed May 19 23:37:09 2010 +0800
@@ -248,6 +248,15 @@
       "[<Domain>|-a]",
       "  -a                             Thaw all tmem",
     },
+    { "tmem-set",
+      &main_tmem_set,
+      "Change tmem settings",
+      "[<Domain>|-a] [-w[=WEIGHT]|-c[=CAP]|-p[=COMPRESS]]",
+      "  -a                             Operate on all tmem\n"
+      "  -w WEIGHT                      Weight (int)\n"
+      "  -c CAP                         Cap (int)\n"
+      "  -p COMPRESS                    Compress (int)",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command
  2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
                   ` (4 preceding siblings ...)
  2010-05-19  8:33 ` [PATCH 5/6]xl: Add 'xl tmem-set' command Yang Hongyang
@ 2010-05-19  8:35 ` Yang Hongyang
  5 siblings, 0 replies; 7+ messages in thread
From: Yang Hongyang @ 2010-05-19  8:35 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com
  Cc: Dan Magenheimer, Keir Fraser, Stefano Stabellini

Add 'xl tmem-shared-auth' command

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r d432ff60f69d tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed May 19 23:37:22 2010 +0800
+++ b/tools/libxl/libxl.c	Thu May 20 00:11:32 2010 +0800
@@ -2917,3 +2917,19 @@
 
     return rc;
 }
+
+int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid,
+                           char* uuid, int auth)
+{
+    int rc;
+
+    rc = xc_tmem_auth(ctx->xch, domid, uuid, auth);
+    if (rc < 0) {
+        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+            "Can not set tmem shared auth");
+        return -1;
+    }
+
+    return rc;
+}
+
diff -r d432ff60f69d tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Wed May 19 23:37:22 2010 +0800
+++ b/tools/libxl/libxl.h	Thu May 20 00:11:32 2010 +0800
@@ -519,5 +519,7 @@
 int libxl_tmem_thaw(struct libxl_ctx *ctx, uint32_t domid);
 int libxl_tmem_set(struct libxl_ctx *ctx, uint32_t domid, char* name,
                    uint32_t set);
+int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid, char* uuid,
+                           int auth);
 #endif /* LIBXL_H */
 
diff -r d432ff60f69d tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed May 19 23:37:22 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Thu May 20 00:11:32 2010 +0800
@@ -3883,3 +3883,63 @@
 
     exit(0);
 }
+
+int main_tmem_shared_auth(int argc, char **argv)
+{
+    char *autharg = NULL;
+    char *endptr = NULL;
+    char *dom = NULL;
+    char *uuid = NULL;
+    int auth = -1;
+    int all = 0;
+    int opt;
+
+    while ((opt = getopt(argc, argv, "au:A:h")) != -1) {
+        switch (opt) {
+        case 'a':
+            all = 1;
+            break;
+        case 'u':
+            uuid = optarg;
+            break;
+        case 'A':
+            autharg = optarg;
+            break;
+        case 'h':
+            help("tmem-shared-auth");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind];
+    if (!dom && all == 0) {
+        fprintf(stderr, "You must specify -a or a domain id.\n\n");
+        help("tmem-shared-auth");
+        exit(1);
+    }
+
+    if (all)
+        domid = -1;
+    else
+        find_domain(dom);
+
+    if (uuid == NULL || autharg == NULL) {
+        fprintf(stderr, "No uuid or auth specified.\n\n");
+        help("tmem-shared-auth");
+        exit(1);
+    }
+
+    auth = strtol(autharg, &endptr, 10);
+    if (*endptr != '\0') {
+        fprintf(stderr, "Invalid auth, valid auth are <0|1>.\n\n");
+        exit(1);
+    }
+
+    libxl_tmem_shared_auth(&ctx, domid, uuid, auth);
+
+    exit(0);
+}
+
diff -r d432ff60f69d tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Wed May 19 23:37:22 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Thu May 20 00:11:32 2010 +0800
@@ -57,6 +57,7 @@
 int main_tmem_destroy(int argc, char **argv);
 int main_tmem_thaw(int argc, char **argv);
 int main_tmem_set(int argc, char **argv);
+int main_tmem_shared_auth(int argc, char **argv);
 
 void help(char *command);
 
diff -r d432ff60f69d tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Wed May 19 23:37:22 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Thu May 20 00:11:32 2010 +0800
@@ -257,6 +257,15 @@
       "  -c CAP                         Cap (int)\n"
       "  -p COMPRESS                    Compress (int)",
     },
+    { "tmem-shared-auth",
+      &main_tmem_shared_auth,
+      "De/authenticate shared tmem pool",
+      "[<Domain>|-a] [-u[=UUID] [-A[=AUTH]",
+      "  -a                             Authenticate for all tmem pools\n"
+      "  -u UUID                        Specify uuid\n"
+      "                                 (abcdef01-2345-6789-1234-567890abcdef)\n"
+      "  -A AUTH                        0=auth,1=deauth",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-19  8:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19  8:22 [PATCH 0/6]xl: Add 'xl tmem-*' commands Yang Hongyang
2010-05-19  8:26 ` [PATCH 1/6]xl: Add 'xl tmem-list' command Yang Hongyang
2010-05-19  8:29 ` [PATCH 2/6]xl: Add 'xl tmem-freeze' command Yang Hongyang
2010-05-19  8:31 ` [PATCH 3/6]xl: Add 'xl tmem-destroy' command Yang Hongyang
2010-05-19  8:32 ` [PATCH 4/6]xl: Add 'xl tmem-thaw' command Yang Hongyang
2010-05-19  8:33 ` [PATCH 5/6]xl: Add 'xl tmem-set' command Yang Hongyang
2010-05-19  8:35 ` [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command Yang Hongyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).