[CRIU] [PATCH 07/28] utils: Change open_fd_of_real_pid() to be open_fd_of_vpid()
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Jun 5 20:24:29 MSK 2017
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/util.h | 2 +-
criu/shmem.c | 5 ++---
criu/util.c | 7 +++++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/criu/include/util.h b/criu/include/util.h
index 91587ef1c..ec93fd5c6 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -307,7 +307,7 @@ extern int epoll_del_rfd(int epfd, struct epoll_rfd *rfd);
extern int epoll_run_rfds(int epfd, struct epoll_event *evs, int nr_fds, int tmo);
extern int epoll_prepare(int nr_events, struct epoll_event **evs);
-extern int open_fd_of_real_pid(pid_t pid, int fd, int flags);
+extern int open_fd_of_vpid(pid_t pid, int fd, int flags);
extern int call_in_child_process(int (*fn)(void *), void *arg);
diff --git a/criu/shmem.c b/criu/shmem.c
index 2af8f8802..ce3746a5c 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -441,13 +441,12 @@ int collect_shmem(int pid, struct vma_area *vma)
static int shmem_wait_and_open(struct shmem_info *si, VmaEntry *vi)
{
- int pid, ret;
+ int ret;
pr_info("Waiting for the %lx shmem to appear\n", si->shmid);
futex_wait_while(&si->lock, 0);
- pid = pstree_pid_by_virt(si->pid)->real;
- ret = open_fd_of_real_pid(pid, si->fd, O_RDWR);
+ ret = open_fd_of_vpid(si->pid, si->fd, O_RDWR);
futex_inc_and_wake(&si->lock);
if (ret < 0)
return -1;
diff --git a/criu/util.c b/criu/util.c
index 7ff40e2f8..93337760b 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -52,6 +52,7 @@
#include "servicefd.h"
#include "cr-service.h"
#include "files.h"
+#include "pstree.h"
#include "cr-errno.h"
@@ -1228,12 +1229,14 @@ static int fn_open_proc_rw(void *path, int fd, pid_t pid)
return openat(get_service_fd(CR_PROC_FD_OFF), path, O_RDWR);
}
-int open_fd_of_real_pid(pid_t pid, int fd, int flags)
+int open_fd_of_vpid(pid_t pid, int fd, int flags)
{
+ struct pstree_item *item;
char path[64];
int ret;
- ret = sprintf(path, "%d/fd/%d", pid, fd);
+ item = pstree_pid_by_virt(pid)->item;
+ ret = sprintf(path, "%d/fd/%d", item->pid->real, fd);
pr_info("Opening real [%s]\n", path);
if (flags == O_RDONLY)
ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
More information about the CRIU
mailing list