aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz Bauer <lmb@cloudflare.com>2019-06-17 09:19:52 +0100
committerLorenz Bauer <lmb@cloudflare.com>2019-06-17 09:19:52 +0100
commit24546316be87b4d1218f7676631d9e41e22b050c (patch)
tree3386bfabe204805afc60d08398ee221b8e536d9d
parentc7d06677da1d3e91ebe82b159d2f7732f804a058 (diff)
downloadvirtme-24546316be87b4d1218f7676631d9e41e22b050c.tar.gz
mkinitramfs: respect --rw flag
Make the initramfs mount the root filesystems read-write if the user requested it via the --rw flag. Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
-rw-r--r--virtme/commands/run.py3
-rw-r--r--virtme/mkinitramfs.py12
2 files changed, 10 insertions, 5 deletions
diff --git a/virtme/commands/run.py b/virtme/commands/run.py
index c942486..d6c9d8d 100644
--- a/virtme/commands/run.py
+++ b/virtme/commands/run.py
@@ -392,6 +392,9 @@ def main():
file=sys.stderr)
return 1
+ if args.rw:
+ config.access = 'rw'
+
# Set up the initramfs (warning: hack ahead)
tmpfd,tmpname = tempfile.mkstemp('irfs')
os.unlink(tmpname)
diff --git a/virtme/mkinitramfs.py b/virtme/mkinitramfs.py
index ecb70ff..baaefe9 100644
--- a/virtme/mkinitramfs.py
+++ b/virtme/mkinitramfs.py
@@ -74,7 +74,7 @@ source /modules/load_all.sh
log 'mounting hostfs...'
-if ! /bin/mount -n -t 9p -o ro,version=9p2000.L,trans=virtio,access=any /dev/root /newroot/; then
+if ! /bin/mount -n -t 9p -o {access},version=9p2000.L,trans=virtio,access=any /dev/root /newroot/; then
echo "Failed to mount real root. We are stuck."
sleep 5
exit 1
@@ -134,19 +134,21 @@ exec /bin/switch_root /newroot "$init" "$@"
"""
-def generate_init():
+def generate_init(config):
out = io.StringIO()
out.write(_INIT.format(
- logfunc=_LOGFUNC))
+ logfunc=_LOGFUNC,
+ access=config.access))
return out.getvalue().encode('utf-8')
class Config:
- __slots__ = ['modfiles', 'virtme_data', 'virtme_init_path', 'busybox']
+ __slots__ = ['modfiles', 'virtme_data', 'virtme_init_path', 'busybox', 'access']
def __init__(self):
self.modfiles = []
self.virtme_data = {}
self.virtme_init_path = None
self.busybox = None
+ self.access = 'ro'
def mkinitramfs(out, config):
cw = cpiowriter.CpioWriter(out)
@@ -158,7 +160,7 @@ def mkinitramfs(out, config):
install_modules(cw, config.modfiles)
for name,contents in config.virtme_data.items():
cw.write_file(b'run_virtme/data/' + name, body=contents, mode=0o755)
- cw.write_file(b'init', body=generate_init(),
+ cw.write_file(b'init', body=generate_init(config),
mode=0o755)
cw.write_trailer()