]> git.feebdaed.xyz Git - 0xmirror/qemu.git/commit
block: use pwrite_zeroes_alignment when writing first sector
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 7 Oct 2025 14:16:59 +0000 (10:16 -0400)
committerKevin Wolf <kwolf@redhat.com>
Tue, 25 Nov 2025 14:26:22 +0000 (15:26 +0100)
commitd704a13d2c025779bc91d04e127427347ddcf3b3
treea8b564fc34071cbca187781f965648806ca3bc27
parent98e788b91ad037193b1fb375561ef7e0fef3c2fd
block: use pwrite_zeroes_alignment when writing first sector

Since commit 5634622bcb33 ("file-posix: allow BLKZEROOUT with -t
writeback"), qemu-img create errors out on a Linux loop block device
with a 4 KB sector size:

  # dd if=/dev/zero of=blockfile bs=1M count=1024
  # losetup --sector-size 4096 /dev/loop0 blockfile
  # qemu-img create -f raw /dev/loop0 1G
  Formatting '/dev/loop0', fmt=raw size=1073741824
  qemu-img: /dev/loop0: Failed to clear the new image's first sector: Invalid argument

Use the pwrite_zeroes_alignment block limit to avoid misaligned
fallocate(2) or ioctl(BLKZEROOUT) in the block/file-posix.c block
driver.

Cc: qemu-stable@nongnu.org
Fixes: 5634622bcb33 ("file-posix: allow BLKZEROOUT with -t writeback")
Reported-by: Jean-Louis Dupond <jean-louis@dupond.be>
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/3127
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20251007141700.71891-3-stefanha@redhat.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block/block-backend.c
include/system/block-backend-io.h