add -p option to ckptinfo to dump pids tree
RFC PATCH 1/1 add -p option to ckptinfo to dump pids tree
This will be used by a restart wrapper to analyze /proc/$$/mountinfo.
Also add the new rpids field to ckpt_pids to reflect kernel.
It depends on the patch I just sent for linux-cr adding rpid to struct ckpt_pids.
Signed-off-by Serge E. Hallyn <serue-r/[email protected]>
--- ckptinfo.c | 36 +++++++++++++++++++++++++++++++++++- include/linux/checkpoint_hdr.h | 1 + 2 files changed, 36 insertions(+), 1 deletions(-)
ckptinfo.c +35 -1
@@ -28,6 +28,7 @@ static char usage_str[] ="\tOptions:\n" "\t -h,--help print this help message\n" "\t -e,--error show error messages\n" +"\t -p,--pids just list process tree\n" "\t -v,--verbose verbose output\n" "\t --show-arch-regs show registers contents\n" "" ;
@@ -36,6 +37,7 @@ struct args {int error;int verbose;int show_arch_regs; +int show_process_tree; };int __verbose;
@@ -55,6 +57,7 @@ static int image_parse_vma(struct ckpt_hdr *h, int fd, struct args *args);static int image_parse_file (struct ckpt_hdr *h,int fd,struct args *args);static int image_parse_objref (struct ckpt_hdr *h,int fd,struct args *args);static int image_parse_error (struct ckpt_hdr *h,int fd,struct args *args); +static void show_tasks (struct ckpt_hdr *h,int numpids);#ifdef __i386__#define __HAVE_image_parse_cpu
@@ -85,10 +88,11 @@ static void parse_args(struct args *args, int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "error", no_argument, NULL, 'e' }, { "verbose", no_argument, NULL, 'v' }, + { "pids", no_argument, NULL, 'p' }, { "show-arch-regs", no_argument, NULL, 1 }, { NULL, 0, NULL, 0 } }; -static char optc[] ="hve" ; +static char optc[] ="hvep" ;while (1 ) {int c =getopt_long (argc, argv, optc, opts,NULL );
@@ -99,6 +103,9 @@ static void parse_args(struct args *args, int argc, char *argv[])exit (1 );case 'h' :usage (usage_str); +case 'p' : + args->show_process_tree =1 ; +break ;case 'e' : args->error =1 ;break ;
@@ -208,6 +215,7 @@ static int image_parse(int fd, struct args *args) {struct ckpt_hdr *h;int ret; +int numpids, next_read_pids =0 ; do { ret = image_read_obj(fd, &h);
@@ -215,6 +223,11 @@ static int image_parse(int fd, struct args *args)break ;if (!h)continue ; +if (next_read_pids) { + next_read_pids =0 ; +if (args->show_process_tree) +show_tasks (h, numpids); + }switch (h->type) {case CKPT_HDR_OBJREF : ret =image_parse_objref (h, fd, args);
@@ -232,12 +245,33 @@ static int image_parse(int fd, struct args *args) ret =image_parse_error (h, fd, args);break ; } +if (h->type ==CKPT_HDR_TREE ) { +struct ckpt_hdr_tree *t = (struct ckpt_hdr_tree *) h; + numpids = t->nr_tasks; + next_read_pids =1 ; + }free (h); }while (ret >0 );return ret; } +struct ckpt_hdr_pids { +struct ckpt_hdr h; +struct ckpt_pids p; +}; + +static void show_tasks (struct ckpt_hdr *h,int numpids) +{ +struct ckpt_hdr_pids *pp = (struct ckpt_hdr_pids *)h; +struct ckpt_pids *p = &pp->p; +int i; + +for (i=0 ; i<numpids; i++) +printf ("Task %d: rpid %d pid %d vppid %d\n" , i, p[i].rpid, + p[i].vpid, p[i].vppid); +} +static int image_parse_objref (struct ckpt_hdr *h,int fd,struct args *args) {struct ckpt_hdr_objref *hh = (struct ckpt_hdr_objref *) h;
include/linux/checkpoint_hdr.h +1 -0
@@ -321,6 +321,7 @@ struct ckpt_hdr_tree { } __attribute__((aligned(8)));struct ckpt_pids { +__s32 rpid;__s32 vpid;__s32 vppid;__s32 vtgid;
Signature · 1 line
1.6.0.6
A message that is not in the archive (sent off-list or not yet received): 20100309210540.GB5789-r/[email protected]
I added a '-p' flag to ckptinfo based on this patch (will push to repository later).
Thanks,
Oren.
Quoted 130 lines · Serge E. Hallyn
This will be used by a restart wrapper to analyze
/proc/$$/mountinfo.Also add the new rpids field to
ckpt_pidsto reflect kernel.It depends on the patch I just sent for linux-cr adding rpid to struct
ckpt_pids.Signed-off-by Serge E. Hallyn <serue-r/[email protected]>--- ckptinfo.c | 36 +++++++++++++++++++++++++++++++++++- include/linux/checkpoint_hdr.h | 1 + 2 files changed, 36 insertions(+), 1 deletions(-)ckptinfo.c +35
-1@@ -28,6 +28,7 @@ static char usage_str[] ="\tOptions:\n" "\t -h,--help print this help message\n" "\t -e,--error show error messages\n" +"\t -p,--pids just list process tree\n" "\t -v,--verbose verbose output\n" "\t --show-arch-regs show registers contents\n" "" ;@@ -36,6 +37,7 @@ struct args {int error;int verbose;int show_arch_regs; +int show_process_tree; };int __verbose;@@ -55,6 +57,7 @@ static int image_parse_vma(struct ckpt_hdr *h, int fd, struct args *args);static int image_parse_file (struct ckpt_hdr *h,int fd,struct args *args);static int image_parse_objref (struct ckpt_hdr *h,int fd,struct args *args);static int image_parse_error (struct ckpt_hdr *h,int fd,struct args *args); +static void show_tasks (struct ckpt_hdr *h,int numpids);#ifdef __i386__#define __HAVE_image_parse_cpu@@ -85,10 +88,11 @@ static void parse_args(struct args *args, int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "error", no_argument, NULL, 'e' }, { "verbose", no_argument, NULL, 'v' }, + { "pids", no_argument, NULL, 'p' }, { "show-arch-regs", no_argument, NULL, 1 }, { NULL, 0, NULL, 0 } }; -static char optc[] ="hve" ; +static char optc[] ="hvep" ;while (1 ) {int c =getopt_long (argc, argv, optc, opts,NULL );@@ -99,6 +103,9 @@ static void parse_args(struct args *args, int argc, char *argv[])exit (1 );case 'h' :usage (usage_str); +case 'p' : + args->show_process_tree =1 ; +break ;case 'e' : args->error =1 ;break ;@@ -208,6 +215,7 @@ static int image_parse(int fd, struct args *args) {struct ckpt_hdr *h;int ret; +int numpids, next_read_pids =0 ; do { ret = image_read_obj(fd, &h);@@ -215,6 +223,11 @@ static int image_parse(int fd, struct args *args)break ;if (!h)continue ; +if (next_read_pids) { + next_read_pids =0 ; +if (args->show_process_tree) +show_tasks (h, numpids); + }switch (h->type) {case CKPT_HDR_OBJREF : ret =image_parse_objref (h, fd, args);@@ -232,12 +245,33 @@ static int image_parse(int fd, struct args *args) ret =image_parse_error (h, fd, args);break ; } +if (h->type ==CKPT_HDR_TREE ) { +struct ckpt_hdr_tree *t = (struct ckpt_hdr_tree *) h; + numpids = t->nr_tasks; + next_read_pids =1 ; + }free (h); }while (ret >0 );return ret; } +struct ckpt_hdr_pids { +struct ckpt_hdr h; +struct ckpt_pids p; +}; + +static void show_tasks (struct ckpt_hdr *h,int numpids) +{ +struct ckpt_hdr_pids *pp = (struct ckpt_hdr_pids *)h; +struct ckpt_pids *p = &pp->p; +int i; + +for (i=0 ; i<numpids; i++) +printf ("Task %d: rpid %d pid %d vppid %d\n" , i, p[i].rpid, + p[i].vpid, p[i].vppid); +} +static int image_parse_objref (struct ckpt_hdr *h,int fd,struct args *args) {struct ckpt_hdr_objref *hh = (struct ckpt_hdr_objref *) h;include/linux/checkpoint_hdr.h +1
-0@@ -321,6 +321,7 @@ struct ckpt_hdr_tree { } __attribute__((aligned(8)));struct ckpt_pids { +__s32 rpid;__s32 vpid;__s32 vppid;__s32 vtgid;