From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Hongyang Subject: [PATCH 6/6]xl: Add 'xl tmem-shared-auth' command Date: Wed, 19 May 2010 16:35:00 +0800 Message-ID: <4BF3A2B4.8040106@cn.fujitsu.com> References: <4BF39FB9.3050005@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4BF39FB9.3050005@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" Cc: Dan Magenheimer , Keir Fraser , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Add 'xl tmem-shared-auth' command Signed-off-by: Yang Hongyang 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", + "[|-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