[Devel] [PATCH 2/2] cpt: restore veth devices with correct names (v4)

Kir Kolyshkin kir at parallels.com
Fri May 31 11:22:05 PDT 2013


The whole series applied, thanks!

http://git.openvz.org/?p=vzctl;a=commitdiff;h=20bd87251
http://git.openvz.org/?p=vzctl;a=commitdiff;h=4fdbcb51f5
http://git.openvz.org/?p=vzctl;a=commitdiff;h=557abfef46


On 05/30/2013 03:07 AM, Andrey Vagin wrote:
> transmit pair of veth names to criu via the option --veth-pair
>
> v2: unset IFS and delete eval from vps-rst
> v3: fix comments from Kir
> v4: vzcheckvar VE_VETH_DEVS
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>   scripts/vps-rst.in | 11 ++++++++++-
>   src/lib/hooks_ct.c | 16 +++++++++++++---
>   2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/vps-rst.in b/scripts/vps-rst.in
> index b6c2f84..91080b3 100755
> --- a/scripts/vps-rst.in
> +++ b/scripts/vps-rst.in
> @@ -25,6 +25,7 @@
>   #   VE_ROOT       - container root directory
>   #   VE_DUMP_DIR   - directory for saving dump files
>   #   VE_STATE_FILE - file to write CT init PID to
> +#   VE_VETH_DEVS  - pair of veth names (CT=HW\n)
>   
>   exec 1>&2
>   . @SCRIPTDIR@/vps-functions
> @@ -32,6 +33,12 @@ exec 1>&2
>   vzcheckvar VE_ROOT
>   vzcheckvar VE_STATE_FILE
>   vzcheckvar VE_DUMP_DIR
> +vzcheckvar VE_VETH_DEVS
> +
> +veth_args=""
> +for dev in $VE_VETH_DEVS; do
> +	veth_args="$veth_args --veth-pair $dev"
> +done
>   
>   criu restore	--file-locks		\
>   		--tcp-established	\
> @@ -42,7 +49,9 @@ criu restore	--file-locks		\
>   		-D $VE_DUMP_DIR		\
>   		-o restore.log		\
>   		-vvvv			\
> -		--pidfile $VE_STATE_FILE
> +		--pidfile $VE_STATE_FILE \
> +		$veth_args
> +
>   if [ $? -eq 0 ]; then
>   	rm -rf $VE_DUMP_DIR
>   else
> diff --git a/src/lib/hooks_ct.c b/src/lib/hooks_ct.c
> index 4011142..18650e0 100644
> --- a/src/lib/hooks_ct.c
> +++ b/src/lib/hooks_ct.c
> @@ -924,11 +924,12 @@ static int ct_chkpnt(vps_handler *h, envid_t veid,
>   static int ct_restore_fn(vps_handler *h, envid_t veid, const vps_res *res,
>   			  int wait_p, int old_wait_p, int err_p, void *data)
>   {
> -	char *argv[2], *env[4];
> +	char *argv[2], *env[5];
>   	const char *dumpfile = NULL;
>   	const char *statefile = NULL;
>   	cpt_param *param = data;
> -	char buf[STR_SIZE];
> +	veth_dev *veth;
> +	char buf[STR_SIZE], *pbuf;
>   	pid_t pid = -1;
>   	int ret;
>   	FILE *sfile;
> @@ -948,7 +949,16 @@ static int ct_restore_fn(vps_handler *h, envid_t veid, const vps_res *res,
>   	env[1] = strdup(buf);
>   	snprintf(buf, sizeof(buf), "VE_STATE_FILE=%s", statefile);
>   	env[2] = strdup(buf);
> -	env[3] = NULL;
> +
> +	pbuf = buf;
> +	pbuf += snprintf(buf, sizeof(buf), "VE_VETH_DEVS=");
> +	list_for_each(veth, &res->veth.dev, list) {
> +		pbuf += snprintf(pbuf, sizeof(buf) - (pbuf - buf),
> +				"%s=%s\n", veth->dev_name_ve, veth->dev_name);
> +	}
> +	env[3] = strdup(buf);
> +
> +	env[4] = NULL;
>   
>   	ret = run_script(argv[0], argv, env, 0);
>   	free_arg(env);




More information about the Devel mailing list