aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-04-30 17:38:13 -0700
committerAndy Lutomirski <luto@kernel.org>2016-04-30 17:38:13 -0700
commitea58d4232b5c0a77a30a244280c35e6a18525f0a (patch)
tree2e21e57d9faa888c28ebc37df63b7a7f187bb074
parenta449fc204bd23d8a601d55f50c3cba4ff5ed591f (diff)
downloadvirtme-ea58d4232b5c0a77a30a244280c35e6a18525f0a.tar.gz
virtme-run: Don't panic if an unrecognized argument is passed to -a
The kernel interprets: init=/bin/sh foobar -- baz quux as a request to run /bin/sh foobar baz quux, unless foobar is a known kernel parameter. As a result, passing '-a foobar' to virtme-run will panic the guest. I think this is a bug or design error in the kernel argument parser. Fortunately, there's another counterbalancing quirk: foobar init=/bin/sh -- baz quux will cause foobar to be ignored because init=/bin/sh resets accumulated init arguments. Reorder our argument generation to take advantage of this quirk and avoid panicking if a bad argument is passed. Signed-off-by: Andy Lutomirski <luto@kernel.org>
-rw-r--r--virtme/commands/run.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/virtme/commands/run.py b/virtme/commands/run.py
index 51d9c11..8a2a3d7 100644
--- a/virtme/commands/run.py
+++ b/virtme/commands/run.py
@@ -197,8 +197,6 @@ def main():
export_virtfs(qemu, arch, qemuargs, guest_tools_path,
'virtme.guesttools')
- kernelargs.append('init=/bin/sh')
-
initargs = ['-c', 'mount -t tmpfs run /run;mkdir -p /run/virtme/guesttools;/bin/mount -n -t 9p -o ro,version=9p2000.L,trans=virtio,access=any virtme.guesttools /run/virtme/guesttools;exec /run/virtme/guesttools/virtme-init']
# Map modules
@@ -395,6 +393,12 @@ def main():
# Now that we're done setting up kernelargs, append user-specified args
# and then initargs
kernelargs.extend(args.kopt)
+
+ # Unknown options get turned into arguments to init, which is annoying
+ # because we're explicitly passing '--' to set the arguments directly.
+ # Fortunately, 'init=' will clear any arguments parsed so far, so make
+ # sure that 'init=' appears directly before '--'.
+ kernelargs.append('init=/bin/sh')
kernelargs.append('--')
kernelargs.extend(initargs)