summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@gmail.com>2021-11-12 23:29:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-13 16:09:53 +0000
commit448eb1fd21287ba16b17e9402ce040b86ae3638c (patch)
tree4ed6a6e9f9d22f88ecfa6e4cef3d7879da47e293
parenta2023319eb315ba71f6c6699d2068e51524a2908 (diff)
downloadopenembedded-core-contrib-448eb1fd21287ba16b17e9402ce040b86ae3638c.tar.gz
runqemu: support rootfs mounted ro
Optionally allow to set QB_KERNEL_ROOT to e.g. "/dev/vda ro" to mount the rootfs reay-only in Qemu. Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/qemuboot.bbclass2
-rwxr-xr-xscripts/runqemu8
2 files changed, 9 insertions, 1 deletions
diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index bf529e9aa4..8cdb544a94 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -36,6 +36,8 @@
# in system mode, where system is experiencing entropy starvation
#
# QB_KERNEL_ROOT: kernel's root, e.g., /dev/vda
+# By default "/dev/vda rw" gets passed to the kernel.
+# To mount the rootfs read-only QB_KERNEL_ROOT can be set to e.g. "/dev/vda ro".
#
# QB_NETWORK_DEVICE: network device, e.g., "-device virtio-net-pci,netdev=net0,mac=@MAC@",
# it needs work with QB_TAP_OPT and QB_SLIRP_OPT.
diff --git a/scripts/runqemu b/scripts/runqemu
index d4f0888f8d..efb98ab9e0 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1266,7 +1266,13 @@ class BaseConfig(object):
self.rootfs_options = vm_drive
if not self.fstype in self.vmtypes:
self.rootfs_options += ' -no-reboot'
- self.kernel_cmdline = 'root=%s rw' % (self.get('QB_KERNEL_ROOT'))
+
+ # By default, ' rw' is appended to QB_KERNEL_ROOT unless either ro or rw is explicitly passed.
+ qb_kernel_root = self.get('QB_KERNEL_ROOT')
+ qb_kernel_root_l = qb_kernel_root.split()
+ if not ('ro' in qb_kernel_root_l or 'rw' in qb_kernel_root_l):
+ qb_kernel_root += ' rw'
+ self.kernel_cmdline = 'root=%s' % qb_kernel_root
if self.fstype == 'nfs':
self.rootfs_options = ''