* [gentoo-user] QEMU -nographic Option with OVMF
@ 2021-05-24 1:01 Oliver Dixon
2021-05-24 10:52 ` Michael
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Dixon @ 2021-05-24 1:01 UTC (permalink / raw
To: Gentoo Users
[-- Attachment #1.1: Type: text/plain, Size: 1850 bytes --]
Hi,
I decided to bite the bullet yesterday and switch from clunky, and generally
untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a working
Gentoo VM with all the bells and whistles I need/want (UEFI booting, NIC
passthrough, SSH forwarding, NFSv4 support, etc.), but it's running in an SDL
window, which means the guest TTY will become confused and pretty much unusable
whenever I change the window size. (Which is rather often since I use a tiling
window manager.)
Since I'll only be using the TTY, the '-nographic' option to QEMU seems
appropriate, but this causes the initial bootloader screen (OVMF/EDK-II) and
GRUB to hang on stdout (screenshot attached). Here's my QEMU invocation script:
#!/bin/bash
exec qemu-system-x86_64 \
-enable-kvm \
-cpu host \
-drive file=Gentoo-VM.img,if=virtio \
-nic user,hostfwd=tcp:127.0.0.1:2222-:22 \
-m 4G \
-smp 12 \
-name "Gentoo VM" \
-bios /usr/share/edk2-ovmf/OVMF_CODE.fd \
-nographic \
$@
I have to spawn another terminal to kill the QEMU process. I can make a bit of
progress by telling the kernel to direct early messages to ttyS0, which does
display the early bootup messages from Linux, but then hangs just before a login
prompt would be shown (screenshot attached).
console=tty0 console=ttyS0,9600n8
Again, I can't do anything other than a `pkill qemu` from elsewhere.
Any ideas from someone more familiar with QEMU hosting Linux guests? I've only
been using it for a day, most of which has been trying to fix this annoying
behaviour.
Cheers.
--
Oliver Dixon
suugaku.co.uk
FD40 39CD
FDEB E22D
B265 6DFD
A9C4 3889
4CA9 3AEC
[-- Attachment #1.2: linux-hang.png --]
[-- Type: image/png, Size: 73838 bytes --]
[-- Attachment #1.3: grub-hang.png --]
[-- Type: image/png, Size: 6494 bytes --]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] QEMU -nographic Option with OVMF
2021-05-24 1:01 [gentoo-user] QEMU -nographic Option with OVMF Oliver Dixon
@ 2021-05-24 10:52 ` Michael
2021-06-05 12:51 ` Nils Freydank
0 siblings, 1 reply; 3+ messages in thread
From: Michael @ 2021-05-24 10:52 UTC (permalink / raw
To: Gentoo Users
[-- Attachment #1: Type: text/plain, Size: 2693 bytes --]
On Monday, 24 May 2021 02:01:15 BST Oliver Dixon wrote:
> Hi,
>
> I decided to bite the bullet yesterday and switch from clunky, and generally
> untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a
> working Gentoo VM with all the bells and whistles I need/want (UEFI
> booting, NIC passthrough, SSH forwarding, NFSv4 support, etc.), but it's
> running in an SDL window, which means the guest TTY will become confused
> and pretty much unusable whenever I change the window size. (Which is
> rather often since I use a tiling window manager.)
Have you tried '-display sdl,gl=on -vga virtio' and then use Ctrl+Alt+f to
maximise it early in the boot process? It seems to work OK here, without
distorting the contents of the VM window.
> Since I'll only be using the TTY, the '-nographic' option to QEMU seems
> appropriate, but this causes the initial bootloader screen (OVMF/EDK-II) and
> GRUB to hang on stdout (screenshot attached). Here's my QEMU invocation
> script:
>
> #!/bin/bash
>
> exec qemu-system-x86_64 \
> -enable-kvm \
> -cpu host \
> -drive file=Gentoo-VM.img,if=virtio \
> -nic user,hostfwd=tcp:127.0.0.1:2222-:22 \
> -m 4G \
> -smp 12 \
> -name "Gentoo VM" \
> -bios /usr/share/edk2-ovmf/OVMF_CODE.fd \
> -nographic \
> $@
>
> I have to spawn another terminal to kill the QEMU process. I can make a bit
> of progress by telling the kernel to direct early messages to ttyS0, which
> does display the early bootup messages from Linux, but then hangs just
> before a login prompt would be shown (screenshot attached).
>
> console=tty0 console=ttyS0,9600n8
>
> Again, I can't do anything other than a `pkill qemu` from elsewhere.
>
> Any ideas from someone more familiar with QEMU hosting Linux guests? I've
> only been using it for a day, most of which has been trying to fix this
> annoying behaviour.
>
> Cheers.
As far as I understand it (haven't tried it) you'll need to redirect the
virtual console of the guest to the host. Also configure GRUB to do the same.
For GRUB you'll probably need:
GRUB_TIMEOUT_STYLE=menu
GRUB_CMDLINE_LINUX="console=ttyS0"
GRUB_TERMINAL="console serial"
For the guest kernel command line you can append console=ttyS0. Theoretically
it should arrive at a login prompt on your terminal.
For testing kernels have a look here:
https://qemu-project.gitlab.io/qemu/system/linuxboot.html
To shut down the guest you could try using the QEMU monitor (Ctrl+Alt+2) and
run 'system_powerdown', or Ctrl+Alt+3 for the serial port.
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] QEMU -nographic Option with OVMF
2021-05-24 10:52 ` Michael
@ 2021-06-05 12:51 ` Nils Freydank
0 siblings, 0 replies; 3+ messages in thread
From: Nils Freydank @ 2021-06-05 12:51 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
Am Montag, den 24.05.2021 um 11:52:22 Uhr +0100 schrieb Michael <confabulate@kintzios.com>:
> On Monday, 24 May 2021 02:01:15 BST Oliver Dixon wrote:
> > Hi,
> >
> > I decided to bite the bullet yesterday and switch from clunky, and generally
> > untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a
> > working Gentoo VM with all the bells and whistles I need/want (UEFI
> > booting, NIC passthrough, SSH forwarding, NFSv4 support, etc.), but it's
> > running in an SDL window, which means the guest TTY will become confused
> > and pretty much unusable whenever I change the window size. (Which is
> > rather often since I use a tiling window manager.)
>
> Have you tried '-display sdl,gl=on -vga virtio' and then use Ctrl+Alt+f to
> maximise it early in the boot process? It seems to work OK here, without
> distorting the contents of the VM window.
Why don't you (Oliver) just use ssh to log in? That way you wouldn't have to
work around TTY resizing problems. If you don't see a prompt over the serial
connection, than maybe there is no getty/agetty instance listening there.
Unfortunately I can't help further in that direction.
As a different approach you could also put the qemu output into a VNC socket
with '-vnc unix:/path/to/socket'. With '-vga virtio' and '-vga std' I had at
least a reproducible screen resolution at startup.
Inspired by app-emulation/nemu I wrote a short shell script which does this and
works for me. I'll attach it here - feel free to take useful parts out of it,
e.g. the daemon mode of qemu could be interesting for you aswell.
[-- Attachment #2: control-vm.sh --]
[-- Type: application/x-sh, Size: 6722 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-05 12:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-24 1:01 [gentoo-user] QEMU -nographic Option with OVMF Oliver Dixon
2021-05-24 10:52 ` Michael
2021-06-05 12:51 ` Nils Freydank
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox