import Oracle_OSS qemu-kvm-10.1.0-17.el9_8.5
This commit is contained in:
parent
a27fa3a882
commit
070b9b1aa1
@ -0,0 +1,91 @@
|
||||
From c1a85d75e71f45db57a849f46b7e352b6359ca19 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Tue, 7 Oct 2025 10:16:59 -0400
|
||||
Subject: [PATCH] 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>
|
||||
(cherry picked from commit d704a13d2c025779bc91d04e127427347ddcf3b3)
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
---
|
||||
block.c | 3 ++-
|
||||
block/block-backend.c | 11 +++++++++++
|
||||
include/system/block-backend-io.h | 1 +
|
||||
3 files changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block.c b/block.c
|
||||
index 8848e9a7ed..be77e03904 100644
|
||||
--- a/block.c
|
||||
+++ b/block.c
|
||||
@@ -606,12 +606,13 @@ create_file_fallback_zero_first_sector(BlockBackend *blk,
|
||||
int64_t current_size,
|
||||
Error **errp)
|
||||
{
|
||||
+ uint32_t alignment = blk_get_pwrite_zeroes_alignment(blk);
|
||||
int64_t bytes_to_clear;
|
||||
int ret;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- bytes_to_clear = MIN(current_size, BDRV_SECTOR_SIZE);
|
||||
+ bytes_to_clear = MIN(current_size, MAX(BDRV_SECTOR_SIZE, alignment));
|
||||
if (bytes_to_clear) {
|
||||
ret = blk_co_pwrite_zeroes(blk, 0, bytes_to_clear, BDRV_REQ_MAY_UNMAP);
|
||||
if (ret < 0) {
|
||||
diff --git a/block/block-backend.c b/block/block-backend.c
|
||||
index d6df369188..98315d4470 100644
|
||||
--- a/block/block-backend.c
|
||||
+++ b/block/block-backend.c
|
||||
@@ -2305,6 +2305,17 @@ uint32_t blk_get_request_alignment(BlockBackend *blk)
|
||||
return bs ? bs->bl.request_alignment : BDRV_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
+/* Returns the optimal write zeroes alignment, in bytes; guaranteed nonzero */
|
||||
+uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk)
|
||||
+{
|
||||
+ BlockDriverState *bs = blk_bs(blk);
|
||||
+ IO_CODE();
|
||||
+ if (!bs) {
|
||||
+ return BDRV_SECTOR_SIZE;
|
||||
+ }
|
||||
+ return bs->bl.pwrite_zeroes_alignment ?: bs->bl.request_alignment;
|
||||
+}
|
||||
+
|
||||
/* Returns the maximum hardware transfer length, in bytes; guaranteed nonzero */
|
||||
uint64_t blk_get_max_hw_transfer(BlockBackend *blk)
|
||||
{
|
||||
diff --git a/include/system/block-backend-io.h b/include/system/block-backend-io.h
|
||||
index ba8dfcc7d0..6d5ac476fc 100644
|
||||
--- a/include/system/block-backend-io.h
|
||||
+++ b/include/system/block-backend-io.h
|
||||
@@ -116,6 +116,7 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
|
||||
void *opaque, int ret);
|
||||
|
||||
uint32_t blk_get_request_alignment(BlockBackend *blk);
|
||||
+uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk);
|
||||
uint32_t blk_get_max_transfer(BlockBackend *blk);
|
||||
uint64_t blk_get_max_hw_transfer(BlockBackend *blk);
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
From b4acb09fee2ce1d4d14d792cbaee1e2a54f8e533 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Tue, 7 Oct 2025 10:16:58 -0400
|
||||
Subject: [PATCH] file-posix: populate pwrite_zeroes_alignment
|
||||
|
||||
Linux block devices require write zeroes alignment whereas files do not.
|
||||
|
||||
It may come as a surprise that block devices opened in buffered I/O mode
|
||||
require the alignment for write zeroes requests although normal
|
||||
read/write requests do not.
|
||||
|
||||
Therefore it is necessary to populate the pwrite_zeroes_alignment field.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-ID: <20251007141700.71891-2-stefanha@redhat.com>
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
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>
|
||||
(cherry picked from commit 98e788b91ad037193b1fb375561ef7e0fef3c2fd)
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
---
|
||||
block/file-posix.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index ace0e23df2..d7f489a40b 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -1602,6 +1602,22 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
|
||||
bs->bl.pdiscard_alignment = dalign;
|
||||
}
|
||||
+
|
||||
+#ifdef __linux__
|
||||
+ /*
|
||||
+ * Linux requires logical block size alignment for write zeroes even
|
||||
+ * when normal reads/writes do not require alignment.
|
||||
+ */
|
||||
+ if (!s->needs_alignment) {
|
||||
+ ret = probe_logical_blocksize(s->fd,
|
||||
+ &bs->bl.pwrite_zeroes_alignment);
|
||||
+ if (ret < 0) {
|
||||
+ error_setg_errno(errp, -ret,
|
||||
+ "Failed to probe logical block size");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+#endif /* __linux__ */
|
||||
}
|
||||
|
||||
raw_refresh_zoned_limits(bs, &st, errp);
|
||||
@ -0,0 +1,105 @@
|
||||
From 760fc5137eda66c2066595fd8abfe5273cf34664 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Tue, 7 Oct 2025 10:17:00 -0400
|
||||
Subject: [PATCH] iotests: add Linux loop device image creation test
|
||||
|
||||
This qemu-iotests test case is based on the reproducer that Jean-Louis
|
||||
Dupond <jean-louis@dupond.be> shared in
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/3127.
|
||||
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-ID: <20251007141700.71891-4-stefanha@redhat.com>
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
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>
|
||||
(cherry picked from commit 59a1cf0cd31597d2f6e2c18dc400a1de8427d47d)
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
---
|
||||
tests/qemu-iotests/tests/loop-create-file | 59 +++++++++++++++++++
|
||||
tests/qemu-iotests/tests/loop-create-file.out | 8 +++
|
||||
2 files changed, 67 insertions(+)
|
||||
create mode 100755 tests/qemu-iotests/tests/loop-create-file
|
||||
create mode 100644 tests/qemu-iotests/tests/loop-create-file.out
|
||||
|
||||
diff --git a/tests/qemu-iotests/tests/loop-create-file b/tests/qemu-iotests/tests/loop-create-file
|
||||
new file mode 100755
|
||||
index 0000000000..5ec75b046b
|
||||
--- /dev/null
|
||||
+++ b/tests/qemu-iotests/tests/loop-create-file
|
||||
@@ -0,0 +1,59 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# group: quick
|
||||
+#
|
||||
+# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+#
|
||||
+# Copyright Red Hat, Inc.
|
||||
+#
|
||||
+# Test Linux loop device image creation
|
||||
+#
|
||||
+# This test verifies #3127 "qemu-img create fails on loop device with sector size 4096"
|
||||
+# https://gitlab.com/qemu-project/qemu/-/issues/3127
|
||||
+
|
||||
+seq="$(basename $0)"
|
||||
+echo "QA output created by $seq"
|
||||
+
|
||||
+status=1 # failure is the default!
|
||||
+
|
||||
+_cleanup() {
|
||||
+ if [ -n "$loopdev" ]; then
|
||||
+ sudo losetup --detach "$loopdev"
|
||||
+ fi
|
||||
+
|
||||
+ _cleanup_test_img
|
||||
+}
|
||||
+
|
||||
+trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
+
|
||||
+# get standard environment, filters and checks
|
||||
+cd ..
|
||||
+. ./common.rc
|
||||
+. ./common.filter
|
||||
+
|
||||
+_supported_fmt raw
|
||||
+_supported_proto file
|
||||
+_supported_os Linux
|
||||
+
|
||||
+if ! sudo -n losetup &>/dev/null; then
|
||||
+ _notrun "sudo losetup not available"
|
||||
+fi
|
||||
+
|
||||
+echo
|
||||
+echo "=== Create image on a 4 KB sector size loop device ==="
|
||||
+echo
|
||||
+
|
||||
+_make_test_img -f $IMGFMT 1M
|
||||
+
|
||||
+loopdev=$(sudo losetup --sector-size 4096 --find --show "$TEST_IMG")
|
||||
+if [ -z "$loopdev" ]; then
|
||||
+ _fail
|
||||
+fi
|
||||
+
|
||||
+sudo $QEMU_IMG_PROG create -f raw "$loopdev" 1M | \
|
||||
+ sed -e "s#/dev/loop[0-9]\\+#LOOPDEV#g"
|
||||
+
|
||||
+# success, all done
|
||||
+echo
|
||||
+echo '*** done'
|
||||
+rm -f $seq.full
|
||||
+status=0
|
||||
diff --git a/tests/qemu-iotests/tests/loop-create-file.out b/tests/qemu-iotests/tests/loop-create-file.out
|
||||
new file mode 100644
|
||||
index 0000000000..32d4155695
|
||||
--- /dev/null
|
||||
+++ b/tests/qemu-iotests/tests/loop-create-file.out
|
||||
@@ -0,0 +1,8 @@
|
||||
+QA output created by loop-create-file
|
||||
+
|
||||
+=== Create image on a 4 KB sector size loop device ===
|
||||
+
|
||||
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
|
||||
+Formatting 'LOOPDEV', fmt=raw size=1048576
|
||||
+
|
||||
+*** done
|
||||
@ -149,7 +149,7 @@ Obsoletes: %{name}-block-ssh <= %{epoch}:%{version} \
|
||||
Summary: QEMU is a machine emulator and virtualizer
|
||||
Name: qemu-kvm
|
||||
Version: 10.1.0
|
||||
Release: 17%{?rcrel}%{?dist}%{?cc_suffix}.4
|
||||
Release: 17%{?rcrel}%{?dist}%{?cc_suffix}.5
|
||||
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
|
||||
# Epoch 15 used for RHEL 8
|
||||
# Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5)
|
||||
@ -359,6 +359,12 @@ Patch106: kvm-accel-mshv-Remove-remap-overlapping-mappings-code.patch
|
||||
Patch107: kvm-accel-mshv-implement-cpu_thread_is_idle-hook.patch
|
||||
# For RHEL-184527 - CVE-2026-48914 qemu-kvm: Heap buffer overflow in virtio-blk SCSI request handling [rhel-9.8.z]
|
||||
Patch108: kvm-virtio-blk-add-missing-VIRTIO_BLK_T_SCSI_CMD-size-ch.patch
|
||||
# For RHEL-207387 - file-posix: populate pwrite_zeroes_alignment [rhel-9.8.z]
|
||||
Patch109: kvm-file-posix-populate-pwrite_zeroes_alignment.patch
|
||||
# For RHEL-207387 - block: use pwrite_zeroes_alignment when writing first sector [rhel-9.8.z]
|
||||
Patch110: kvm-block-use-pwrite_zeroes_alignment-when-writing-first.patch
|
||||
# For RHEL-207387 - iotests: add Linux loop device image creation test [rhel-9.8.z]
|
||||
Patch111: kvm-iotests-add-Linux-loop-device-image-creation-test.patch
|
||||
|
||||
|
||||
# For RHEL-11424 - [IBM 9.6 FEAT] KVM: Full boot order support - qemu part
|
||||
@ -2073,6 +2079,13 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Jul 17 2026 Danilo de Paula <ddepaula@redhat.com> - 10.1.0-17.el9_8.5
|
||||
- kvm-file-posix-populate-pwrite_zeroes_alignment.patch [RHEL-207387]
|
||||
- kvm-block-use-pwrite_zeroes_alignment-when-writing-first.patch [RHEL-207387]
|
||||
- kvm-iotests-add-Linux-loop-device-image-creation-test.patch [RHEL-207387]
|
||||
- Resolves: RHEL-207387
|
||||
(qemu-img create/convert fails on target block device with 4k sector size [rhel-9.8.z])
|
||||
|
||||
* Mon Jun 22 2026 Jon Maloy <jmaloy@redhat.com> - 10.1.0-17.el9_8.4
|
||||
- kvm-virtio-blk-add-missing-VIRTIO_BLK_T_SCSI_CMD-size-ch.patch [RHEL-184527]
|
||||
- Resolves: RHEL-184527
|
||||
|
||||
Loading…
Reference in New Issue
Block a user