mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
Nowadays there are hard drives and operating systems which support "4K native" sector size. In this mode physical and logical block size exposed to the operating system is equal to 4096 bytes. GPT partition table (as a known example) being created in this mode will place GPT header at LBA1 which is 4096 bytes. libguetfs is unable to recognize partition table on such physical block devices or disk images. The reason is that libguestfs appliance will look for a GPT header at LBA1 which is seen at 512 byte offset. In order to fix the issue we need a way to provide correct logical block size for attached disks. Fortunately QEMU and libvirt already provides a way to specify physical/logical block size per disk basis. After discussion in a mailing list we agreed that physical block size is rarely used and is not so important. Thus both physical and logical block size will be set to the same value. In this patch one more optional parameter 'blocksize' is added to add_drive_opts API method. Valid values are 512 and 4096. add_drive_scratch has the same optional parameter for a consistency and testing purpose. add-domain and add_libvirt_dom will pass logical_block_size value from libvirt XML to add_drive_opts method.