[Devel] [PATCH 3/3] cpt: restore veth devices with correct names
Kir Kolyshkin
kir at openvz.org
Wed May 29 16:55:58 PDT 2013
On 05/27/2013 02:12 PM, Andrey Vagin wrote:
> transmit pair of veth names to criu via the option --veth-pair
>
> v2: unset IFS and delete eval from vps-rst
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> scripts/vps-rst.in | 15 +++++++++++++--
> src/lib/hooks_ct.c | 18 ++++++++++++++----
> 2 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/vps-rst.in b/scripts/vps-rst.in
> index b6c2f84..629b1b3 100755
> --- a/scripts/vps-rst.in
> +++ b/scripts/vps-rst.in
> @@ -25,15 +25,24 @@
> # 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
>
> +veth_args=
> +IFS="
> +"
Why do you need to set IFS at all? Default IFS is space, tab and newline.
Are you implying that device names can contain spaces or tabs? I haven't
see any.
> +for dev in $VE_VETH_DEVS; do
> + veth_args="$veth_args --veth-pair $dev"
> +done
> +unset IFS
> +
> vzcheckvar VE_ROOT
> vzcheckvar VE_STATE_FILE
> vzcheckvar VE_DUMP_DIR
>
> -criu restore --file-locks \
> +criu restore --file-locks \
> --tcp-established \
> --evasive-devices \
> --link-remap \
> @@ -42,7 +51,9 @@ criu restore --file-locks \
> -D $VE_DUMP_DIR \
> -o restore.log \
> -vvvv \
> - --pidfile $VE_STATE_FILE
> + --pidfile $VE_STATE_FILE\
a whitespace before \ would be nice
> + $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 21e6823..1580b8e 100644
> --- a/src/lib/hooks_ct.c
> +++ b/src/lib/hooks_ct.c
> @@ -921,14 +921,15 @@ static int ct_chkpnt(vps_handler *h, envid_t veid,
> return ret;
> }
>
> -static int ct_restore_fn(vps_handler *h, envid_t veid, const fs_param *fs,
> +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)
This belongs to the patch #1, right?
> {
> - 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 fs_param *fs,
> 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=");;
double ;; detected
> + 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