1 |
On Monday, 24 May 2021 02:01:15 BST Oliver Dixon wrote: |
2 |
> Hi, |
3 |
> |
4 |
> I decided to bite the bullet yesterday and switch from clunky, and generally |
5 |
> untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a |
6 |
> working Gentoo VM with all the bells and whistles I need/want (UEFI |
7 |
> booting, NIC passthrough, SSH forwarding, NFSv4 support, etc.), but it's |
8 |
> running in an SDL window, which means the guest TTY will become confused |
9 |
> and pretty much unusable whenever I change the window size. (Which is |
10 |
> rather often since I use a tiling window manager.) |
11 |
|
12 |
Have you tried '-display sdl,gl=on -vga virtio' and then use Ctrl+Alt+f to |
13 |
maximise it early in the boot process? It seems to work OK here, without |
14 |
distorting the contents of the VM window. |
15 |
|
16 |
|
17 |
> Since I'll only be using the TTY, the '-nographic' option to QEMU seems |
18 |
> appropriate, but this causes the initial bootloader screen (OVMF/EDK-II) and |
19 |
> GRUB to hang on stdout (screenshot attached). Here's my QEMU invocation |
20 |
> script: |
21 |
> |
22 |
> #!/bin/bash |
23 |
> |
24 |
> exec qemu-system-x86_64 \ |
25 |
> -enable-kvm \ |
26 |
> -cpu host \ |
27 |
> -drive file=Gentoo-VM.img,if=virtio \ |
28 |
> -nic user,hostfwd=tcp:127.0.0.1:2222-:22 \ |
29 |
> -m 4G \ |
30 |
> -smp 12 \ |
31 |
> -name "Gentoo VM" \ |
32 |
> -bios /usr/share/edk2-ovmf/OVMF_CODE.fd \ |
33 |
> -nographic \ |
34 |
> $@ |
35 |
> |
36 |
> I have to spawn another terminal to kill the QEMU process. I can make a bit |
37 |
> of progress by telling the kernel to direct early messages to ttyS0, which |
38 |
> does display the early bootup messages from Linux, but then hangs just |
39 |
> before a login prompt would be shown (screenshot attached). |
40 |
> |
41 |
> console=tty0 console=ttyS0,9600n8 |
42 |
> |
43 |
> Again, I can't do anything other than a `pkill qemu` from elsewhere. |
44 |
> |
45 |
> Any ideas from someone more familiar with QEMU hosting Linux guests? I've |
46 |
> only been using it for a day, most of which has been trying to fix this |
47 |
> annoying behaviour. |
48 |
> |
49 |
> Cheers. |
50 |
|
51 |
As far as I understand it (haven't tried it) you'll need to redirect the |
52 |
virtual console of the guest to the host. Also configure GRUB to do the same. |
53 |
|
54 |
For GRUB you'll probably need: |
55 |
|
56 |
GRUB_TIMEOUT_STYLE=menu |
57 |
GRUB_CMDLINE_LINUX="console=ttyS0" |
58 |
GRUB_TERMINAL="console serial" |
59 |
|
60 |
For the guest kernel command line you can append console=ttyS0. Theoretically |
61 |
it should arrive at a login prompt on your terminal. |
62 |
|
63 |
For testing kernels have a look here: |
64 |
|
65 |
https://qemu-project.gitlab.io/qemu/system/linuxboot.html |
66 |
|
67 |
|
68 |
To shut down the guest you could try using the QEMU monitor (Ctrl+Alt+2) and |
69 |
run 'system_powerdown', or Ctrl+Alt+3 for the serial port. |