mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
Add restoring of unnamed unix sockets.
Added functionality for restoring unnamed unix sockets
using already implemented feature - inherit fd and using same command line
option.
Usage example:
criu restore -d -D images -o restore.log --pidfile restore.pid -v4 \
-x --inherit-fd fd[3]:socket:[9677263]
Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
79fd764ae6
commit
b790b586eb
2 changed files with 29 additions and 4 deletions
|
|
@ -41,6 +41,7 @@
|
|||
#define USK_EXTERN (1 << 0)
|
||||
#define USK_SERVICE (1 << 1)
|
||||
#define USK_CALLBACK (1 << 2)
|
||||
#define USK_INHERIT (1 << 3)
|
||||
|
||||
/*
|
||||
* VMA_AREA status:
|
||||
|
|
|
|||
32
sk-unix.c
32
sk-unix.c
|
|
@ -160,7 +160,6 @@ static bool unix_sk_exception_lookup_id(ino_t ino)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int write_unix_entry(struct unix_sk_desc *sk)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -843,16 +842,19 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
|
|||
if (ui->ue->uflags & USK_CALLBACK)
|
||||
return 0;
|
||||
|
||||
pr_info("\tConnect %#x to %#x\n", ui->ue->ino, peer->ue->ino);
|
||||
|
||||
/* Skip external sockets */
|
||||
if (!list_empty(&peer->d.fd_info_head))
|
||||
futex_wait_while(&peer->prepared, 0);
|
||||
|
||||
if (ui->ue->uflags & USK_INHERIT)
|
||||
return 0;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
memcpy(&addr.sun_path, peer->name, peer->ue->name.len);
|
||||
|
||||
pr_info("\tConnect %#x to %#x\n", ui->ue->ino, peer->ue->ino);
|
||||
|
||||
if (prep_unix_sk_cwd(peer))
|
||||
return -1;
|
||||
|
||||
|
|
@ -1139,7 +1141,13 @@ static int open_unix_sk(struct file_desc *d)
|
|||
struct unix_sk_info *ui;
|
||||
|
||||
ui = container_of(d, struct unix_sk_info, d);
|
||||
if (ui->flags & USK_PAIR_MASTER)
|
||||
|
||||
int unixsk_fd = -1;
|
||||
|
||||
if (inherited_fd(d, &unixsk_fd)) {
|
||||
ui->ue->uflags |= USK_INHERIT;
|
||||
return unixsk_fd;
|
||||
} else if (ui->flags & USK_PAIR_MASTER)
|
||||
return open_unixsk_pair_master(ui);
|
||||
else if (ui->flags & USK_PAIR_SLAVE)
|
||||
return open_unixsk_pair_slave(ui);
|
||||
|
|
@ -1147,11 +1155,27 @@ static int open_unix_sk(struct file_desc *d)
|
|||
return open_unixsk_standalone(ui);
|
||||
}
|
||||
|
||||
static char *socket_d_name(struct file_desc *d, char *buf, size_t s)
|
||||
{
|
||||
struct unix_sk_info *ui;
|
||||
|
||||
ui = container_of(d, struct unix_sk_info, d);
|
||||
|
||||
if (snprintf(buf, s, "socket:[%d]", ui->ue->ino) >= s) {
|
||||
pr_err("Not enough room for unixsk %d identifier string\n",
|
||||
ui->ue->ino);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static struct file_desc_ops unix_desc_ops = {
|
||||
.type = FD_TYPES__UNIXSK,
|
||||
.open = open_unix_sk,
|
||||
.post_open = post_open_unix_sk,
|
||||
.want_transport = unixsk_should_open_transport,
|
||||
.name = socket_d_name,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue