summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@siemens.com>2019-06-09 14:03:42 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-10 17:38:10 +0100
commit0e4c79a7c4dae93fb1b12e8c0a59e8252e3f4b71 (patch)
tree093fd7b83f301dd94cfd89b8a0246732db44f375 /scripts/runqemu
parent79ef0eab3555dc9e9994e899aa00a70ed8573c3c (diff)
downloadpoky-0e4c79a7c4dae93fb1b12e8c0a59e8252e3f4b71.tar.gz
runqemu: QB_FSINFO to support fstype wic images
wic images are handled as vmtype images. Starting qemu with "-kernel" parameter and an image of type wic is not supported. Especially for "-machine virt" the combination of wic with -kernel parameter would be beneficial. The new parameter QB_FSINFO allows to pass image type specific flags to runqemu. QB_FSINFO is a space separated list of parameters. Parameters are structured according to the following pattern: image-type:flag. For now two parameters are supported: - wic:no-kernel-in-fs The wic image is treated as rootfs only image. A -kernel option is passed to qemu. - wic:kernel-in-fs The wic image is treated as VM image including a bootloader and a kernel. This is still the default behavior. Example: QB_DEFAULT_FSTYPE = "wic" QB_FSINFO = "wic:no-kernel-in-fs" QB_KERNEL_ROOT = "/dev/vda1" QB_SYSTEM_NAME = "qemu-system-aarch64" QB_MACHINE = "-machine virt" ... [YOCTO #13336] (From OE-Core rev: 2aa79a67affd22dfa37e4c2945c6ab0c86321f98) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-xscripts/runqemu49
1 files changed, 44 insertions, 5 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index af90c010da..4079f2b17d 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -185,10 +185,11 @@ class BaseConfig(object):
185 self.lock_descriptor = None 185 self.lock_descriptor = None
186 self.bitbake_e = '' 186 self.bitbake_e = ''
187 self.snapshot = False 187 self.snapshot = False
188 self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi')
188 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs', 189 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
189 'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz') 190 'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz')
190 self.vmtypes = ('hddimg', 'hdddirect', 'wic', 'wic.vmdk', 191 self.vmtypes = ('hddimg', 'hdddirect', 'iso')
191 'wic.qcow2', 'wic.vdi', 'iso') 192 self.fsinfo = {}
192 self.network_device = "-device e1000,netdev=net0,mac=@MAC@" 193 self.network_device = "-device e1000,netdev=net0,mac=@MAC@"
193 # Use different mac section for tap and slirp to avoid 194 # Use different mac section for tap and slirp to avoid
194 # conflicts, e.g., when one is running with tap, the other is 195 # conflicts, e.g., when one is running with tap, the other is
@@ -253,7 +254,7 @@ class BaseConfig(object):
253 254
254 def check_arg_fstype(self, fst): 255 def check_arg_fstype(self, fst):
255 """Check and set FSTYPE""" 256 """Check and set FSTYPE"""
256 if fst not in self.fstypes + self.vmtypes: 257 if fst not in self.fstypes + self.vmtypes + self.wictypes:
257 logger.warning("Maybe unsupported FSTYPE: %s" % fst) 258 logger.warning("Maybe unsupported FSTYPE: %s" % fst)
258 if not self.fstype or self.fstype == fst: 259 if not self.fstype or self.fstype == fst:
259 if fst == 'ramfs': 260 if fst == 'ramfs':
@@ -390,7 +391,7 @@ class BaseConfig(object):
390 391
391 unknown_arg = "" 392 unknown_arg = ""
392 for arg in sys.argv[1:]: 393 for arg in sys.argv[1:]:
393 if arg in self.fstypes + self.vmtypes: 394 if arg in self.fstypes + self.vmtypes + self.wictypes:
394 self.check_arg_fstype(arg) 395 self.check_arg_fstype(arg)
395 elif arg == 'nographic': 396 elif arg == 'nographic':
396 self.qemu_opt_script += ' -nographic' 397 self.qemu_opt_script += ' -nographic'
@@ -536,6 +537,40 @@ class BaseConfig(object):
536 else: 537 else:
537 raise RunQemuError("FSTYPE is NULL!") 538 raise RunQemuError("FSTYPE is NULL!")
538 539
540 # parse QB_FSINFO into dict, e.g. { 'wic': ['no-kernel-in-fs', 'a-flag'], 'ext4': ['another-flag']}
541 wic_fs = False
542 qb_fsinfo = self.get('QB_FSINFO')
543 if qb_fsinfo:
544 qb_fsinfo = qb_fsinfo.split()
545 for fsinfo in qb_fsinfo:
546 try:
547 fstype, fsflag = fsinfo.split(':')
548
549 if fstype == 'wic':
550 if fsflag == 'no-kernel-in-fs':
551 wic_fs = True
552 elif fsflag == 'kernel-in-fs':
553 wic_fs = False
554 else:
555 logger.warn('Unknown flag "%s:%s" in QB_FSINFO', fstype, fsflag)
556 continue
557 else:
558 logger.warn('QB_FSINFO is not supported for image type "%s"', fstype)
559 continue
560
561 if fstype in self.fsinfo:
562 self.fsinfo[fstype].append(fsflag)
563 else:
564 self.fsinfo[fstype] = [fsflag]
565 except Exception:
566 logger.error('Invalid parameter "%s" in QB_FSINFO', fsinfo)
567
568 # treat wic images as vmimages (with kernel) or as fsimages (rootfs only)
569 if wic_fs:
570 self.fstypes = self.fstypes + self.wictypes
571 else:
572 self.vmtypes = self.vmtypes + self.wictypes
573
539 def check_rootfs(self): 574 def check_rootfs(self):
540 """Check and set rootfs""" 575 """Check and set rootfs"""
541 576
@@ -832,7 +867,11 @@ class BaseConfig(object):
832 if self.dtb: 867 if self.dtb:
833 print('DTB: [%s]' % self.dtb) 868 print('DTB: [%s]' % self.dtb)
834 print('MACHINE: [%s]' % self.get('MACHINE')) 869 print('MACHINE: [%s]' % self.get('MACHINE'))
835 print('FSTYPE: [%s]' % self.fstype) 870 try:
871 fstype_flags = ' (' + ', '.join(self.fsinfo[self.fstype]) + ')'
872 except KeyError:
873 fstype_flags = ''
874 print('FSTYPE: [%s%s]' % (self.fstype, fstype_flags))
836 if self.fstype == 'nfs': 875 if self.fstype == 'nfs':
837 print('NFS_DIR: [%s]' % self.rootfs) 876 print('NFS_DIR: [%s]' % self.rootfs)
838 else: 877 else: