[CRIU] Re: Before we do the CRIU v0.1 release

Cyrill Gorcunov gorcunov at openvz.org
Thu Jul 19 13:58:13 EDT 2012


On Thu, Jul 19, 2012 at 08:10:14PM +0400, Cyrill Gorcunov wrote:

>  - show method invoked via pb_show_plain which I guess
>    should be extended since only a top level entries
>    are shown

Here is a patch on top of this one for moving fancy output
on CoreEntry back. Feel free either accept it or drop it
if we don't need such output.

	Cyrill
-------------- next part --------------
>From b4d537736dc00199e1586651aa74ed70e860273d Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 19 Jul 2012 21:49:29 +0400
Subject: [PATCH] protobuf: Restore fancy "show" for CoreEntry

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-show.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/cr-show.c b/cr-show.c
index c6226e9..12f71ba 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -52,24 +52,6 @@
 #define PR_SYMBOL(sym)			\
 	(isprint(sym) ? sym : '.')
 
-#define pr_regs4(s, n1, n2, n3, n4)	\
-	pr_msg("%8s: 0x%16lx "		\
-	       "%8s: 0x%16lx "		\
-	       "%8s: 0x%16lx "		\
-	       "%8s: 0x%16lx\n",	\
-	       #n1, s.n1,		\
-	       #n2, s.n2,		\
-	       #n3, s.n3,		\
-	       #n4, s.n4)
-
-#define pr_regs3(s, n1, n2, n3)		\
-	pr_msg("%8s: 0x%16lx "		\
-	       "%8s: 0x%16lx "		\
-	       "%8s: 0x%16lx\n",	\
-	       #n1, s.n1,		\
-	       #n2, s.n2,		\
-	       #n3, s.n3)
-
 static LIST_HEAD(pstree_list);
 
 void show_files(int fd_files, struct cr_options *o)
@@ -391,9 +373,86 @@ static inline char *task_state_str(int state)
 	}
 }
 
+static void show_core_rest(TaskCoreEntry *tc)
+{
+	pr_msg("\t---[ Task parameters ]---\n");
+	pr_msg("\tPersonality:  %#x\n", tc->personality);
+	pr_msg("\tCommand:      %s\n", tc->comm);
+	pr_msg("\tState:        %d (%s)\n",
+	       (int)tc->task_state,
+	       task_state_str((int)tc->task_state));
+
+	pr_msg("\t   Exit code: %u\n",
+	       (unsigned int)tc->exit_code);
+
+	pr_msg("\tBlkSig: 0x%lx\n", tc->blk_sigset);
+	pr_msg("\n");
+}
+
+static void show_core_ids(CoreIdsEntry *ids)
+{
+	pr_msg("\t---[ Task IDS ]---\n");
+	pr_msg("\tVM:      %#x\n", ids->vm_id);
+	pr_msg("\tFS:      %#x\n", ids->fs_id);
+	pr_msg("\tFILES:   %#x\n", ids->files_id);
+	pr_msg("\tSIGHAND: %#x\n", ids->sighand_id);
+}
+
+static void show_core_regs(UserX86RegsEntry *regs)
+{
+#define pr_regs4(s, n1, n2, n3, n4)	\
+	pr_msg("\t%8s: 0x%-16lx "	\
+	       "%8s: 0x%-16lx "		\
+	       "%8s: 0x%-16lx "		\
+	       "%8s: 0x%-16lx\n",	\
+	       #n1, s->n1,		\
+	       #n2, s->n2,		\
+	       #n3, s->n3,		\
+	       #n4, s->n4)
+
+#define pr_regs3(s, n1, n2, n3)		\
+	pr_msg("\t%8s: 0x%-16lx "	\
+	       "%8s: 0x%-16lx "		\
+	       "%8s: 0x%-16lx\n",	\
+	       #n1, s->n1,		\
+	       #n2, s->n2,		\
+	       #n3, s->n3)
+
+	pr_msg("\t---[ GP registers set ]---\n");
+
+	pr_regs4(regs, cs, ip, ds, es);
+	pr_regs4(regs, ss, sp, fs, gs);
+	pr_regs4(regs, di, si, dx, cx);
+	pr_regs4(regs, ax, r8, r9, r10);
+	pr_regs4(regs, r11, r12, r13, r14);
+	pr_regs3(regs, r15, bp, bx);
+	pr_regs4(regs, orig_ax, flags, fs_base, gs_base);
+	pr_msg("\n");
+}
+
 void show_core(int fd_core, struct cr_options *o)
 {
-	pb_show_plain(fd_core, core_entry);
+	CoreEntry *core;
+
+	pr_img_head(CR_FD_CORE);
+	if (pb_read_eof(fd_core, &core, core_entry) > 0) {
+
+		pr_msg("\t---[ General ]---\n");
+		pr_msg("\tversion:         0x%x\n", core->version);
+		pr_msg("\tmtype:           0x%x\n", core->mtype);
+		pr_msg("\tclear_tid_addr:  0x%lx\n", core->clear_tid_addr);
+		pr_msg("\n");
+
+		/* Continue if we support it */
+		if (core->version == 1 && core->mtype == CORE_ENTRY__MARCH__X86_64) {
+			show_core_regs(core->arch_x86->gpregs);
+			show_core_rest(core->tc);
+			show_core_ids(core->ids);
+		}
+
+		core_entry__free_unpacked(core, NULL);
+	}
+	pr_img_tail(CR_FD_CORE);
 }
 
 void show_mm(int fd_mm, struct cr_options *o)
-- 
1.7.7.6



More information about the CRIU mailing list