Commit f3021b6a authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

infect: Remove criu util.h from infect

This includes

* The close_safe() routine for infect
* Callback for opening proc files on infect_ctx
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent dec9a250
......@@ -89,6 +89,9 @@ extern k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl);
struct rt_sigframe;
typedef int (*open_proc_fn)(int pid, int mode, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
struct infect_ctx {
int *p_sock;
......@@ -103,6 +106,8 @@ struct infect_ctx {
unsigned long flags; /* fine-tune (e.g. faults) */
void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */
open_proc_fn open_proc;
};
extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *);
......
......@@ -6,6 +6,7 @@
#include <signal.h>
#include <sys/mman.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/seccomp.h>
#include "pie-relocs.h"
......@@ -15,9 +16,6 @@
#include "common/xmalloc.h"
#include "lock.h"
#include <fcntl.h>
#include "util.h"
#include "uapi/std/syscall-codes.h"
#include "uapi/std/asm/syscall-types.h"
#include "compel/include/asm/ptrace.h"
......@@ -46,6 +44,14 @@
#define SI_EVENT(_si_code) (((_si_code) & 0xFFFF) >> 8)
static inline void close_safe(int *pfd)
{
if (*pfd > -1) {
close(*pfd);
*pfd = -1;
}
}
int compel_stop_task(int pid)
{
int ret;
......@@ -626,7 +632,7 @@ static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size)
ctl->map_length = round_up(size, page_size());
fd = open_proc_rw(ctl->rpid, "map_files/%p-%p",
fd = ctl->ictx.open_proc(ctl->rpid, O_RDWR, "map_files/%p-%p",
ctl->remote_map, ctl->remote_map + ctl->map_length);
if (fd < 0)
return -1;
......@@ -685,7 +691,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
return fd;
ctl->map_length = round_up(size, page_size());
lfd = open_proc_rw(ctl->rpid, "fd/%d", fd);
lfd = ctl->ictx.open_proc(ctl->rpid, O_RDWR, "fd/%d", fd);
if (lfd < 0)
goto err_cure;
......
......@@ -543,6 +543,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
ictx = compel_infect_ctx(ctl);
ictx->open_proc = do_open_proc;
ictx->child_handler = sigchld_handler;
ictx->p_sock = &dmpi(item)->netns->net.seqsk;
ictx->save_regs = save_task_regs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment