aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lutomirski <luto@kernel.org>2019-10-10 10:18:34 -0700
committerGitHub <noreply@github.com>2019-10-10 10:18:34 -0700
commit05f7c222ba66cff260e641b6b03312712f992e58 (patch)
tree0025b80fc775fe653af34958beb62fd4f089c2cc
parentdc8aa987d794d1ea75a1a8b69aa5b7dacd98198a (diff)
parent4c038ed54883f116e599617e6091e6173bf1b6b0 (diff)
downloadvirtme-05f7c222ba66cff260e641b6b03312712f992e58.tar.gz
Merge pull request #50 from marcosps/mpdesouza_ezequiel_cwd
run: Add a --cwd command to change the working directory
-rw-r--r--virtme/commands/run.py9
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: