summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Weihmann <kweihmann@outlook.com>2020-04-15 20:39:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-02 16:12:36 +0100
commit81c46e46a8f3db9659fef58d6bd1ce0e45f4ff95 (patch)
tree3449be7e5105a1a6f8571d8ba4af9d12b62c9d01
parentc330f617044953bbcdb3b23b0770904ede4d1302 (diff)
downloadpoky-81c46e46a8f3db9659fef58d6bd1ce0e45f4ff95.tar.gz
runqemu: add QB_ROOTFS_EXTRA_OPT parameter
Content of the optional parameter will be appended to the rootfs-device in the qemu configuration, in case QB_ROOTFS_OPT is not specified. By default this is empty. Example use cases are: Defining 'readonly' when using squashfs, so multiple instances of qemu can share the same base image, something that cannot be done by just specifying 'snapshot'. Defining 'bootindex=0' which helps to get past the EFI shell in ovmf-binary. This also enables the use case of running WIC images with EFI bootloader through the testimage.bbclass. (From OE-Core rev: 1a5cb1bd56be2b784208516a7c73c49906c7022f) Signed-off-by: Konrad Weihmann <kweihmann@outlook.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit e9b8c194636cb5505774a2a71bf54450580dd5b8) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/qemuboot.bbclass5
-rwxr-xr-xscripts/runqemu11
2 files changed, 13 insertions, 3 deletions
diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index 54044c38da..99da543f9a 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -65,6 +65,10 @@
65# " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon" 65# " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"
66# Note, runqemu will replace "@PORT@" with the port number which is used. 66# Note, runqemu will replace "@PORT@" with the port number which is used.
67# 67#
68# QB_ROOTFS_EXTRA_OPT: extra options to be appended to the rootfs device in case there is none specified by QB_ROOTFS_OPT.
69# Can be used to automatically determine the image from the other variables
70# but define things link 'bootindex' when booting from EFI or 'readonly' when using squashfs
71# without the need to specify a dedicated qemu configuration
68# Usage: 72# Usage:
69# IMAGE_CLASSES += "qemuboot" 73# IMAGE_CLASSES += "qemuboot"
70# See "runqemu help" for more info 74# See "runqemu help" for more info
@@ -77,6 +81,7 @@ QB_OPT_APPEND ?= "-show-cursor"
77QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@" 81QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@"
78QB_CMDLINE_IP_SLIRP ?= "ip=dhcp" 82QB_CMDLINE_IP_SLIRP ?= "ip=dhcp"
79QB_CMDLINE_IP_TAP ?= "ip=192.168.7.@CLIENT@::192.168.7.@GATEWAY@:255.255.255.0" 83QB_CMDLINE_IP_TAP ?= "ip=192.168.7.@CLIENT@::192.168.7.@GATEWAY@:255.255.255.0"
84QB_ROOTFS_EXTRA_OPT ?= ""
80 85
81# This should be kept align with ROOT_VM 86# This should be kept align with ROOT_VM
82QB_DRIVE_TYPE ?= "/dev/sd" 87QB_DRIVE_TYPE ?= "/dev/sd"
diff --git a/scripts/runqemu b/scripts/runqemu
index 6a77e3db9a..310d79fdc5 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1196,6 +1196,10 @@ class BaseConfig(object):
1196 else: 1196 else:
1197 self.rootfs_options = '-drive file=%s,if=virtio,format=%s' % (self.rootfs, rootfs_format) 1197 self.rootfs_options = '-drive file=%s,if=virtio,format=%s' % (self.rootfs, rootfs_format)
1198 1198
1199 qb_rootfs_extra_opt = self.get("QB_ROOTFS_EXTRA_OPT")
1200 if qb_rootfs_extra_opt and not qb_rootfs_extra_opt.startswith(","):
1201 qb_rootfs_extra_opt = "," + qb_rootfs_extra_opt
1202
1199 if self.fstype in ('cpio.gz', 'cpio'): 1203 if self.fstype in ('cpio.gz', 'cpio'):
1200 self.kernel_cmdline = 'root=/dev/ram0 rw debugshell' 1204 self.kernel_cmdline = 'root=/dev/ram0 rw debugshell'
1201 self.rootfs_options = '-initrd %s' % self.rootfs 1205 self.rootfs_options = '-initrd %s' % self.rootfs
@@ -1208,14 +1212,15 @@ class BaseConfig(object):
1208 drive_type = self.get('QB_DRIVE_TYPE') 1212 drive_type = self.get('QB_DRIVE_TYPE')
1209 if drive_type.startswith("/dev/sd"): 1213 if drive_type.startswith("/dev/sd"):
1210 logger.info('Using scsi drive') 1214 logger.info('Using scsi drive')
1211 vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' \ 1215 vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd%s' \
1212 % (self.rootfs, rootfs_format) 1216 % (self.rootfs, rootfs_format, qb_rootfs_extra_opt)
1213 elif drive_type.startswith("/dev/hd"): 1217 elif drive_type.startswith("/dev/hd"):
1214 logger.info('Using ide drive') 1218 logger.info('Using ide drive')
1215 vm_drive = "-drive file=%s,format=%s" % (self.rootfs, rootfs_format) 1219 vm_drive = "-drive file=%s,format=%s" % (self.rootfs, rootfs_format)
1216 elif drive_type.startswith("/dev/vdb"): 1220 elif drive_type.startswith("/dev/vdb"):
1217 logger.info('Using block virtio drive'); 1221 logger.info('Using block virtio drive');
1218 vm_drive = '-drive id=disk0,file=%s,if=none,format=%s -device virtio-blk-device,drive=disk0' % (self.rootfs, rootfs_format) 1222 vm_drive = '-drive id=disk0,file=%s,if=none,format=%s -device virtio-blk-device,drive=disk0%s' \
1223 % (self.rootfs, rootfs_format,qb_rootfs_extra_opt)
1219 else: 1224 else:
1220 # virtio might have been selected explicitly (just use it), or 1225 # virtio might have been selected explicitly (just use it), or
1221 # is used as fallback (then warn about that). 1226 # is used as fallback (then warn about that).