mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
zdtm/lib: add "bind" desc option
Add {'bind': 'path/to/bindmount'} zdtm descriptor option, so that in
test mount namespace a directory bindmount can be created before running
the test.
This is useful to leave test directory writable (e.g. for logs) while
the test makes root mount readonly. note: We create this bindmount early
so that all test files are opened on it initially and not on the below
mount. Will be used in mnt_ro_root test.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
88cb552f69
commit
6b3826a6fb
2 changed files with 17 additions and 1 deletions
|
|
@ -443,6 +443,7 @@ class zdtm_test:
|
|||
self._bins = [name]
|
||||
self._env = {'TMPDIR': os.environ.get('TMPDIR', '/tmp')}
|
||||
self._deps = desc.get('deps', [])
|
||||
self._bind = desc.get('bind')
|
||||
self.auto_reap = True
|
||||
|
||||
def __make_action(self, act, env=None, root=None):
|
||||
|
|
@ -513,6 +514,8 @@ class zdtm_test:
|
|||
if self.__flavor.ns:
|
||||
env['ZDTM_NEWNS'] = "1"
|
||||
env['ZDTM_ROOT'] = self.__flavor.root
|
||||
if self._bind:
|
||||
env['ZDTM_BIND'] = self._bind
|
||||
env['ZDTM_DEV'] = self.__flavor.devpath
|
||||
env['PATH'] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
|||
static int prepare_mntns(void)
|
||||
{
|
||||
int dfd, ret;
|
||||
char *root, *criu_path, *dev_path;
|
||||
char *root, *criu_path, *dev_path, *zdtm_bind;
|
||||
char path[PATH_MAX];
|
||||
char bind_path[PATH_MAX];
|
||||
|
||||
root = getenv("ZDTM_ROOT");
|
||||
if (!root) {
|
||||
|
|
@ -52,6 +53,18 @@ static int prepare_mntns(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
zdtm_bind = getenv("ZDTM_BIND");
|
||||
if (zdtm_bind) {
|
||||
/*
|
||||
* Bindmount the directory to itself.
|
||||
*/
|
||||
snprintf(bind_path, sizeof(bind_path), "%s/%s", root, zdtm_bind);
|
||||
if (mount(bind_path, bind_path, NULL, MS_BIND, NULL)) {
|
||||
fprintf(stderr, "Can't bind-mount ZDTM_BIND: %m\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dev_path = getenv("ZDTM_DEV");
|
||||
if (dev_path) {
|
||||
snprintf(path, sizeof(path), "%s/dev", root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue