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

infect: Introduce flags on ictx

These will control various behavior of infection engine. For now
only fault-injections.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 71a4b46c
......@@ -28,8 +28,12 @@ struct thread_ctx {
struct infect_ctx {
int *p_sock;
unsigned long flags; /* fine-tune (e.g. faults) */
};
#define INFECT_NO_MEMFD 0x1 /* don't use memfd() */
#define INFECT_FAIL_CONNECT 0x2 /* make parasite connect() fail */
/* parasite control block */
struct parasite_ctl {
int rpid; /* Real pid of the victim */
......
......@@ -474,7 +474,7 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
}
/* Check a case when parasite can't initialize a command socket */
if (fault_injected(FI_PARASITE_CONNECT))
if (ctl->ictx.flags & INFECT_FAIL_CONNECT)
args->h_addr_len = gen_parasite_saddr(&args->h_addr, getpid() + 1);
/*
......@@ -1317,7 +1317,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
int ret, fd, lfd;
bool __maybe_unused compat_task = !seized_native(ctl);
if (fault_injected(FI_NO_MEMFD))
if (ctl->ictx.flags & INFECT_NO_MEMFD)
return 1;
BUILD_BUG_ON(sizeof(orig_code) < sizeof(long));
......@@ -1482,6 +1482,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk;
if (fault_injected(FI_NO_MEMFD))
ctl->ictx.flags |= INFECT_NO_MEMFD;
if (fault_injected(FI_PARASITE_CONNECT))
ctl->ictx.flags |= INFECT_FAIL_CONNECT;
parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
......
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