diff options
author | Ezequiel Garcia <ezequiel@collabora.com> | 2018-09-12 16:01:24 -0300 |
---|---|---|
committer | Marcos Paulo de Souza <marcos.souza.org@gmail.com> | 2019-10-09 23:30:03 -0300 |
commit | 4c038ed54883f116e599617e6091e6173bf1b6b0 (patch) | |
tree | 82c15de0d755cee9c4d3684725cced02b441cbe9 | |
parent | 9a0ed9f43dbb2a510c802d8afe92f39f66e5d156 (diff) | |
download | virtme-4c038ed54883f116e599617e6091e6173bf1b6b0.tar.gz |
run: Add a --cwd command to change the working directory
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Marcos Paulo de Souza <mpdsouza@suse.com>
-rw-r--r-- | virtme/commands/run.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 52e8de6..ce00154 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -112,6 +112,8 @@ def make_parser() -> argparse.ArgumentParser: g = parser.add_argument_group(title='Guest userspace configuration') g.add_argument('--pwd', action='store_true', help='Propagate current working directory to the guest') + g.add_argument('--cwd', action='store', + help='Change guest working directory') g = parser.add_argument_group(title='Sharing resources with guest') g.add_argument('--rwdir', action='append', default=[], @@ -490,6 +492,13 @@ def do_it() -> int: return 1 kernelargs.append('virtme_chdir=%s' % rel_pwd) + if args.cwd: + rel_cwd = os.path.relpath(args.cwd, args.root) + if rel_cwd.startswith('..'): + print('specified working directory is not contained in the root') + return 1 + kernelargs.append('virtme_chdir=%s' % rel_cwd) + initrdpath: Optional[str] if need_initramfs: |