[CRIU] [PATCH 2/6] lib: Add support for setting new namespace flags via libcriu

Tycho Andersen tycho.andersen at canonical.com
Mon Aug 4 06:15:53 PDT 2014


Hi Pavel,

On Mon, Aug 04, 2014 at 01:56:16PM +0400, Pavel Emelyanov wrote:
> On 07/29/2014 09:06 PM, Tycho Andersen wrote:
> 
> Actually, right now --namespaces option is obsoleted. We used to have one
> before we had /proc/pid/ns/* files being links with IDs exported into the
> userspace. Right now criu can get the per-process nsmask on dump out of
> /proc and get one on restore out of the images.
> 
> Do you need the --namespaces mask for something special?

I don't know, http://www.criu.org/LXC says pass -n, so that is what I
was doing :). Is there a better way to do this?

Tycho

> Thanks,
> Pavel
> 
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  cr-service.c       | 3 +++
> >  lib/criu.c         | 6 ++++++
> >  lib/criu.h         | 2 ++
> >  protobuf/rpc.proto | 1 +
> >  4 files changed, 12 insertions(+)
> > 
> > diff --git a/cr-service.c b/cr-service.c
> > index 11e9778..2041ed8 100644
> > --- a/cr-service.c
> > +++ b/cr-service.c
> > @@ -266,6 +266,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
> >  	if (req->has_force_irmap)
> >  		opts.force_irmap = req->force_irmap;
> >  
> > +	if (req->has_ns_flags)
> > +		opts.rst_namespaces_flags = req->ns_flags;
> > +
> >  	if (req->n_exec_cmd > 0) {
> >  		opts.exec_cmd = xmalloc((req->n_exec_cmd + 1) * sizeof(char *));
> >  		memcpy(opts.exec_cmd, req->exec_cmd, req->n_exec_cmd * sizeof(char *));
> > diff --git a/lib/criu.c b/lib/criu.c
> > index 9d84c83..dbf35cd 100644
> > --- a/lib/criu.c
> > +++ b/lib/criu.c
> > @@ -163,6 +163,12 @@ void criu_set_cpu_cap(unsigned int cap)
> >  	opts->cpu_cap		= cap;
> >  }
> >  
> > +void criu_set_ns_flags(uint32_t flags)
> > +{
> > +	opts->has_ns_flags	= true;
> > +	opts->ns_flags		= flags;
> > +}
> > +
> >  int criu_set_exec_cmd(int argc, char *argv[])
> >  {
> >  	int i;
> > diff --git a/lib/criu.h b/lib/criu.h
> > index 5ab09c3..593aae3 100644
> > --- a/lib/criu.h
> > +++ b/lib/criu.h
> > @@ -20,6 +20,7 @@
> >  #define __CRIU_LIB_H__
> >  
> >  #include <stdbool.h>
> > +#include <inttypes.h>
> >  
> >  void criu_set_service_address(char *path);
> >  
> > @@ -47,6 +48,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);
> > +void criu_set_ns_flags(uint32_t flags);
> >  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);
> > diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
> > index 1604f37..410b159 100644
> > --- a/protobuf/rpc.proto
> > +++ b/protobuf/rpc.proto
> > @@ -47,6 +47,7 @@ message criu_opts {
> >  	repeated ext_mount_map		ext_mnt		= 23;
> >  
> >  	repeated string			action_scripts	= 24;
> > +	optional uint32			ns_flags	= 25;
> >  }
> >  
> >  message criu_dump_resp {
> > 
> 


More information about the CRIU mailing list