[CRIU] [PATCH 6/8] show: UNIX sockets queue support

Kinsbursky Stanislav skinsbursky at openvz.org
Tue Feb 28 05:31:47 EST 2012


Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>

---
 cr-show.c         |    7 +++++++
 include/sockets.h |    1 +
 sockets.c         |   24 ++++++++++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/cr-show.c b/cr-show.c
index 2f9cb84..1ecbcdd 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -503,6 +503,9 @@ static int cr_parse_file(struct cr_options *opts)
 	case INETSK_MAGIC:
 		show_inetsk(fd);
 		break;
+	case SK_QUEUES_MAGIC:
+		show_sk_queues(fd);
+		break;
 	case ITIMERS_MAGIC:
 		show_itimers(fd);
 		break;
@@ -550,6 +553,10 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts)
 	if (ret)
 		goto out;
 
+	ret = show_sk_queues(cr_fdset->fds[CR_FD_SK_QUEUES]);
+	if (ret)
+		goto out;
+
 	close_cr_fdset(&cr_fdset);
 
 	ret = try_show_namespaces(pid);
diff --git a/include/sockets.h b/include/sockets.h
index f9f6690..960b918 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -29,5 +29,6 @@ extern int collect_sockets(void);
 extern int prepare_sockets(int pid);
 extern void show_unixsk(int fd);
 extern void show_inetsk(int fd);
+extern int show_sk_queues(int fd);
 
 #endif /* CR_SOCKETS_H__ */
diff --git a/sockets.c b/sockets.c
index 97746bf..1e02681 100644
--- a/sockets.c
+++ b/sockets.c
@@ -195,8 +195,8 @@ static void show_one_unix(char *act, const struct unix_sk_desc *sk)
 
 static void show_one_unix_img(const char *act, const struct unix_sk_entry *e)
 {
-	pr_debug("\t%s: fd %d type %d state %d name %d bytes\n",
-		act, e->fd, e->type, e->state, e->namelen);
+	pr_info("\t%s: id %u fd %d type %d state %d name %d bytes\n",
+		act, e->id, e->fd, e->type, e->state, e->namelen);
 }
 
 static int can_dump_inet_sk(const struct inet_sk_desc *sk)
@@ -1284,3 +1284,23 @@ out:
 	pr_img_tail(CR_FD_UNIXSK);
 }
 
+int show_sk_queues(int fd)
+{
+	struct sk_packet_entry pe;
+	int ret;
+
+	while (1) {
+		ret = read_img_eof(fd, &pe);
+		if (ret <= 0)
+			return ret;
+
+		pr_info("pkt for %u length %u bytes\n",
+				pe.id_for, pe.length);
+
+		ret = read_img_buf(fd, buf, pe.length);
+		if (ret < 0)
+			return ret;
+
+		pr_info("\t`-[%*s]\n", pe.length, buf);
+	}
+}



More information about the CRIU mailing list