FS#76220 - [qemu] guest boot fail with "cache=none" when sector sizes differ
Attached to Project:
Arch Linux
Opened by frederick_metzengerstein (metzengerstein) - Sunday, 16 October 2022, 17:50 GMT
Last edited by David Runge (dvzrv) - Thursday, 20 October 2022, 17:45 GMT
Opened by frederick_metzengerstein (metzengerstein) - Sunday, 16 October 2022, 17:50 GMT
Last edited by David Runge (dvzrv) - Thursday, 20 October 2022, 17:45 GMT
|
Details
Description:
Qemu doesn't boot anymore from drives that use the option "-drive cache=none,...", resulting in the following output after qemu start: "SeaBIOS (version Arch Linux 1.16.0-3-3) Boot failed: could not read the boot disk" It doesn't matter if the boot media is disk or cdrom (see below). Setting cache to writeback, writethrough etc. works. Additional info: System: Linux 6.0.1-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 13 Oct 2022 18:58:49 +0000 x86_64 GNU/Linux package: qemu-desktop 7.1.0-9 Steps to reproduce (example lines): $ qemu-system-x86_64 -enable-kvm -cpu qemu64 -m 2G -net none -drive file=disk.img,format=raw,cache=none $ qemu-system-x86_64 -enable-kvm -cpu qemu64 -m 2G -net none -drive file=cd.iso,media=cdrom,cache=none -boot order=d Last working package versions: linux 5.19.13.arch1-1 qemu-desktop 7.1.0-8 |
This task depends upon
Closed by David Runge (dvzrv)
Thursday, 20 October 2022, 17:45 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed with qemu 7.1.0-10
Thursday, 20 October 2022, 17:45 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed with qemu 7.1.0-10
$ qemu-system-x86_64 -m 2G -drive file=archlinux-2022.06.01-x86_64.iso,media=cdrom,cache=none -boot order=d
Btw, If I enable the boot menu (with -boot menu=on) the disk/iso is listed there. So the bios "sees" it, but cannot boot it.
I haven't made any changes to the system lately, so it must be caused by the upgrade to linux 6.0.1 and/or qemu 7.1.0-9.
Viewing at the boot log, the only warning that appeared after the linux 6.0.1 upgrade is: "amd_gpio AMDI0030:00: failed to get iomux index", but I don't think it's related.
HW: Asus B350-F Gaming, Ryzen 5600x
[1] https://bbs.archlinux.org/viewtopic.php?id=280493
So linux 6.0 is the culprit here.
The bug happens only if the file (disk image, iso) resides on a file system inside a crypto luks container!
(which is my setup: my system root and my vms are on an ext4 partition inside a luks container)
If the file is on a normal filesystem (ext4, ntfs, xfs whatever), the booting works without problem.
Steps to reproduce:
1. create an empty partition on a spare device (here /dev/sdc4)
2. make crypto container ($ cryptsetup luksFormat /dev/sdc4)
3. open container ($ cryptsetup open /dev/sdc4 testcrypto)
4. create a filesystem inside container ($ mkfs.ext4 /dev/mapper/testcrypto)
5. create mountpoint and mount test partition ($ mkdir /mnt/test && mount /dev/mapper/testcrypto /mnt/test)
6. cp an iso to /mnt/test ($ cp archlinux-2022.06.01-x86_64.iso /mnt/test)
7. run qemu cmd ($ qemu-system-x86_64 -m 2G -drive file=/mnt/test/archlinux-2022.06.01-x86_64.iso,media=cdrom,cache=none)
-> it should not boot from the iso
Can someone please try to reproduce?
Btw: the bug happens also with uefi (so it's not related to seabios or sth.)
-> It doesn't show this bug.
So I've compared the luks dump ($ cryptsetup luksDump /dev/sdx) and noticed the difference of the encryption sector sizes:
USB: 512 bytes, SSD: 4096 bytes
Thus, I recreated the container on the SSD with an encryption sector size of 512 (Step 2: $ cryptsetup --sector-size 512 luksFormat /dev/sdc4):
-> qemu boots without problem
So somehow the bug depends on the encryption sector size of the luks volume.
The fdisk output of my SSD (sdc) is: Sector size (logical/physical): 512 bytes / 4096 bytes
According to https://wiki.archlinux.org/title/Advanced_Format#dm-crypt, cryptsetup automatically sets the optimal encryption sector size,
which is 4096 bytes for my SSDs.
Mailing list thread [2]
Upstream patches [3][4]
[1] https://bbs.archlinux.org/viewtopic.php?pid=2063057#p2063057
[2] https://lists.nongnu.org/archive/html/qemu-devel/2022-09/msg05228.html
[3] https://gitlab.com/qemu-project/qemu/-/commit/a7c5f67a
[4] https://gitlab.com/qemu-project/qemu/-/commit/25474d90
@loqs: Thanks for the investigation on this and figuring out the related upstream commits fixing the problem!
Will apply in a pkgrel bump in [testing].
Please let me know if this works as expected.