From c1c6b278e63406b5323beb5efaf3e45a538d2371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Stefanik?= Date: Sun, 25 Feb 2024 02:39:43 +0100 Subject: [PATCH] Use qemu's GUI support in interactive mode Previously, there was no way to access the additional consoles in qemu mode, due to qemu running in -nographic mode with a serial console. This is perfectly fine in non-interactive mode, but we can make interactive mode more usable by using a graphical console like on bare metal. Also drop -no-reboot from interactive mode, since rebooting (e.g. to load a newly compiled kernel) makes sense in this case. --- rootfs.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/rootfs.py b/rootfs.py index 6f4faf0..c1702cf 100755 --- a/rootfs.py +++ b/rootfs.py @@ -38,7 +38,7 @@ def create_configuration_file(args): config.write(f"FINAL_JOBS={args.cores}\n") config.write(f"INTERNAL_CI={args.internal_ci or False}\n") config.write(f"INTERACTIVE={args.interactive}\n") - config.write(f"BARE_METAL={args.bare_metal}\n") + config.write(f"BARE_METAL={args.bare_metal or (args.qemu and args.interactive)}\n") if (args.bare_metal or args.qemu) and not args.kernel: if args.repo or args.external_sources: config.write("DISK=sdb1\n") @@ -254,7 +254,6 @@ print(shutil.which('chroot')) '-enable-kvm', '-m', str(args.qemu_ram) + 'M', '-smp', str(args.cores), - '-no-reboot', '-drive', 'file=' + target.get_disk("disk") + ',format=raw' ] if target.get_disk("external") is not None: @@ -264,17 +263,20 @@ print(shutil.which('chroot')) arg_list += [ '-nic', 'user,ipv6=off,model=e1000', '-kernel', args.kernel, - '-nographic', - '-append', 'console=ttyS0 root=/dev/sda1 rootfstype=ext3 init=/init rw' + '-append', ] - run(args.qemu_cmd, *arg_list) + if args.interactive: + arg_list += ['consoleblank=0 earlyprintk=vga root=/dev/sda1 ' + 'rootfstype=ext3 init=/init rw'] + else: + arg_list += ['console=ttyS0 earlycon=uart8250,io,0x3f8,115200n8 ' + 'root=/dev/sda1 rootfstype=ext3 init=/init rw'] else: generator.prepare(target, kernel_bootstrap=True, target_size=size) arg_list = [ '-enable-kvm', '-m', str(args.qemu_ram) + 'M', '-smp', str(args.cores), - '-no-reboot', '-drive', 'file=' + generator.target_dir + '.img' + ',format=raw' ] if target.get_disk("external") is not None: @@ -283,10 +285,11 @@ print(shutil.which('chroot')) ] arg_list += [ '-machine', 'kernel-irqchip=split', - '-nic', 'user,ipv6=off,model=e1000', - '-nographic' + '-nic', 'user,ipv6=off,model=e1000' ] - run(args.qemu_cmd, *arg_list) + if not args.interactive: + arg_list += ['-no-reboot', '-nographic'] + run(args.qemu_cmd, *arg_list) if __name__ == "__main__": main()