[CRIU] [crtools-bot for Kinsbursky Stanislav ] IPC: show semaphores set

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 15 04:33:46 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 4101487f878a32fcc027ee18c745d9a0968f7f0b
Author: Kinsbursky Stanislav <skinsbursky at openvz.org>
Date:   Tue Feb 14 19:54:13 2012 +0300

    IPC: show semaphores set
    
    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         |   28 ++++++++++++++++++++++++++++
 namespaces.c     |    3 +++
 4 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/cr-show.c b/cr-show.c
index 9715910..660312e 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -520,6 +520,9 @@ static int cr_parse_file(struct cr_options *opts)
 	case IPCNS_MSG_MAGIC:
 		show_ipc_msg(fd);
 		break;
+	case IPCNS_SEM_MAGIC:
+		show_ipc_sem(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 981e2fa..41a7d9a 100644
--- a/include/ipc_ns.h
+++ b/include/ipc_ns.h
@@ -6,6 +6,7 @@
 extern void show_ipc_var(int fd);
 extern void show_ipc_shm(int fd);
 extern void show_ipc_msg(int fd);
+extern void show_ipc_sem(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 a03f754..9bba37f 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -440,6 +440,34 @@ static void show_var_entry(struct ipc_var_entry *entry)
 	ipc_sysctl_req(entry, CTL_PRINT);
 }
 
+static void show_ipc_sem_entries(int fd)
+{
+	pr_info("\nSemaphores sets:\n");
+	while (1) {
+		int size;
+		struct ipc_sem_entry entry;
+		u16 *values;
+
+		if (read_img_eof(fd, &entry) <= 0)
+			return;
+		print_ipc_sem_entry(&entry);
+		size = sizeof(u16) * entry.nsems;
+		values = xmalloc(size);
+		if (values == NULL)
+			return;
+		if (read_img_buf(fd, values, round_up(size, sizeof(u64))) <= 0)
+			return;
+		print_ipc_sem_array(entry.nsems, values);
+	}
+}
+
+void show_ipc_sem(int fd)
+{
+	pr_img_head(CR_FD_IPCNS);
+	show_ipc_sem_entries(fd);
+	pr_img_tail(CR_FD_IPCNS);
+}
+
 static void show_ipc_msg_entries(int fd)
 {
 	pr_info("\nMessage queues:\n");
diff --git a/namespaces.c b/namespaces.c
index aa0b572..b64f9b0 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -134,6 +134,9 @@ int try_show_namespaces(int ns_pid)
 	if (fdset->fds[CR_FD_IPCNS_MSG] != -1)
 		show_ipc_msg(fdset->fds[CR_FD_IPCNS_MSG]);
 
+	if (fdset->fds[CR_FD_IPCNS_SEM] != -1)
+		show_ipc_sem(fdset->fds[CR_FD_IPCNS_SEM]);
+
 	close_cr_fdset(&fdset);
 	return 0;
 }


More information about the CRIU mailing list