xl: Add 'xl tmem-*' commands
cover xl: Add 'xl tmem-*' commands
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
Signature · 2 lines
Regards Yang Hongyang
PATCH 1/6 xl: Add 'xl tmem-list' command
Add 'xl tmem-list' command
tools/libxl/libxl.c +15 -0
@@ -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); +}
tools/libxl/libxl.h +2 -0
@@ -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 */
tools/libxl/xl_cmdimpl.c +46 -0
49 lines not on this page · raw message
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +6 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang
PATCH 2/6 xl: Add 'xl tmem-freeze' command
In reply to Yang HongyangAdd 'xl tmem-freeze' command
tools/libxl/libxl.c +15 -0
@@ -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; +}
tools/libxl/libxl.h +1 -0
@@ -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 */
tools/libxl/xl_cmdimpl.c +37 -0
@@ -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 ); +} +
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +6 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang
PATCH 3/6 xl: Add 'xl tmem-destroy' command
In reply to Yang HongyangAdd 'xl tmem-destroy' command
tools/libxl/libxl.c +15 -0
@@ -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; +}
tools/libxl/libxl.h +1 -1
@@ -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 */
tools/libxl/xl_cmdimpl.c +36 -0
@@ -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 ); +} +
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +6 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang
PATCH 4/6 xl: Add 'xl tmem-thaw' command
In reply to Yang HongyangAdd 'xl tmem-thaw' command
tools/libxl/libxl.c +15 -0
@@ -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; +}
tools/libxl/libxl.h +1 -0
@@ -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 */
tools/libxl/xl_cmdimpl.c +36 -0
@@ -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 ); +} +
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +6 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang
PATCH 5/6 xl: Add 'xl tmem-set' command
In reply to Yang HongyangAdd 'xl tmem-set' command
tools/libxl/libxl.c +32 -0
@@ -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; +}
tools/libxl/libxl.h +2 -0
@@ -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 */
tools/libxl/xl_cmdimpl.c +61 -0
64 lines not on this page · raw message
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +9 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang
PATCH 6/6 xl: Add 'xl tmem-shared-auth' command
In reply to Yang HongyangAdd 'xl tmem-shared-auth' command
tools/libxl/libxl.c +16 -0
@@ -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; +} +
tools/libxl/libxl.h +2 -0
@@ -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 */
tools/libxl/xl_cmdimpl.c +60 -0
63 lines not on this page · raw message
tools/libxl/xl_cmdimpl.h +1 -0
@@ -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);
tools/libxl/xl_cmdtable.c +9 -0
@@ -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 );
Signature · 2 lines
Regards Yang Hongyang