xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>,
	Keir Fraser <keir.fraser@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command
Date: Wed, 19 May 2010 16:35:00 +0800	[thread overview]
Message-ID: <4BF3A2B4.8040106@cn.fujitsu.com> (raw)
In-Reply-To: <4BF39FB9.3050005@cn.fujitsu.com>

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

      parent reply	other threads:[~2010-05-19  8:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Yang Hongyang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BF3A2B4.8040106@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).