[CRIU] [PATCH 1/2] sockets: add debug messages ro restore process

Kinsbursky Stanislav skinsbursky at openvz.org
Fri Mar 2 09:36:30 EST 2012



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

---
 sockets.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/sockets.c b/sockets.c
index 7d0e887..1902d20 100644
--- a/sockets.c
+++ b/sockets.c
@@ -718,6 +718,7 @@ struct sk_packet {
 struct sk_packets_pool {
 	struct list_head packets_list;
 	int img_fd;
+	int pid;
 };
 
 static int read_sockets_queues(struct sk_packets_pool *pool)
@@ -725,8 +726,7 @@ static int read_sockets_queues(struct sk_packets_pool *pool)
 	struct sk_packet *pkt;
 	int ret;
 
-	pr_info("Trying to read socket queues image\n");
-
+	pr_info("%d: Trying to read socket queues image\n", pool->pid);
 	lseek(pool->img_fd, MAGIC_OFFSET, SEEK_SET);
 	while (1) {
 		struct sk_packet_entry tmp;
@@ -757,7 +757,7 @@ static int restore_socket_queue(struct sk_packets_pool *pool, int fd,
 	struct sk_packet *pkt, *tmp;
 	int ret;
 
-	pr_info("Trying to restore recv queue for %u\n", peer_id);
+	pr_info("%d: Restoring recv queue for %u: ", pool->pid, peer_id);
 
 	list_for_each_entry_safe(pkt, tmp, &pool->packets_list, list) {
 		struct sk_packet_entry *entry = &pkt->entry;
@@ -770,17 +770,20 @@ static int restore_socket_queue(struct sk_packets_pool *pool, int fd,
 
 		ret = sendfile(fd, pool->img_fd, &pkt->img_off, entry->length);
 		if (ret < 0) {
-			pr_perror("Failed to sendfile packet");
+			pr_perror("\n%d: Failed to sendfile packet", pool->pid);
 			return -1;
 		}
 		if (ret != entry->length) {
-			pr_err("Restored skb trimmed to %d/%d\n",
-					ret, entry->length);
+			pr_err("%d: Restored skb trimmed to %d/%d\n",
+					pool->pid, ret, entry->length);
 			return -1;
 		}
+		pr_info("\t%d: Restored %d-bytes skb\n", pool->pid,
+				entry->length);
 		list_del(&pkt->list);
 		xfree(pkt);
 	}
+	pr_info("%d: Queue restored for %u\n", pool->pid, peer_id);
 	return 0;
 }
 
@@ -840,6 +843,7 @@ static int run_connect_jobs(struct sk_packets_pool *pool)
 	struct unix_conn_job *cj, *next;
 	int i;
 
+	pr_info("%d: Run connect jobs\n", pool->pid);
 	cj = conn_jobs;
 	while (cj) {
 		int attempts = 8;
@@ -860,8 +864,8 @@ static int run_connect_jobs(struct sk_packets_pool *pool)
 				e = lookup_unix_listen(cj->peer, SOCK_DGRAM);
 
 			if (!e) {
-				pr_err("Bad in-flight socket peer %d\n",
-						cj->peer);
+				pr_err("%d: Bad in-flight socket peer %d\n",
+						pool->pid, cj->peer);
 				return -1;
 			}
 
@@ -877,7 +881,7 @@ try_again:
 				attempts--;
 				goto try_again; /* FIXME use avagin@ waiters */
 			}
-			pr_perror("Can't restore connection (c)");
+			pr_perror("%d: Can't restore connection (c)", pool->pid);
 			return -1;
 		}
 
@@ -1137,7 +1141,8 @@ static int prepare_unix_sockets(int pid)
 {
 	int usk_fd, ret = -1;
 	struct sk_packets_pool unix_pool = {
-		.packets_list = LIST_HEAD_INIT(unix_pool.packets_list),
+		.packets_list	= LIST_HEAD_INIT(unix_pool.packets_list),
+		.pid		= pid,
 	};
 
 	usk_fd = open_image_ro(CR_FD_UNIXSK, pid);



More information about the CRIU mailing list