[CRIU] [crtools-bot for Kinsbursky Stanislav ] dump: UNIX sockets queue support

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 29 08:42:30 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 131f5a1d4968feebd0de53428d763f651064290d
Author: Kinsbursky Stanislav <skinsbursky at openvz.org>
Date:   Wed Feb 29 16:07:04 2012 +0300

    dump: UNIX sockets queue support
    
    Based on xemul@ patches.
    
    Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
    Acked-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 sockets.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/sockets.c b/sockets.c
index 6c7b99f..a8e58b0 100644
--- a/sockets.c
+++ b/sockets.c
@@ -83,6 +83,24 @@ struct inet_sk_desc {
 	unsigned int		src_addr[4];
 };
 
+static int unix_sk_queue_add(int fd, const struct unix_sk_desc *sd,
+			     struct sk_queue *queue)
+{
+	struct sk_queue_entry *next, *new;
+
+	new = xmalloc(sizeof(struct sk_queue_entry));
+	if (!new)
+		return -1;
+
+	new->item.fd = fd;
+	new->item.type = sd->type;
+	new->item.sk_id = sd->sd.ino;
+	new->next = queue->list;
+
+	queue->list = new;
+	queue->entries++;
+	return 0;
+}
 
 #define SK_HASH_SIZE		32
 #define SK_HASH_LINK(head, key, elem)					\
@@ -260,17 +278,6 @@ static int can_dump_unix_sk(const struct unix_sk_desc *sk)
 	case TCP_LISTEN:
 		break;
 	case TCP_ESTABLISHED:
-		if (sk->rqlen) {
-			/*
-			 * The hard case :( Currentl there's no way to
-			 * clone the sk queue. Even the MSG_PEEK doesn't
-			 * help, since it picks up the head of the queue
-			 * always. Some more patches should go
-			 */
-			pr_err("Non empty queue\n");
-			return 0;
-		}
-
 		break;
 	case TCP_CLOSE:
 		if (sk->type != SOCK_DGRAM)
@@ -340,6 +347,11 @@ static int dump_one_unix(const struct socket_desc *_sk, int fd,
 	if (write_img_buf(cr_fdset->fds[CR_FD_UNIXSK], sk->name, ue.namelen))
 		goto err;
 
+	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
+				sk->state == TCP_LISTEN))
+		if (unix_sk_queue_add(fd, sk, queue))
+			goto err;
+
 	pr_info("Dumping unix socket at %d\n", fd);
 	show_one_unix("Dumping", sk);
 	show_one_unix_img("Dumped", &ue);


More information about the CRIU mailing list