Bug 2168245

Summary: [seabios] Can't boot from a disk with 4K sector size
Product: Red Hat Enterprise Linux 9 Reporter: Jiri Kortus <jikortus>
Component: seabiosAssignee: Gerd Hoffmann <kraxel>
Status: NEW --- QA Contact: Xueqiang Wei <xuwei>
Severity: low Docs Contact:
Priority: low    
Version: 9.1CC: aliang, coli, jinzhao, juzhang, kraxel, kwolf, meili, pkrempa, vgoyal, virt-maint, xuwei
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
machine.xml none

Description Jiri Kortus 2023-02-08 14:55:28 UTC
Description of problem:
It is not possible to boot from a disk with physical/logical sector size of 4096 bytes. The disk is listed in the boot order configuration section of a VM in VirtManager (as well as in the VM XML configuration obtained via virsh dumpxml), however once the VM is started, this disk is ignored completely. The VM doesn't attempt to boot from it and it is not even listed in the available boot devices shown upon VM start.

However, the disk is available to the VM and can be used for installation.

Version-Release number of selected component (if applicable):
libvirt-8.5.0-7.el9_1.x86_64, qemu-kvm-7.0.0-13.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create a VM with one disk, modify the configuration via virsh edit, so that the disk uses 4K physical and logical block sizes by inserting blockio element into the <disk> configuration:
   <blockio logical_block_size='4096' physical_block_size='4096'/>
2. Enable the boot menu on machine start and make sure the disk is selected as one of the available boot devices
3. Start the VM and observe the boot menu.

Actual results:
The disk is not available as a boot device and the VM won't boot from it. It can also be seen in the configuration XML that there is boot order set for the disk.

Expected results:
The disk is available for boot - both for manual selection in the menu and for automated boot based on the configured boot order.

Comment 1 Jiri Kortus 2023-02-08 15:58:14 UTC
Created attachment 1942914 [details]
machine.xml

Comment 2 Peter Krempa 2023-02-09 12:27:33 UTC
The XML you've attached has the following two disks:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/RHEL-9.2.0-20230119.t.4-x86_64-boot.iso'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <boot order='1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/rhel9.0-test'/>
      <blockio logical_block_size='4096' physical_block_size='4096'/>
      <target dev='sdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

The second device does not actually set the '<boot order=' thus it's not bootable. Not marking it as bootable also in certain cases causes that it is not included in the boot menu as the device does not get activated firmware/bios.

Additionally the above XML doesn't even work as discussed in 2168247, due to the issue of 4k sectors not really working with sata/ide disks.

Did you attach the correct XML?

Comment 3 Jiri Kortus 2023-02-16 17:19:06 UTC
Sorry for providing you with a wrong XML. I reproduced this problem again and will attach a proper XML - with just one disk with 4K/4K physical/logical block sizes and boot order value set:
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/rhel9.0.qcow2'/>
      <blockio logical_block_size='4096' physical_block_size='4096'/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>

I also noticed I didn't mention properly the necessary configuration detail (sector sizes) in bug description, so I'm going to update it accordingly.

Thank you,
Jirka

Comment 6 Peter Krempa 2023-02-16 18:08:43 UTC
So your problem is that 4k sectors are not supported with legacy bios-based VMs by the seabios firmware.

Seabios prints the following:

virtio-blk 04:00.0 block size 4096 is unsupported

On the debug console which I enabled by adding:

    <serial type='file'>
      <source path='/tmp/debugcon.log'/>
      <target type='isa-debug' port='1'>
        <model name='isa-debugcon'/>
      </target>
      <alias name='serial1'/>
      <address type='isa' iobase='0x402'/>
    </serial>

Justification is here.  The legacy interface is 512byte only.

https://mail.coreboot.org/pipermail/seabios/2016-April/010596.html

I suggest you use UEFI instead as a workaround which should work. Unfortunately it didn't work for my test VM but that may be corrupted. I'll move this to qemu to assess whether using efi is suitable.

Other possibility is to move to the 'seabios' component as a feature request to do emulation.

Comment 7 qing.wang 2023-03-01 09:39:00 UTC
The seabios can not read the boot disk when it using 
logical_block_size=4096,physical_block_size=4096 on it


It may works under ovmf

-blockdev driver=qcow2,file.driver=file,cache.direct=off,cache.no-flush=on,file.filename=/home/kvm_autotest_root/images/rhel850-new-64-virtio.qcow2,node-name=drive_image1,file.aio=threads   
-device virtio-blk-pci,id=os,drive=drive_image1,bus=pcie-root-port-3,bootindex=0,logical_block_size=4096,physical_block_size=4096,serial=OS_DISK   

-blockdev driver=qcow2,file.driver=file,file.filename=/home/kvm_autotest_root/images/data1.qcow2,node-name=data_image1   
-device virtio-blk-pci,id=data1,drive=data_image1,bus=pcie-root-port-4,bootindex=1,logical_block_size=4096,physical_block_size=4096,serial=DATA_DISK

Comment 8 aihua liang 2023-03-03 09:22:32 UTC
Hi,Jiri

 From qing's test result in comment7, 4k sector size works ok under UEFI, you can check it in your test env.


Thanks,
Aliang

Comment 9 Vivek Goyal 2023-03-08 21:47:38 UTC
Kevin, as we were discussing that 4K sector size is not supported with seabios. So should we close this bug as NOTABUG. It works with UEFI.

Comment 19 Gerd Hoffmann 2023-04-14 13:32:23 UTC
test build:
https://kojihub.stream.centos.org/koji/taskinfo?taskID=2126701

Comment 21 Gerd Hoffmann 2023-05-03 09:06:21 UTC
new scratch build
https://kojihub.stream.centos.org/koji/taskinfo?taskID=2175528

Comment 24 Gerd Hoffmann 2023-05-16 11:01:48 UTC
Turned out to be a build problems, patches where not actually applied ...
New test build: https://kojihub.stream.centos.org/koji/taskinfo?taskID=2224284

Comment 25 Xueqiang Wei 2023-05-23 03:33:52 UTC
(In reply to Gerd Hoffmann from comment #24)
> Turned out to be a build problems, patches where not actually applied ...
> New test build:
> https://kojihub.stream.centos.org/koji/taskinfo?taskID=2224284

Tested it with the scratch build, printing to the screen from threads work well. Found the following string in the screen.

hardware setup errors:
virtio-blk 04:00.0 block size 4096 is unsupported


Versions:
kernel-5.14.0-306.el9.x86_64
qemu-kvm-8.0.0-2.el9
seabios-bin-1.16.1-1.el9.bz2168245.20230516.1256.noarch