summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-xscripts/runqemu27
1 files changed, 4 insertions, 23 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 4bac151ccf..c28980e616 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -421,27 +421,8 @@ class BaseConfig(object):
421 else: 421 else:
422 raise RunQemuError("Unknown path arg %s" % p) 422 raise RunQemuError("Unknown path arg %s" % p)
423 423
424 def rootfs_fixups(self): 424 def uncompress_rootfs(self):
425 425 """Decompress ZST rootfs image if needed"""
426 """Decompress and/or resize the rootfs image, if needed"""
427 qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
428
429 # Check if sdcard size is a power of 2, as that is currently a requirement for qemu
430 # See https://gitlab.com/qemu-project/qemu/-/issues/1754
431 rootfs_size = os.path.getsize(self.rootfs)
432 rootfs_size_pwr2 = 1 << (rootfs_size - 1).bit_length()
433 if ("if=sd" in qb_rootfs_opt or "if=pflash" in qb_rootfs_opt) and rootfs_size != rootfs_size_pwr2:
434 logger.info("Using sd-card or pflash and is not power of 2. File size %d, power of 2 size %d" %(rootfs_size, rootfs_size_pwr2))
435 logger.info("Attempting to use truncate to correct this.")
436
437 # Ensure the 'truncate' tool is installed before attempting to make a power of 2.
438 if not shutil.which('truncate'):
439 raise RunQemuError(f"'truncate' is required to make {self.rootfs} a power of 2 in size but was not found in PATH")
440 try:
441 subprocess.check_call(['truncate', '-s', str(rootfs_size_pwr2), self.rootfs])
442 except subprocess.CalledProcessError as e:
443 raise RunQemuError(f"Failed to make {self.rootfs} power of 2 in size: {e}")
444
445 if not self.rootfs or not self.fstype.endswith('.zst'): 426 if not self.rootfs or not self.fstype.endswith('.zst'):
446 return 427 return
447 428
@@ -903,7 +884,7 @@ to your build configuration.
903 self.set('QB_MEM', qb_mem) 884 self.set('QB_MEM', qb_mem)
904 885
905 mach = self.get('MACHINE') 886 mach = self.get('MACHINE')
906 if not mach.startswith(('qemumips', 'qemux86', 'qemuloongarch64')) and self.get('QB_DTB') == "": 887 if not mach.startswith(('qemumips', 'qemux86', 'qemuloongarch64')):
907 self.kernel_cmdline_script += ' mem=%s' % self.get('QB_MEM').replace('-m','').strip() + 'M' 888 self.kernel_cmdline_script += ' mem=%s' % self.get('QB_MEM').replace('-m','').strip() + 'M'
908 889
909 self.qemu_opt_script += ' %s' % self.get('QB_MEM') 890 self.qemu_opt_script += ' %s' % self.get('QB_MEM')
@@ -1828,7 +1809,7 @@ def main():
1828 config.check_args() 1809 config.check_args()
1829 config.read_qemuboot() 1810 config.read_qemuboot()
1830 config.check_and_set() 1811 config.check_and_set()
1831 config.rootfs_fixups() 1812 config.uncompress_rootfs()
1832 # Check whether the combos is valid or not 1813 # Check whether the combos is valid or not
1833 config.validate_combos() 1814 config.validate_combos()
1834 config.print_config() 1815 config.print_config()