[CRIU] [crtools-bot for Kinsbursky Stanislav ] IPC: show shared memory dump content

Cyrill Gorcunov gorcunov at openvz.org
Thu Feb 9 04:21:46 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 516099d885924652e4df191a23b253f537c2a1d9
Author: Kinsbursky Stanislav <skinsbursky at openvz.org>
Date:   Thu Feb 9 12:09:48 2012 +0300

    IPC: show shared memory dump content
    
    Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
    Acked-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-show.c        |    3 +++
 include/ipc_ns.h |    1 +
 ipc_ns.c         |   25 +++++++++++++++++++++++++
 namespaces.c     |    3 +++
 4 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/cr-show.c b/cr-show.c
index 948f51f..00eb0f5 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -517,6 +517,9 @@ static int cr_parse_file(struct cr_options *opts)
 	case IPCNS_VAR_MAGIC:
 		show_ipc_var(fd);
 		break;
+	case IPCNS_SHM_MAGIC:
+		show_ipc_shm(fd);
+		break;
 	default:
 		pr_err("Unknown magic %x on %s\n", magic, opts->show_dump_file);
 		goto err;
diff --git a/include/ipc_ns.h b/include/ipc_ns.h
index 60fc1a2..2654b64 100644
--- a/include/ipc_ns.h
+++ b/include/ipc_ns.h
@@ -4,6 +4,7 @@
 #include "crtools.h"
 
 extern void show_ipc_var(int fd);
+extern void show_ipc_shm(int fd);
 extern int dump_ipc_ns(int ns_pid, struct cr_fdset *fdset);
 extern int prepare_ipc_ns(int pid);
 
diff --git a/ipc_ns.c b/ipc_ns.c
index 0ad2a67..d6cebc7 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -246,6 +246,31 @@ static void show_var_entry(struct ipc_var_entry *entry)
 	ipc_sysctl_req(entry, CTL_PRINT);
 }
 
+static void show_ipc_shm_entries(int fd)
+{
+	pr_info("\nShared memory segments:\n");
+	while (1) {
+		int ret;
+		struct ipc_shm_entry shm;
+
+		ret = read_img_eof(fd, &shm);
+		if (ret <= 0)
+			return;
+
+		print_ipc_shm(&shm);
+
+		if (lseek(fd, round_up(shm.size, sizeof(u32)), SEEK_CUR) == (off_t) -1)
+			return;
+	}
+}
+
+void show_ipc_shm(int fd)
+{
+	pr_img_head(CR_FD_IPCNS);
+	show_ipc_shm_entries(fd);
+	pr_img_tail(CR_FD_IPCNS);
+}
+
 static void show_ipc_var_entry(int fd)
 {
 	int ret;
diff --git a/namespaces.c b/namespaces.c
index 6d90870..dd00b3c 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -128,6 +128,9 @@ int try_show_namespaces(int ns_pid)
 	if (fdset->fds[CR_FD_IPCNS_VAR] != -1)
 		show_ipc_var(fdset->fds[CR_FD_IPCNS_VAR]);
 
+	if (fdset->fds[CR_FD_IPCNS_SHM] != -1)
+		show_ipc_shm(fdset->fds[CR_FD_IPCNS_SHM]);
+
 	close_cr_fdset(&fdset);
 	return 0;
 }


More information about the CRIU mailing list