[CRIU] [PATCH v4 2/4] IPC: show shared memory dump content
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu Feb 9 04:09:48 EST 2012
Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
---
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