diff --git a/kvm-Enable-vhost-user-gpu-pci-for-RHIVOS.patch b/kvm-Enable-vhost-user-gpu-pci-for-RHIVOS.patch new file mode 100644 index 0000000..659e692 --- /dev/null +++ b/kvm-Enable-vhost-user-gpu-pci-for-RHIVOS.patch @@ -0,0 +1,39 @@ +From 86f52a84c158f7b31455596c9700124977696314 Mon Sep 17 00:00:00 2001 +From: Miroslav Rezanina +Date: Tue, 29 Apr 2025 09:09:51 -0400 +Subject: [PATCH 4/4] Enable vhost-user-gpu-pci for RHIVOS + +RH-Author: Miroslav Rezanina +RH-MergeRequest: 356: Enable vhost-user-gpu-pci for RHIVOS +RH-Jira: RHEL-86056 +RH-Commit: [1/1] d323301596f82a3b0a98b0ac99f839d39199ab32 (mrezanin/centos-src-qemu-kvm) + +RHIVOS needs vhost-user-gpu-pci device to be available. + +Signed-off-by: Miroslav Rezanina +--- + configs/devices/aarch64-softmmu/aarch64-rh-devices.mak | 1 + + configs/devices/x86_64-softmmu/x86_64-rh-devices.mak | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak +index dce5fca821..197fabeb00 100644 +--- a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak ++++ b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak +@@ -45,3 +45,4 @@ CONFIG_VHOST_USER_FS=y + CONFIG_IOMMUFD=y + CONFIG_VHOST_USER_SND=y + CONFIG_VHOST_USER_SCMI=y ++CONFIG_VHOST_USER_GPU=y +diff --git a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak +index 8da1a8f82f..097dad9003 100644 +--- a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak ++++ b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak +@@ -113,3 +113,4 @@ CONFIG_VHOST_USER_VSOCK=y + CONFIG_VHOST_USER_FS=y + CONFIG_IOMMUFD=y + CONFIG_VHOST_USER_SND=y ++CONFIG_VHOST_USER_GPU=y +-- +2.39.3 + diff --git a/kvm-block-io-skip-head-tail-requests-on-EINVAL.patch b/kvm-block-io-skip-head-tail-requests-on-EINVAL.patch new file mode 100644 index 0000000..9650c04 --- /dev/null +++ b/kvm-block-io-skip-head-tail-requests-on-EINVAL.patch @@ -0,0 +1,74 @@ +From 8d520ef6e8959a017535ecfc556b067e4b118cb7 Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi +Date: Thu, 17 Apr 2025 11:05:28 -0400 +Subject: [PATCH 2/4] block/io: skip head/tail requests on EINVAL + +RH-Author: Stefan Hajnoczi +RH-MergeRequest: 354: file-posix: probe discard alignment on Linux block devices +RH-Jira: RHEL-87642 +RH-Acked-by: Kevin Wolf +RH-Acked-by: Eric Blake +RH-Commit: [2/3] 5fddeb3ba2df7c61cdb8dd709e56914f3b5c0972 (stefanha/centos-stream-qemu-kvm) + +When guests send misaligned discard requests, the block layer breaks +them up into a misaligned head, an aligned main body, and a misaligned +tail. + +The file-posix block driver on Linux returns -EINVAL on misaligned +discard requests. This causes bdrv_co_pdiscard() to fail and guests +configured with werror=stop will pause. + +Add a special case for misaligned head/tail requests. Simply continue +when EINVAL is encountered so that the aligned main body of the request +can be completed and the guest is not paused. This is the best we can do +when guest discard limits do not match the host discard limits. + +Fixes: https://issues.redhat.com/browse/RHEL-86032 +Signed-off-by: Stefan Hajnoczi +Reviewed-by: Hanna Czenczek +Message-ID: <20250417150528.76470-3-stefanha@redhat.com> +Reviewed-by: Kevin Wolf +Signed-off-by: Kevin Wolf +(cherry picked from commit 4733cb0833c4b223f92ec0136980eeb5239ecb87) +Signed-off-by: Stefan Hajnoczi +--- + block/io.c | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/block/io.c b/block/io.c +index 1ba8d1aeea..ccec11386b 100644 +--- a/block/io.c ++++ b/block/io.c +@@ -3109,11 +3109,12 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, + /* Invalidate the cached block-status data range if this discard overlaps */ + bdrv_bsc_invalidate_range(bs, offset, bytes); + +- /* Discard is advisory, but some devices track and coalesce ++ /* ++ * Discard is advisory, but some devices track and coalesce + * unaligned requests, so we must pass everything down rather than +- * round here. Still, most devices will just silently ignore +- * unaligned requests (by returning -ENOTSUP), so we must fragment +- * the request accordingly. */ ++ * round here. Still, most devices reject unaligned requests with ++ * -EINVAL or -ENOTSUP, so we must fragment the request accordingly. ++ */ + align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment); + assert(align % bs->bl.request_alignment == 0); + head = offset % align; +@@ -3180,7 +3181,11 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, + } + } + if (ret && ret != -ENOTSUP) { +- goto out; ++ if (ret == -EINVAL && (offset % align != 0 || num % align != 0)) { ++ /* Silently skip rejected unaligned head/tail requests */ ++ } else { ++ goto out; /* bail out */ ++ } + } + + offset += num; +-- +2.39.3 + diff --git a/kvm-file-posix-Fix-crash-on-discard_granularity-0.patch b/kvm-file-posix-Fix-crash-on-discard_granularity-0.patch new file mode 100644 index 0000000..d7145e3 --- /dev/null +++ b/kvm-file-posix-Fix-crash-on-discard_granularity-0.patch @@ -0,0 +1,46 @@ +From 4d575970f12462a054a207b593438aff0d40881a Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 29 Apr 2025 17:56:54 +0200 +Subject: [PATCH 3/4] file-posix: Fix crash on discard_granularity == 0 + +RH-Author: Stefan Hajnoczi +RH-MergeRequest: 354: file-posix: probe discard alignment on Linux block devices +RH-Jira: RHEL-87642 +RH-Acked-by: Kevin Wolf +RH-Acked-by: Eric Blake +RH-Commit: [3/3] dbe73aef453e77263d30ebebc690ab21145f6bab (stefanha/centos-stream-qemu-kvm) + +Block devices that don't support discard have a discard_granularity of +0. Currently, this results in a division by zero when we try to make +sure that it's a multiple of request_alignment. Only try to update +bs->bl.pdiscard_alignment when we got a non-zero discard_granularity +from sysfs. + +Fixes: f605796aae4 ('file-posix: probe discard alignment on Linux block devices') +Signed-off-by: Kevin Wolf +Reviewed-by: Stefan Hajnoczi +Reviewed-by: Eric Blake +Message-ID: <20250429155654.102735-1-kwolf@redhat.com> +Signed-off-by: Stefan Hajnoczi +(cherry picked from commit 71a30d54e6ab1d5c102a8bee2c263414697402ea) +Signed-off-by: Stefan Hajnoczi +--- + block/file-posix.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/block/file-posix.c b/block/file-posix.c +index 0d6e12f880..0d85123d0f 100644 +--- a/block/file-posix.c ++++ b/block/file-posix.c +@@ -1573,7 +1573,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) + int ret; + + ret = hdev_get_pdiscard_alignment(&st, &dalign); +- if (ret == 0) { ++ if (ret == 0 && dalign != 0) { + uint32_t ralign = bs->bl.request_alignment; + + /* Probably never happens, but handle it just in case */ +-- +2.39.3 + diff --git a/kvm-file-posix-probe-discard-alignment-on-Linux-block-de.patch b/kvm-file-posix-probe-discard-alignment-on-Linux-block-de.patch new file mode 100644 index 0000000..cd24d41 --- /dev/null +++ b/kvm-file-posix-probe-discard-alignment-on-Linux-block-de.patch @@ -0,0 +1,131 @@ +From 2baedec75a8a0daf9e93228795d1e6f2974f4825 Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi +Date: Thu, 17 Apr 2025 11:05:27 -0400 +Subject: [PATCH 1/4] file-posix: probe discard alignment on Linux block + devices + +RH-Author: Stefan Hajnoczi +RH-MergeRequest: 354: file-posix: probe discard alignment on Linux block devices +RH-Jira: RHEL-87642 +RH-Acked-by: Kevin Wolf +RH-Acked-by: Eric Blake +RH-Commit: [1/3] 84de24191bfa47e94cd475e78dcafd38a50a5888 (stefanha/centos-stream-qemu-kvm) + +Populate the pdiscard_alignment block limit so the block layer is able +align discard requests correctly. + +Signed-off-by: Stefan Hajnoczi +Message-ID: <20250417150528.76470-2-stefanha@redhat.com> +Reviewed-by: Kevin Wolf +Signed-off-by: Kevin Wolf +(cherry picked from commit f605796aae42885034400c83ed6a9b07cd6d6481) +Signed-off-by: Stefan Hajnoczi +--- + block/file-posix.c | 67 +++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 66 insertions(+), 1 deletion(-) + +diff --git a/block/file-posix.c b/block/file-posix.c +index 56d1972d15..0d6e12f880 100644 +--- a/block/file-posix.c ++++ b/block/file-posix.c +@@ -1276,10 +1276,10 @@ static int get_sysfs_zoned_model(struct stat *st, BlockZoneModel *zoned) + } + #endif /* defined(CONFIG_BLKZONED) */ + ++#ifdef CONFIG_LINUX + /* + * Get a sysfs attribute value as a long integer. + */ +-#ifdef CONFIG_LINUX + static long get_sysfs_long_val(struct stat *st, const char *attribute) + { + g_autofree char *str = NULL; +@@ -1299,6 +1299,30 @@ static long get_sysfs_long_val(struct stat *st, const char *attribute) + } + return ret; + } ++ ++/* ++ * Get a sysfs attribute value as a uint32_t. ++ */ ++static int get_sysfs_u32_val(struct stat *st, const char *attribute, ++ uint32_t *u32) ++{ ++ g_autofree char *str = NULL; ++ const char *end; ++ unsigned int val; ++ int ret; ++ ++ ret = get_sysfs_str_val(st, attribute, &str); ++ if (ret < 0) { ++ return ret; ++ } ++ ++ /* The file is ended with '\n', pass 'end' to accept that. */ ++ ret = qemu_strtoui(str, &end, 10, &val); ++ if (ret == 0 && end && *end == '\0') { ++ *u32 = val; ++ } ++ return ret; ++} + #endif + + static int hdev_get_max_segments(int fd, struct stat *st) +@@ -1318,6 +1342,23 @@ static int hdev_get_max_segments(int fd, struct stat *st) + #endif + } + ++/* ++ * Fills in *dalign with the discard alignment and returns 0 on success, ++ * -errno otherwise. ++ */ ++static int hdev_get_pdiscard_alignment(struct stat *st, uint32_t *dalign) ++{ ++#ifdef CONFIG_LINUX ++ /* ++ * Note that Linux "discard_granularity" is QEMU "discard_alignment". Linux ++ * "discard_alignment" is something else. ++ */ ++ return get_sysfs_u32_val(st, "discard_granularity", dalign); ++#else ++ return -ENOTSUP; ++#endif ++} ++ + #if defined(CONFIG_BLKZONED) + /* + * If the reset_all flag is true, then the wps of zone whose state is +@@ -1527,6 +1568,30 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) + } + } + ++ if (S_ISBLK(st.st_mode)) { ++ uint32_t dalign = 0; ++ int ret; ++ ++ ret = hdev_get_pdiscard_alignment(&st, &dalign); ++ if (ret == 0) { ++ uint32_t ralign = bs->bl.request_alignment; ++ ++ /* Probably never happens, but handle it just in case */ ++ if (dalign < ralign && (ralign % dalign == 0)) { ++ dalign = ralign; ++ } ++ ++ /* The block layer requires a multiple of request_alignment */ ++ if (dalign % ralign != 0) { ++ error_setg(errp, "Invalid pdiscard_alignment limit %u is not a " ++ "multiple of request_alignment %u", dalign, ralign); ++ return; ++ } ++ ++ bs->bl.pdiscard_alignment = dalign; ++ } ++ } ++ + raw_refresh_zoned_limits(bs, &st, errp); + } + +-- +2.39.3 + diff --git a/qemu-kvm.spec b/qemu-kvm.spec index b6729ed..35bb1a4 100644 --- a/qemu-kvm.spec +++ b/qemu-kvm.spec @@ -147,7 +147,7 @@ Obsoletes: %{name}-block-ssh <= %{epoch}:%{version} \ Summary: QEMU is a machine emulator and virtualizer Name: qemu-kvm Version: 10.0.0 -Release: 1%{?rcrel}%{?dist}%{?cc_suffix} +Release: 2%{?rcrel}%{?dist}%{?cc_suffix} # 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) @@ -188,6 +188,14 @@ Patch0016: 0016-vfio-cap-number-of-devices-that-can-be-assigned.patch Patch0017: 0017-Add-support-statement-to-help-output.patch Patch0018: 0018-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch Patch0019: 0019-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch +# For RHEL-87642 - QEMU sends unaligned discards on 4K devices[RHEL-10] +Patch20: kvm-file-posix-probe-discard-alignment-on-Linux-block-de.patch +# For RHEL-87642 - QEMU sends unaligned discards on 4K devices[RHEL-10] +Patch21: kvm-block-io-skip-head-tail-requests-on-EINVAL.patch +# For RHEL-87642 - QEMU sends unaligned discards on 4K devices[RHEL-10] +Patch22: kvm-file-posix-Fix-crash-on-discard_granularity-0.patch +# For RHEL-86056 - Enable 'vhost-user-gpu-pci' in qemu-kvm for RHIVOS +Patch23: kvm-Enable-vhost-user-gpu-pci-for-RHIVOS.patch %if %{have_clang} BuildRequires: clang @@ -1263,6 +1271,16 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Mon May 12 2025 Miroslav Rezanina - 10.0.0-2 +- kvm-file-posix-probe-discard-alignment-on-Linux-block-de.patch [RHEL-87642] +- kvm-block-io-skip-head-tail-requests-on-EINVAL.patch [RHEL-87642] +- kvm-file-posix-Fix-crash-on-discard_granularity-0.patch [RHEL-87642] +- kvm-Enable-vhost-user-gpu-pci-for-RHIVOS.patch [RHEL-86056] +- Resolves: RHEL-87642 + (QEMU sends unaligned discards on 4K devices[RHEL-10]) +- Resolves: RHEL-86056 + (Enable 'vhost-user-gpu-pci' in qemu-kvm for RHIVOS) + * Wed Apr 23 2025 Miroslav Rezanina - 10.0.0-1 - Rebase to QEMU 10.0.0 [RHEL-74473] - Resolves: RHEL-74473