2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

21 Commits

Author SHA1 Message Date
Kir Kolyshkin
0194ed392f Fix some codespell warnings
Brought to you by

	codespell -w

(using codespell v2.1.0).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-28 17:53:52 -07:00
Kir Kolyshkin
2166d47482 scripts: fix shellcheck warnings
On my system (shellcheck v0.7.1) make lint shows a few warnings about
needing to quote variables.

Fix those.

PS I am not sure why those are not shown by GHA CI, I assume there is
different shellcheck version used. Add shellcheck -- version to the
appropriate Makefile target to avoid confusion.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
84215e0355 scripts: run shellcheck on the scripts folder
Shellcheck (https://github.com/koalaman/shellcheck) can identify common
errors in shell scripts. This initial integration of shellcheck only
checks the scripts in the 'scripts/' folder. This commit fixes (or
disables) all reports of shellcheck to ensure this part starts error
free. I am not convinced this is really necessary as most changes do not
seem to be necessary for their circumstances. On the other hand it
probably does not hurt to use a checker to avoid unnecessary errors.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
55d0f98fc9 scripts/systemd-autofs-restart.sh: fix variable name
The script checks if $NSENTER is executable and sets $NS_ENTER if not.
This seems to be a typo (once with '_' and once without).

Untested and not reproducible. It just looks wrong.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-07-09 18:26:50 +03:00
Stanislav Kinsburskiy
56662c4ab2 systemd-autofs-restart.sh: fix issue with removed check_fs_type reference
"Check_fs_type" helper was repalce by "get_fs_type".
This reference is a silly mistake.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-06 11:44:05 +03:00
Stanislav Kinsburskiy
dd3a901210 systemd-autofs-restart.sh: explicitly return result from get_fs_type
This helper uses other binaries (like awk), which can fail or be killed.
It this case might be, that no mountpoint is found.
Or, on other hand, the whole mount point path is wrong, and is absend in
mountinfo.
Return explicit error in this case.
Without this patch, script will proceed further, and, since returned value is
empty, it doesn't equal to "autofs", so script will try to bind-mount autofs
mount, resulting in hung.

 travis-ci: success for systemd-autofs-restart.sh: explicitly return result from get_fs_type
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-10 12:48:20 +03:00
Stanislav Kinsburskiy
333373110c systemd-autofs-restart.sh: fix error handling in case of system limitation
Without this patch any error in check_fs_type function is considered as a
grant to process to bind-mount.
This patch splits mount point fs type discovering and comparison to autofs
type, thus allowing to check for discovery errors.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-09-06 19:31:21 +03:00
Stanislav Kinsburskiy
6e89dbbfcc systemd-autofs-restart.sh: do not treat absence on bindmount as error
There can be autofs direct mount point without target mount on top.
In this case there won't be any bindmount and nothing to restore on top of the
autofs mount point.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-08-11 16:18:43 +03:00
Stanislav Kinsburskiy
a71b27ea79 scripts: fix typo in binary path in systemd-autofs-restart.sh
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:27:02 +03:00
Eugene Kolomeetz
df5f0262ca scripts: terminate systemd-autofs-restart.sh if saved mountpoint is missing
restore_mountpoint() should never be called without saved mountpoint.
If this happens, this is bug in script logic, which needs fixing.
https://jira.sw.ru/browse/PSBM-44207

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:19:06 +03:00
Eugene Kolomeetz
73a24127e3 scripts: return non zero if save_mountpoint() fails
In such case, we must not proceed: without saved mountpoint, we risk
losing data when restarting automount service (think about tmpfs).
Currently, zero will be returned as exit status of preceeding echo.
https://jira.sw.ru/browse/PSBM-44207

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:19:06 +03:00
Eugene Kolomeetz
00f8b63b22 scripts: remove bogus command substitution in systemd-autofs-restart.sh
When we want to just execute command (without capturing output), we must
not do it via $(cmd). With such form, shell first gets output of 'cmd',
and then evaluates it. If this is empty string, it is successfully
executed. If not empty, all breaks down.
https://jira.sw.ru/browse/PSBM-44207

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:19:06 +03:00
Eugene Kolomeetz
e928321399 scripts: detect EOF on read in a usual way in systemd-autofs-restart.sh
When read bultin detects EOF, it sets empty string as value of specified
variable, and returns non-zero exit code. So we can rely just on exit
code, and not check variable value. This is standard approach.
https://jira.sw.ru/browse/PSBM-44207

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:19:06 +03:00
Eugene Kolomeetz
76a6b0c4bf scripts: call readlink in CT context in systemd-autofs-restart.sh
Now readlink is called in host context, this is obviously wrong.

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:16 +03:00
Eugene Kolomeetz
1525aee1e4 scripts: single style for command substitution in systemd-autofs-restart.sh
Let's use $(...) form, it is more readable, and used in other places.

Signed-off-by: Eugene Kolomeetz <klm@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:16 +03:00
Stanislav Kinsburskiy
92d8c31750 scripts: fix strings comparison in systemd-autofs-restart.sh
Otherwise the following errors can be triggered:

/usr/libexec/criu/scripts/systemd-autofs-restart.sh: line 64: [: =: unary
operator expected
/usr/libexec/criu/scripts/systemd-autofs-restart.sh: line 77: [: =: unary
operator expected

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:16 +03:00
Stanislav Kinsburskiy
49bfd9540d scripts: fix mountinfo parsing in systemd-autofs-restart.sh
Fily system type is not necessarily located in the column number 9.
But look like we can rely on " - " pattern: it's always located immediately
after dash.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:15 +03:00
Stanislav Kinsburskiy
9f89937468 scripts: do not use stat to discover fs type in systemd-autofs-restart.sh
Unfortunatelly, autofs doesn't allow to discover it's type. At least without
accessing master process. That means, that stat can be used to determine
whether some other file system is mounted on top of autofs (which we need to
take a decision whether to move restore fs aside or not), because it simply
stuck.
This patch does fs type discovering by parsing CTs mountinfo.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:15 +03:00
Stanislav Kinsburskiy
40682f1561 scripts: save and restore target mount for autofs service
This patch slightly changes the logic on systemd autofs service restart script:

1) It tries to bind-mount the mountpoint on top of autofs (if any) somewhere
before service restart, and replace new mount point on top of autofs (if any)
by the saved one after.

2) It doesn't exit in case of error, trying to recover as much as
possible in case of failure instead and then continue services restarting.

The reason for introducing new logic is that there can be some other,
stateful, file system on top of autofs (say, tmpfs), which state was restore
during migration.
With current script this state will be lost, while this patch allows to
preserve restored mount point after service restart.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:15 +03:00
Stanislav Kinsburskiy
63d61425b7 scripts: join pid namespace in systemd-autofs-restart.sh
Without correct pid namespace systemctl is not able to determine whether
autofs is active or not.
The reason is unaccessible proc due to mount namespace change without pid
namespace change.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:15 +03:00
Stanislav Kinsburskiy
10ffc78dfb scripts: systemd-autofs-restart.sh added
This script restarts systemd autofs services to workaround a problem, when
systemd doesn't consider autofs mount as own after restore (alien device ID
problem)

v4:
Environment variable NS_PID was renamed to CRTOOLS_INIT_PID

v2:
1) Added different checks: for process with pid, active service, systemd based
container.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-05 23:18:15 +03:00