All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
To: Sukadev Bhattiprolu <sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH 5/5][lxc] Hook up lxc_checkpoint() with app_checkpoint()
Date: Wed, 24 Mar 2010 21:51:48 +0100	[thread overview]
Message-ID: <4BAA7B64.9080004@fr.ibm.com> (raw)
In-Reply-To: <20100324193537.GB20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

Sukadev Bhattiprolu wrote:
> Daniel Lezcano [dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org] wrote:
>>> +find_cinit_pid(const char *name)
>>>  {
>>> +	struct lxc_command command = {
>>> +		.request = { .type = LXC_COMMAND_CINIT_PID },
>>> +	};
>>> +
>>> +	int ret, stopped;
>>> +
>>> +	ret = lxc_command(name, &command, &stopped);
>>> +	if (ret < 0) {
>>> +		ERROR("failed to send command");
>>> +		return -1;
>>> +	}
>>> +
>>> +	ERROR("find_cinit_pid %d\n", command.answer.ret);
>>> +
>>> +	return command.answer.ret;
>>> +}
>> I just committed the same function for the lxc_attach command. I think  
>> you can reuse it.
> 
> Ok, will try to reuse it.
> 
>>> +int lxc_checkpoint(const char *name, const char *statefile, int lxc_flags)
>>> +{
>>> +	int ret;
>>> +	int pid;
>>> +	int flags;
>>> +	struct stat statbuf;
>>> +	struct app_checkpoint_args crargs;
>>> +
>>> +	if (access(statefile, F_OK) == 0) {
>>> +		ret = stat(statefile, &statbuf);
>>> +		if (ret < 0) {
>>> +			ERROR("stat(%s): %s\n", statefile, strerror(errno));
>>> +			return -1;
>>> +		}
>>> +
>>> +		if (S_ISDIR(statbuf.st_mode)) {
>>> +			ERROR("--directory option not implemented");
>>> +			return -1;
>>> +		} else {
>>> +			ERROR("Checkpoint image file %s exists\n", statefile);
>>> +			return -1;
>>> +		}
>>> +	}
>> For the checkpoint, you don't need to check if it's a directory or a  
>> file (but it should be done at restart time).
> 
> I need to open() the statefile and pass its fd to app_checkpoint().
> If I don't check for directory, the open() below would fail, only
> because of the O_RDWR flag. By checking, we could give a more useful
> error message ?

What I meant is the directory shall not exists when checkpointing, if 
the directory or the file exists, the checkpoint should fail.

>> I am not sure 'access' is  
>> really necessary because the O_EXCL is set in the open below.
> 
> Agree. How about just the stat() and the error message ?

IMO, just fail when trying to open the file, the O_EXCL flag will do the 
job for us.

> Maybe later we could bury this code under say #ifdef USERCR so
> if LXC is configured without USERCR, the current behavior is preserved ?

Right, it's an aspect we have to address. But we can do that later, IMHO 
the main objective would be to correctly integrate lxc and the CR with 
the 'configure' script. eg configure --with-linux=<path> .... and the 
makefiles.

  parent reply	other threads:[~2010-03-24 20:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19  6:39 [RFC][PATCH 0/5][lxc]: Link with USERCR Sukadev Bhattiprolu
     [not found] ` <20100319063912.GA25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-19  6:40   ` [PATCH 1/5][lxc] Enable static linking of some lxc binaries Sukadev Bhattiprolu
     [not found]     ` <20100319064024.GB25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:44       ` Daniel Lezcano
2010-03-19  6:40   ` [PATCH 2/5][lxc] lxc_restart: Add --image option Sukadev Bhattiprolu
     [not found]     ` <20100319064046.GC25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:45       ` Daniel Lezcano
     [not found]         ` <4BA78276.2040308-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:48           ` Sukadev Bhattiprolu
     [not found]             ` <20100324194851.GD20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:53               ` Daniel Lezcano
2010-03-19  6:41   ` [PATCH 3/5][lxc] lxc_checkpoint: " Sukadev Bhattiprolu
2010-03-19  6:41   ` [PATCH 4/5][lxc] Hook up lxc_restart() with app_restart() Sukadev Bhattiprolu
     [not found]     ` <20100319064121.GE25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:48       ` Daniel Lezcano
2010-03-19  6:41   ` [PATCH 5/5][lxc] Hook up lxc_checkpoint() with app_checkpoint() Sukadev Bhattiprolu
     [not found]     ` <20100319064141.GF25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:44       ` Daniel Lezcano
     [not found]         ` <4BA78262.6050109-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:35           ` Sukadev Bhattiprolu
     [not found]             ` <20100324193537.GB20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:51               ` Daniel Lezcano [this message]
2010-03-19 10:44   ` [RFC][PATCH 0/5][lxc]: Link with USERCR Michel Normand
2010-03-24 19:22     ` Sukadev Bhattiprolu
2010-03-22 14:45   ` Daniel Lezcano
     [not found]     ` <4BA7826D.10706-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:27       ` Oren Laadan
2010-03-24 19:47       ` Sukadev Bhattiprolu
     [not found]         ` <20100324194744.GC20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:52           ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BAA7B64.9080004@fr.ibm.com \
    --to=dlezcano-nmtc/0zbporqt0dzr+alfa@public.gmane.org \
    --cc=clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.