[CRIU] Re: [PATCH cr 1/2] parasite: add a function to execute a
parasite code in threads
Cyrill Gorcunov
gorcunov at openvz.org
Tue Feb 21 02:00:48 EST 2012
On Tue, Feb 21, 2012 at 09:25:16AM +0300, Andrey Vagin wrote:
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> parasite-syscall.c | 37 +++++++++++++++++++++++++++++--------
> 1 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index 02a50fa..0a27b18 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -77,9 +77,8 @@ static void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs)
> }
>
> /* we run at @regs->ip */
> -static int __parasite_execute(struct parasite_ctl *ctl, user_regs_struct_t *regs)
> +static int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs)
> {
> - pid_t pid = ctl->pid;
> siginfo_t siginfo;
> int status;
> int ret = -1;
> @@ -226,19 +225,29 @@ err:
> return ret;
> }
>
> -static int parasite_execute(unsigned long cmd, struct parasite_ctl *ctl,
> +static int parasite_execute_by_pid(unsigned long cmd, struct parasite_ctl *ctl,
> + pid_t pid,
> parasite_status_t *args, int args_size)
> {
> int ret;
> -
> - user_regs_struct_t regs = ctl->regs_orig;
> + user_regs_struct_t regs_orig, regs;
> +
> + if (ctl->pid == pid)
> + regs = ctl->regs_orig;
> + else {
> + if (ptrace(PTRACE_GETREGS, pid, NULL, ®s_orig)) {
> + pr_err("Can't obtain registers (pid: %d)\n", pid);
> + return -1;
> + }
> + regs = regs_orig;
> + }
>
This won't work well. __parasite_execute *updates* current registers
frame so you rather have to update __parasite_execute as well and
add regs as an argument. Then, in case of signal deliery, you're
to update these regs and return them to a caller with already
modifed contents.
Cyrill
More information about the CRIU
mailing list