mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
infect: Introduce API to configure the infection
I.e. -- the infect_ctX structure. Now it's in infect.h and is aimed for compel sources. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
5e75d49946
commit
f98a557529
@@ -24,8 +24,8 @@
|
|||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#include "uapi/std/syscall-codes.h"
|
#include "uapi/std/syscall-codes.h"
|
||||||
#include "kerndat.h"
|
#include "kerndat.h"
|
||||||
#include "infect-priv.h"
|
|
||||||
#include "infect.h"
|
#include "infect.h"
|
||||||
|
#include "infect-priv.h"
|
||||||
|
|
||||||
#include "protobuf.h"
|
#include "protobuf.h"
|
||||||
#include "images/core.pb-c.h"
|
#include "images/core.pb-c.h"
|
||||||
|
@@ -81,4 +81,28 @@ extern int compel_mode_native(struct parasite_ctl *ctl);
|
|||||||
|
|
||||||
extern k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl);
|
extern k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl);
|
||||||
|
|
||||||
|
struct rt_sigframe;
|
||||||
|
|
||||||
|
struct infect_ctx {
|
||||||
|
int *p_sock;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Regs manipulation context.
|
||||||
|
*/
|
||||||
|
int (*save_regs)(void *, user_regs_struct_t *, user_fpregs_struct_t *);
|
||||||
|
int (*make_sigframe)(void *, struct rt_sigframe *, struct rt_sigframe *, k_rtsigset_t *);
|
||||||
|
void *regs_arg;
|
||||||
|
|
||||||
|
unsigned long syscall_ip; /* entry point of infection */
|
||||||
|
unsigned long flags; /* fine-tune (e.g. faults) */
|
||||||
|
|
||||||
|
void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *);
|
||||||
|
|
||||||
|
#define INFECT_NO_MEMFD 0x1 /* don't use memfd() */
|
||||||
|
#define INFECT_FAIL_CONNECT 0x2 /* make parasite connect() fail */
|
||||||
|
#define INFECT_NO_BREAKPOINTS 0x4 /* no breakpoints in pie tracking */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -27,26 +27,6 @@ struct thread_ctx {
|
|||||||
user_regs_struct_t regs;
|
user_regs_struct_t regs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct infect_ctx {
|
|
||||||
int *p_sock;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Regs manipulation context.
|
|
||||||
*/
|
|
||||||
int (*save_regs)(void *, user_regs_struct_t *, user_fpregs_struct_t *);
|
|
||||||
int (*make_sigframe)(void *, struct rt_sigframe *, struct rt_sigframe *, k_rtsigset_t *);
|
|
||||||
void *regs_arg;
|
|
||||||
|
|
||||||
unsigned long syscall_ip; /* entry point of infection */
|
|
||||||
unsigned long flags; /* fine-tune (e.g. faults) */
|
|
||||||
|
|
||||||
void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define INFECT_NO_MEMFD 0x1 /* don't use memfd() */
|
|
||||||
#define INFECT_FAIL_CONNECT 0x2 /* make parasite connect() fail */
|
|
||||||
#define INFECT_NO_BREAKPOINTS 0x4 /* no breakpoints in pie tracking */
|
|
||||||
|
|
||||||
struct parasite_ctl;
|
struct parasite_ctl;
|
||||||
|
|
||||||
extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_imgset);
|
extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_imgset);
|
||||||
|
@@ -1216,3 +1216,8 @@ k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl)
|
|||||||
{
|
{
|
||||||
return &ctl->orig.sigmask;
|
return &ctl->orig.sigmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct infect_ctx *compel_infect_ctx(struct parasite_ctl *ctl)
|
||||||
|
{
|
||||||
|
return &ctl->ictx;
|
||||||
|
}
|
||||||
|
@@ -558,6 +558,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
|
|||||||
struct vm_area_list *vma_area_list)
|
struct vm_area_list *vma_area_list)
|
||||||
{
|
{
|
||||||
struct parasite_ctl *ctl;
|
struct parasite_ctl *ctl;
|
||||||
|
struct infect_ctx *ictx;
|
||||||
unsigned long p;
|
unsigned long p;
|
||||||
|
|
||||||
BUG_ON(item->threads[0].real != pid);
|
BUG_ON(item->threads[0].real != pid);
|
||||||
@@ -572,20 +573,22 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
|
|||||||
if (!ctl)
|
if (!ctl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ctl->ictx.child_handler = sigchld_handler;
|
ictx = compel_infect_ctx(ctl);
|
||||||
ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk;
|
|
||||||
ctl->ictx.save_regs = save_task_regs;
|
ictx->child_handler = sigchld_handler;
|
||||||
ctl->ictx.make_sigframe = make_sigframe;
|
ictx->p_sock = &dmpi(item)->netns->net.seqsk;
|
||||||
ctl->ictx.regs_arg = item->core[0];
|
ictx->save_regs = save_task_regs;
|
||||||
ctl->ictx.syscall_ip = p;
|
ictx->make_sigframe = make_sigframe;
|
||||||
|
ictx->regs_arg = item->core[0];
|
||||||
|
ictx->syscall_ip = p;
|
||||||
pr_debug("Parasite syscall_ip at %#lx\n", p);
|
pr_debug("Parasite syscall_ip at %#lx\n", p);
|
||||||
|
|
||||||
if (fault_injected(FI_NO_MEMFD))
|
if (fault_injected(FI_NO_MEMFD))
|
||||||
ctl->ictx.flags |= INFECT_NO_MEMFD;
|
ictx->flags |= INFECT_NO_MEMFD;
|
||||||
if (fault_injected(FI_PARASITE_CONNECT))
|
if (fault_injected(FI_PARASITE_CONNECT))
|
||||||
ctl->ictx.flags |= INFECT_FAIL_CONNECT;
|
ictx->flags |= INFECT_FAIL_CONNECT;
|
||||||
if (fault_injected(FI_NO_BREAKPOINTS))
|
if (fault_injected(FI_NO_BREAKPOINTS))
|
||||||
ctl->ictx.flags |= INFECT_NO_BREAKPOINTS;
|
ictx->flags |= INFECT_NO_BREAKPOINTS;
|
||||||
|
|
||||||
parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
|
parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
|
||||||
parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
|
parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
|
||||||
|
Reference in New Issue
Block a user