[CRIU] [PATCH] scripts: set CRIU_IMAGE_DIR when running scripts

Tycho Andersen tycho.andersen at canonical.com
Tue Aug 12 08:14:29 PDT 2014


On Tue, Aug 12, 2014 at 10:07:08AM -0500, Tycho Andersen wrote:
> Hi Pavel,
> 
> On Tue, Aug 12, 2014 at 06:31:45PM +0400, Pavel Emelyanov wrote:
> > On 08/12/2014 06:22 PM, Tycho Andersen wrote:
> > > When doing a restore for LXC, we store some other metadata (which bridge a veth
> > > was on) in the image directory so that the restore script can correctly unlock
> > > a network device and attach it to the right interface. This patch is needed so
> > > that the script can find this metadata.
> > > 
> > > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > > ---
> > >  util.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/util.c b/util.c
> > > index a180ea5..4ff8768 100644
> > > --- a/util.c
> > > +++ b/util.c
> > > @@ -460,6 +460,7 @@ int run_scripts(char *action)
> > >  {
> > >  	struct script *script;
> > >  	int ret = 0;
> > > +	char image_dir[PATH_MAX];
> > 
> > Odd enough, but we have a magic constant PSFDS that says "how much 
> > would the path to /proc/self/fd/%d occupy on the stack" :)
> > 
> > >  
> > >  	pr_debug("Running %s scripts\n", action);
> > >  
> > > @@ -468,6 +469,12 @@ int run_scripts(char *action)
> > >  		return -1;
> > >  	}
> > >  
> > > +	sprintf(image_dir, "/proc/%ld/fd/%d", (long) getpid(), get_service_fd(IMG_FD_OFF));
> > 
> > Maybe /proc/self/fd/%d would be nicer? This would allow using the
> > PSFDS above :)
> 
> I this, but it seems that the fds are declared O_CLOEXEC or something?

Urgh, I *tried* this :)

> It doesn't look like open_image_dir does that, though, so I'm not sure
> what is going on. They weren't available in the script, in any case.

Tycho


More information about the CRIU mailing list