[CRIU] [PATCH 1/6] lib: add support for --action-script in libcriu

Tycho Andersen tycho.andersen at canonical.com
Wed Jul 30 05:25:01 PDT 2014


Hi Andrew,

On Wed, Jul 30, 2014 at 12:19:58PM +0400, Andrew Vagin wrote:
> Do you look at send_criu_rpc_script()? We use it in p.haul:
> https://github.com/xemul/p.haul/blob/master/p_haul_iters.py
> 
> Why do you decide to not use this?

Actually I didn't notice this, so that's why :). I think we can drop
this patch then if that is a better way of doing the same thing.

Tycho

> On Tue, Jul 29, 2014 at 12:06:42PM -0500, Tycho Andersen wrote:
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  cr-service.c       | 15 +++++++++++++++
> >  lib/criu.c         | 19 +++++++++++++++++++
> >  lib/criu.h         |  1 +
> >  protobuf/rpc.proto |  2 ++
> >  4 files changed, 37 insertions(+)
> > 
> > diff --git a/cr-service.c b/cr-service.c
> > index 64ce751..11e9778 100644
> > --- a/cr-service.c
> > +++ b/cr-service.c
> > @@ -300,6 +300,21 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
> >  			return -1;
> >  	}
> >  
> > +	for (i = 0; i < req->n_action_scripts; i++) {
> > +		struct script *script;
> > +
> > +		script = xmalloc(sizeof(*script));
> > +		if(!script)
> > +			return -1;
> > +
> > +		script->path = xstrdup(req->action_scripts[i]);
> > +		if (!script->path) {
> > +			free(script);
> > +			return -1;
> > +		}
> > +		list_add(&script->node, &opts.scripts);
> > +	}
> > +
> >  	if (req->has_cpu_cap)
> >  		opts.cpu_cap = req->cpu_cap;
> >  
> > diff --git a/lib/criu.c b/lib/criu.c
> > index 7c1ac07..9d84c83 100644
> > --- a/lib/criu.c
> > +++ b/lib/criu.c
> > @@ -259,6 +259,25 @@ er:
> >  	return -ENOMEM;
> >  }
> >  
> > +int criu_add_action_script(char *script)
> > +{
> > +	void *m;
> > +	opts->n_action_scripts++;
> > +	m = realloc(opts->action_scripts, sizeof(char*) * opts->n_action_scripts);
> > +	if (!m)
> > +		return -1;
> > +	opts->action_scripts = m;
> > +
> > +	m = strdup(script);
> > +	opts->action_scripts[opts->n_action_scripts - 1] = m;
> > +	if (!m) {
> > +		opts->n_action_scripts--;
> > +		return -1;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static CriuResp *recv_resp(int socket_fd)
> >  {
> >  	unsigned char buf[CR_MAX_MSG_SIZE];
> > diff --git a/lib/criu.h b/lib/criu.h
> > index 18faaef..5ab09c3 100644
> > --- a/lib/criu.h
> > +++ b/lib/criu.h
> > @@ -47,6 +47,7 @@ void criu_set_log_level(int log_level);
> >  void criu_set_log_file(char *log_file);
> >  void criu_set_cpu_cap(unsigned int cap);
> >  void criu_set_root(char *root);
> > +int criu_add_action_script(char *script);
> >  int criu_set_exec_cmd(int argc, char *argv[]);
> >  int criu_add_ext_mount(char *key, char *val);
> >  int criu_add_veth_pair(char *in, char *out);
> > diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
> > index e50d97c..1604f37 100644
> > --- a/protobuf/rpc.proto
> > +++ b/protobuf/rpc.proto
> > @@ -45,6 +45,8 @@ message criu_opts {
> >  	repeated string			exec_cmd	= 22;
> >  
> >  	repeated ext_mount_map		ext_mnt		= 23;
> > +
> > +	repeated string			action_scripts	= 24;
> >  }
> >  
> >  message criu_dump_resp {
> > -- 
> > 1.9.1
> > 
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list