scripts: Add ACT_POST_SIGRETURN stage

Submitted by Cyrill Gorcunov on Jan. 9, 2017, 2:44 p.m.

Details

Message ID 1483973097-29763-1-git-send-email-gorcunov@virtuozzo.com
State Superseded
Series "scripts: Add ACT_POST_SIGRETURN stage"
Headers show

Commit Message

Cyrill Gorcunov Jan. 9, 2017, 2:44 p.m.
The "post-sigreturn" action is when all tasks are restored
but not yet restarted sitting in frozen/seized state, right
after final rt-sigreturn call passed.

In vz7 this step is needed to tune up beancounters/cgroups
params from the script, in vanilla criu it useful as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/action-scripts.c         | 1 +
 criu/cr-restore.c             | 4 ++++
 criu/include/action-scripts.h | 1 +
 3 files changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index 6a47d5e..d13de23 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -26,6 +26,7 @@  static const char *action_names[ACT_MAX] = {
 	[ ACT_POST_SETUP_NS ]	= "post-setup-namespaces",
 	[ ACT_POST_RESUME ]	= "post-resume",
 	[ ACT_POST_NET_LOCK ]	= "post-network-lock",
+	[ ACT_POST_SIGRETURN ]	= "post-sigreturn",
 };
 
 struct script {
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index d003f12..da6ed31 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1852,6 +1852,10 @@  static int restore_root_task(struct pstree_item *init)
 	if (ret == 0)
 		finalize_restore();
 
+	ret = run_scripts(ACT_POST_SIGRETURN);
+	if (ret)
+		pr_err("Post-sigreturn script ret code %d\n", ret);
+
 	if (restore_freezer_state())
 		pr_err("Unable to restore freezer state\n");
 
diff --git a/criu/include/action-scripts.h b/criu/include/action-scripts.h
index e49f57c..631350d 100644
--- a/criu/include/action-scripts.h
+++ b/criu/include/action-scripts.h
@@ -12,6 +12,7 @@  enum script_actions {
 	ACT_POST_SETUP_NS,
 	ACT_POST_RESUME,
 	ACT_POST_NET_LOCK,
+	ACT_POST_SIGRETURN,
 
 	ACT_MAX
 };

Comments

Pavel Emelianov Jan. 10, 2017, 12:51 p.m.
On 01/09/2017 05:44 PM, Cyrill Gorcunov wrote:
> The "post-sigreturn" action is when all tasks are restored
> but not yet restarted sitting in frozen/seized state, right
> after final rt-sigreturn call passed.
> 
> In vz7 this step is needed to tune up beancounters/cgroups
> params from the script, in vanilla criu it useful as well.

We have POST_RESTORE hook. If it happens too early (why?) let's
move it into proper place?

> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> ---
>  criu/action-scripts.c         | 1 +
>  criu/cr-restore.c             | 4 ++++
>  criu/include/action-scripts.h | 1 +
>  3 files changed, 6 insertions(+)
> 
> diff --git a/criu/action-scripts.c b/criu/action-scripts.c
> index 6a47d5e..d13de23 100644
> --- a/criu/action-scripts.c
> +++ b/criu/action-scripts.c
> @@ -26,6 +26,7 @@ static const char *action_names[ACT_MAX] = {
>  	[ ACT_POST_SETUP_NS ]	= "post-setup-namespaces",
>  	[ ACT_POST_RESUME ]	= "post-resume",
>  	[ ACT_POST_NET_LOCK ]	= "post-network-lock",
> +	[ ACT_POST_SIGRETURN ]	= "post-sigreturn",
>  };
>  
>  struct script {
> diff --git a/criu/cr-restore.c b/criu/cr-restore.c
> index d003f12..da6ed31 100644
> --- a/criu/cr-restore.c
> +++ b/criu/cr-restore.c
> @@ -1852,6 +1852,10 @@ static int restore_root_task(struct pstree_item *init)
>  	if (ret == 0)
>  		finalize_restore();
>  
> +	ret = run_scripts(ACT_POST_SIGRETURN);
> +	if (ret)
> +		pr_err("Post-sigreturn script ret code %d\n", ret);
> +
>  	if (restore_freezer_state())
>  		pr_err("Unable to restore freezer state\n");
>  
> diff --git a/criu/include/action-scripts.h b/criu/include/action-scripts.h
> index e49f57c..631350d 100644
> --- a/criu/include/action-scripts.h
> +++ b/criu/include/action-scripts.h
> @@ -12,6 +12,7 @@ enum script_actions {
>  	ACT_POST_SETUP_NS,
>  	ACT_POST_RESUME,
>  	ACT_POST_NET_LOCK,
> +	ACT_POST_SIGRETURN,
>  
>  	ACT_MAX
>  };
>
Andrey Vagin Jan. 11, 2017, 12:28 a.m.
On Tue, Jan 10, 2017 at 03:51:10PM +0300, Pavel Emelyanov wrote:
> On 01/09/2017 05:44 PM, Cyrill Gorcunov wrote:
> > The "post-sigreturn" action is when all tasks are restored
> > but not yet restarted sitting in frozen/seized state, right
> > after final rt-sigreturn call passed.
> > 
> > In vz7 this step is needed to tune up beancounters/cgroups
> > params from the script, in vanilla criu it useful as well.
> 
> We have POST_RESTORE hook. If it happens too early (why?) let's
> move it into proper place?

POST_RESTORE is a place where we can kill restored processes and
resume processes on the source siede. I don't think that we can move it
to somewhere.
> 
> > Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> > ---
> >  criu/action-scripts.c         | 1 +
> >  criu/cr-restore.c             | 4 ++++
> >  criu/include/action-scripts.h | 1 +
> >  3 files changed, 6 insertions(+)
> > 
> > diff --git a/criu/action-scripts.c b/criu/action-scripts.c
> > index 6a47d5e..d13de23 100644
> > --- a/criu/action-scripts.c
> > +++ b/criu/action-scripts.c
> > @@ -26,6 +26,7 @@ static const char *action_names[ACT_MAX] = {
> >  	[ ACT_POST_SETUP_NS ]	= "post-setup-namespaces",
> >  	[ ACT_POST_RESUME ]	= "post-resume",
> >  	[ ACT_POST_NET_LOCK ]	= "post-network-lock",
> > +	[ ACT_POST_SIGRETURN ]	= "post-sigreturn",
> >  };
> >  
> >  struct script {
> > diff --git a/criu/cr-restore.c b/criu/cr-restore.c
> > index d003f12..da6ed31 100644
> > --- a/criu/cr-restore.c
> > +++ b/criu/cr-restore.c
> > @@ -1852,6 +1852,10 @@ static int restore_root_task(struct pstree_item *init)
> >  	if (ret == 0)
> >  		finalize_restore();
> >  
> > +	ret = run_scripts(ACT_POST_SIGRETURN);
> > +	if (ret)
> > +		pr_err("Post-sigreturn script ret code %d\n", ret);
> > +
> >  	if (restore_freezer_state())
> >  		pr_err("Unable to restore freezer state\n");
> >  
> > diff --git a/criu/include/action-scripts.h b/criu/include/action-scripts.h
> > index e49f57c..631350d 100644
> > --- a/criu/include/action-scripts.h
> > +++ b/criu/include/action-scripts.h
> > @@ -12,6 +12,7 @@ enum script_actions {
> >  	ACT_POST_SETUP_NS,
> >  	ACT_POST_RESUME,
> >  	ACT_POST_NET_LOCK,
> > +	ACT_POST_SIGRETURN,
> >  
> >  	ACT_MAX
> >  };
> > 
>