diff --git a/SOURCES/kvm-dump-Add-arch-cleanup-function.patch b/SOURCES/kvm-dump-Add-arch-cleanup-function.patch new file mode 100644 index 0000000..d8fd368 --- /dev/null +++ b/SOURCES/kvm-dump-Add-arch-cleanup-function.patch @@ -0,0 +1,49 @@ +From e72629e5149aba6f44122ea6d2a803ef136a0c6b Mon Sep 17 00:00:00 2001 +From: Janosch Frank +Date: Thu, 9 Nov 2023 12:04:42 +0000 +Subject: [PATCH] dump: Add arch cleanup function +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some architectures (s390x) need to cleanup after a failed dump to be +able to continue to run the vm. Add a cleanup function pointer and +call it if it's set. + +Signed-off-by: Janosch Frank +Reviewed-by: Thomas Huth +Reviewed-by: Marc-André Lureau +Message-ID: <20231109120443.185979-3-frankja@linux.ibm.com> +Signed-off-by: Thomas Huth +--- + dump/dump.c | 4 ++++ + include/sysemu/dump-arch.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/dump/dump.c b/dump/dump.c +index ad5294e8536f..481905076493 100644 +--- a/dump/dump.c ++++ b/dump/dump.c +@@ -96,6 +96,10 @@ uint64_t cpu_to_dump64(DumpState *s, uint64_t val) + + static int dump_cleanup(DumpState *s) + { ++ if (s->dump_info.arch_cleanup_fn) { ++ s->dump_info.arch_cleanup_fn(s); ++ } ++ + guest_phys_blocks_free(&s->guest_phys_blocks); + memory_mapping_list_free(&s->list); + close(s->fd); +diff --git a/include/sysemu/dump-arch.h b/include/sysemu/dump-arch.h +index 59bbc9be38c9..743916e46ca1 100644 +--- a/include/sysemu/dump-arch.h ++++ b/include/sysemu/dump-arch.h +@@ -24,6 +24,7 @@ typedef struct ArchDumpInfo { + void (*arch_sections_add_fn)(DumpState *s); + uint64_t (*arch_sections_write_hdr_fn)(DumpState *s, uint8_t *buff); + int (*arch_sections_write_fn)(DumpState *s, uint8_t *buff); ++ void (*arch_cleanup_fn)(DumpState *s); + } ArchDumpInfo; + + struct GuestPhysBlockList; /* memory_mapping.h */ diff --git a/SOURCES/io-remove-io-watch-if-TLS-channel-is-closed.patch b/SOURCES/kvm-io-remove-io-watch-if-TLS-channel-is-closed.patch similarity index 100% rename from SOURCES/io-remove-io-watch-if-TLS-channel-is-closed.patch rename to SOURCES/kvm-io-remove-io-watch-if-TLS-channel-is-closed.patch diff --git a/SOURCES/migration-Add-migration-prefix-to-functions-in-target.patch b/SOURCES/kvm-migration-Add-migration-prefix-to-functions-in-target.patch similarity index 100% rename from SOURCES/migration-Add-migration-prefix-to-functions-in-target.patch rename to SOURCES/kvm-migration-Add-migration-prefix-to-functions-in-target.patch diff --git a/SOURCES/migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch b/SOURCES/kvm-migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch similarity index 100% rename from SOURCES/migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch rename to SOURCES/kvm-migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch diff --git a/SOURCES/migration-Move-more-initializations-to-migrate_init.patch b/SOURCES/kvm-migration-Move-more-initializations-to-migrate_init.patch similarity index 100% rename from SOURCES/migration-Move-more-initializations-to-migrate_init.patch rename to SOURCES/kvm-migration-Move-more-initializations-to-migrate_init.patch diff --git a/SOURCES/kvm-target-s390x-arch_dump-Add-arch-cleanup-function-for-PV.patch b/SOURCES/kvm-target-s390x-arch_dump-Add-arch-cleanup-function-for-PV.patch new file mode 100644 index 0000000..bb3b273 --- /dev/null +++ b/SOURCES/kvm-target-s390x-arch_dump-Add-arch-cleanup-function-for-PV.patch @@ -0,0 +1,64 @@ +From d12a91e0baafce7b1cbacff7cf9339eeb0011732 Mon Sep 17 00:00:00 2001 +From: Janosch Frank +Date: Thu, 9 Nov 2023 12:04:43 +0000 +Subject: [PATCH] target/s390x/arch_dump: Add arch cleanup function for PV + dumps +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +PV dumps block vcpu runs until dump end is reached. If there's an +error between PV dump init and PV dump end the vm will never be able +to run again. One example of such an error is insufficient disk space +for the dump file. + +Let's add a cleanup function that tries to do a dump end. The dump +completion data is discarded but there's no point in writing it to a +file anyway if there's a possibility that other PV dump data is +missing. + +Signed-off-by: Janosch Frank +Reviewed-by: Thomas Huth +Reviewed-by: Claudio Imbrenda +Reviewed-by: Marc-André Lureau +Message-ID: <20231109120443.185979-4-frankja@linux.ibm.com> +Signed-off-by: Thomas Huth +--- + target/s390x/arch_dump.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c +index bdb0bfa0e76e..7e8a1b4fc080 100644 +--- a/target/s390x/arch_dump.c ++++ b/target/s390x/arch_dump.c +@@ -433,6 +433,22 @@ static int arch_sections_write(DumpState *s, uint8_t *buff) + return 0; + } + ++static void arch_cleanup(DumpState *s) ++{ ++ g_autofree uint8_t *buff = NULL; ++ int rc; ++ ++ if (!pv_dump_initialized) { ++ return; ++ } ++ ++ buff = g_malloc(kvm_s390_pv_dmp_get_size_completion_data()); ++ rc = kvm_s390_dump_completion_data(buff); ++ if (!rc) { ++ pv_dump_initialized = false; ++ } ++} ++ + int cpu_get_dump_info(ArchDumpInfo *info, + const struct GuestPhysBlockList *guest_phys_blocks) + { +@@ -448,6 +464,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, + info->arch_sections_add_fn = *arch_sections_add; + info->arch_sections_write_hdr_fn = *arch_sections_write_hdr; + info->arch_sections_write_fn = *arch_sections_write; ++ info->arch_cleanup_fn = *arch_cleanup; + } + return 0; + } diff --git a/SOURCES/kvm-target-s390x-dump-Remove-unneeded-dump-info-function.patch b/SOURCES/kvm-target-s390x-dump-Remove-unneeded-dump-info-function.patch new file mode 100644 index 0000000..89864b4 --- /dev/null +++ b/SOURCES/kvm-target-s390x-dump-Remove-unneeded-dump-info-function.patch @@ -0,0 +1,36 @@ +From 816644b1219900875f47d7adf9bfb283f1b29aa0 Mon Sep 17 00:00:00 2001 +From: Janosch Frank +Date: Thu, 9 Nov 2023 12:04:41 +0000 +Subject: [PATCH] target/s390x/dump: Remove unneeded dump info function pointer + init +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +dump_state_prepare() now sets the function pointers to NULL so we only +need to touch them if we're going to use them. + +Signed-off-by: Janosch Frank +Reviewed-by: Marc-André Lureau +Reviewed-by: Thomas Huth +Message-ID: <20231109120443.185979-2-frankja@linux.ibm.com> +Signed-off-by: Thomas Huth +--- + target/s390x/arch_dump.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c +index 51a2116515ca..bdb0bfa0e76e 100644 +--- a/target/s390x/arch_dump.c ++++ b/target/s390x/arch_dump.c +@@ -448,10 +448,6 @@ int cpu_get_dump_info(ArchDumpInfo *info, + info->arch_sections_add_fn = *arch_sections_add; + info->arch_sections_write_hdr_fn = *arch_sections_write_hdr; + info->arch_sections_write_fn = *arch_sections_write; +- } else { +- info->arch_sections_add_fn = NULL; +- info->arch_sections_write_hdr_fn = NULL; +- info->arch_sections_write_fn = NULL; + } + return 0; + } diff --git a/SOURCES/vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch b/SOURCES/kvm-vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch similarity index 100% rename from SOURCES/vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch rename to SOURCES/kvm-vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch diff --git a/SOURCES/kvm-virtio-Drop-out-of-coroutine-context-in-virtio_load.patch b/SOURCES/kvm-virtio-Drop-out-of-coroutine-context-in-virtio_load.patch new file mode 100644 index 0000000..cbc4726 --- /dev/null +++ b/SOURCES/kvm-virtio-Drop-out-of-coroutine-context-in-virtio_load.patch @@ -0,0 +1,139 @@ +From 92e2e6a867334a990f8d29f07ca34e3162fdd6ec Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 5 Sep 2023 16:50:02 +0200 +Subject: [PATCH] virtio: Drop out of coroutine context in virtio_load() + +virtio_load() as a whole should run in coroutine context because it +reads from the migration stream and we don't want this to block. + +However, it calls virtio_set_features_nocheck() and devices don't +expect their .set_features callback to run in a coroutine and therefore +call functions that may not be called in coroutine context. To fix this, +drop out of coroutine context for calling virtio_set_features_nocheck(). + +Without this fix, the following crash was reported: + + #0 __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 + #1 0x00007efc738c05d3 in __pthread_kill_internal (signo=6, threadid=) at pthread_kill.c:78 + #2 0x00007efc73873d26 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 + #3 0x00007efc738477f3 in __GI_abort () at abort.c:79 + #4 0x00007efc7384771b in __assert_fail_base (fmt=0x7efc739dbcb8 "", assertion=assertion@entry=0x560aebfbf5cf "!qemu_in_coroutine()", + file=file@entry=0x560aebfcd2d4 "../block/graph-lock.c", line=line@entry=275, function=function@entry=0x560aebfcd34d "void bdrv_graph_rdlock_main_loop(void)") at assert.c:92 + #5 0x00007efc7386ccc6 in __assert_fail (assertion=0x560aebfbf5cf "!qemu_in_coroutine()", file=0x560aebfcd2d4 "../block/graph-lock.c", line=275, + function=0x560aebfcd34d "void bdrv_graph_rdlock_main_loop(void)") at assert.c:101 + #6 0x0000560aebcd8dd6 in bdrv_register_buf () + #7 0x0000560aeb97ed97 in ram_block_added.llvm () + #8 0x0000560aebb8303f in ram_block_add.llvm () + #9 0x0000560aebb834fa in qemu_ram_alloc_internal.llvm () + #10 0x0000560aebb2ac98 in vfio_region_mmap () + #11 0x0000560aebb3ea0f in vfio_bars_register () + #12 0x0000560aebb3c628 in vfio_realize () + #13 0x0000560aeb90f0c2 in pci_qdev_realize () + #14 0x0000560aebc40305 in device_set_realized () + #15 0x0000560aebc48e07 in property_set_bool.llvm () + #16 0x0000560aebc46582 in object_property_set () + #17 0x0000560aebc4cd58 in object_property_set_qobject () + #18 0x0000560aebc46ba7 in object_property_set_bool () + #19 0x0000560aeb98b3ca in qdev_device_add_from_qdict () + #20 0x0000560aebb1fbaf in virtio_net_set_features () + #21 0x0000560aebb46b51 in virtio_set_features_nocheck () + #22 0x0000560aebb47107 in virtio_load () + #23 0x0000560aeb9ae7ce in vmstate_load_state () + #24 0x0000560aeb9d2ee9 in qemu_loadvm_state_main () + #25 0x0000560aeb9d45e1 in qemu_loadvm_state () + #26 0x0000560aeb9bc32c in process_incoming_migration_co.llvm () + #27 0x0000560aebeace56 in coroutine_trampoline.llvm () + +Cc: qemu-stable@nongnu.org +Buglink: https://issues.redhat.com/browse/RHEL-832 +Signed-off-by: Kevin Wolf +Message-ID: <20230905145002.46391-3-kwolf@redhat.com> +Reviewed-by: Stefan Hajnoczi +Signed-off-by: Kevin Wolf +--- + hw/virtio/virtio.c | 45 ++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 40 insertions(+), 5 deletions(-) + +diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c +index 309038fd4632..969c25f4cfcb 100644 +--- a/hw/virtio/virtio.c ++++ b/hw/virtio/virtio.c +@@ -2825,8 +2825,9 @@ static int virtio_device_put(QEMUFile *f, void *opaque, size_t size, + } + + /* A wrapper for use as a VMState .get function */ +-static int virtio_device_get(QEMUFile *f, void *opaque, size_t size, +- const VMStateField *field) ++static int coroutine_mixed_fn ++virtio_device_get(QEMUFile *f, void *opaque, size_t size, ++ const VMStateField *field) + { + VirtIODevice *vdev = VIRTIO_DEVICE(opaque); + DeviceClass *dc = DEVICE_CLASS(VIRTIO_DEVICE_GET_CLASS(vdev)); +@@ -2853,6 +2854,39 @@ static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) + return bad ? -1 : 0; + } + ++typedef struct VirtioSetFeaturesNocheckData { ++ Coroutine *co; ++ VirtIODevice *vdev; ++ uint64_t val; ++ int ret; ++} VirtioSetFeaturesNocheckData; ++ ++static void virtio_set_features_nocheck_bh(void *opaque) ++{ ++ VirtioSetFeaturesNocheckData *data = opaque; ++ ++ data->ret = virtio_set_features_nocheck(data->vdev, data->val); ++ aio_co_wake(data->co); ++} ++ ++static int coroutine_mixed_fn ++virtio_set_features_nocheck_maybe_co(VirtIODevice *vdev, uint64_t val) ++{ ++ if (qemu_in_coroutine()) { ++ VirtioSetFeaturesNocheckData data = { ++ .co = qemu_coroutine_self(), ++ .vdev = vdev, ++ .val = val, ++ }; ++ aio_bh_schedule_oneshot(qemu_get_current_aio_context(), ++ virtio_set_features_nocheck_bh, &data); ++ qemu_coroutine_yield(); ++ return data.ret; ++ } else { ++ return virtio_set_features_nocheck(vdev, val); ++ } ++} ++ + int virtio_set_features(VirtIODevice *vdev, uint64_t val) + { + int ret; +@@ -2906,7 +2940,8 @@ size_t virtio_get_config_size(const VirtIOConfigSizeParams *params, + return config_size; + } + +-int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) ++int coroutine_mixed_fn ++virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) + { + int i, ret; + int32_t config_len; +@@ -3023,14 +3058,14 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) + * host_features. + */ + uint64_t features64 = vdev->guest_features; +- if (virtio_set_features_nocheck(vdev, features64) < 0) { ++ if (virtio_set_features_nocheck_maybe_co(vdev, features64) < 0) { + error_report("Features 0x%" PRIx64 " unsupported. " + "Allowed features: 0x%" PRIx64, + features64, vdev->host_features); + return -1; + } + } else { +- if (virtio_set_features_nocheck(vdev, features) < 0) { ++ if (virtio_set_features_nocheck_maybe_co(vdev, features) < 0) { + error_report("Features 0x%x unsupported. " + "Allowed features: 0x%" PRIx64, + features, vdev->host_features); diff --git a/SPECS/qemu-kvm.spec b/SPECS/qemu-kvm.spec index 0d6d98f..c8c10de 100644 --- a/SPECS/qemu-kvm.spec +++ b/SPECS/qemu-kvm.spec @@ -149,7 +149,7 @@ Obsoletes: %{name}-block-ssh <= %{epoch}:%{version} \ Summary: QEMU is a machine emulator and virtualizer Name: qemu-kvm Version: 8.0.0 -Release: 16%{?rcrel}%{?dist}%{?cc_suffix}.1.alma.1 +Release: 16%{?rcrel}%{?dist}%{?cc_suffix}.3.alma.1 # 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) @@ -549,15 +549,23 @@ Patch193: kvm-vdpa-remove-net-cvq-migration-blocker.patch # Patches were taken from upstream and backported to apply cleanly: # https://github.com/qemu/qemu/commit/10be627d2b5ec2d6b3dce045144aa739eef678b4.patch -Patch1001: io-remove-io-watch-if-TLS-channel-is-closed.patch +Patch1001: kvm-io-remove-io-watch-if-TLS-channel-is-closed.patch # https://github.com/qemu/qemu/commit/38c482b4778595ee337761f73ec0730d6c47b404.patch -Patch1002: migration-Add-migration-prefix-to-functions-in-target.patch +Patch1002: kvm-migration-Add-migration-prefix-to-functions-in-target.patch # https://github.com/qemu/qemu/commit/f543aa222da183ac37424d1ea3a65e5fb6202732.patch -Patch1003: migration-Move-more-initializations-to-migrate_init.patch +Patch1003: kvm-migration-Move-more-initializations-to-migrate_init.patch # https://github.com/qemu/qemu/commit/08fc4cb51774f763dcc6fd74637aa9e00eb6a0ba.patch -Patch1004: migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch +Patch1004: kvm-migration-Add-save_prepare-handler-to-struct-SaveVMHandlers.patch # https://github.com/qemu/qemu/commit/bf7ef7a2da3e61dc104f26c679c9465e3fbe7dde.patch -Patch1005: vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch +Patch1005: kvm-vfio-migration-Block-VFIO-migration-with-postcopy-migration.patch +# https://github.com/qemu/qemu/commit/816644b1219900875f47d7adf9bfb283f1b29aa0 +Patch1006: kvm-target-s390x-dump-Remove-unneeded-dump-info-function.patch +# https://github.com/qemu/qemu/commit/e72629e5149aba6f44122ea6d2a803ef136a0c6b +Patch1007: kvm-dump-Add-arch-cleanup-function.patch +# https://github.com/qemu/qemu/commit/d12a91e0baafce7b1cbacff7cf9339eeb0011732 +Patch1008: kvm-target-s390x-arch_dump-Add-arch-cleanup-function-for-PV.patch +# https://github.com/qemu/qemu/commit/92e2e6a867334a990f8d29f07ca34e3162fdd6ec +Patch1009: kvm-virtio-Drop-out-of-coroutine-context-in-virtio_load.patch %if %{have_clang} BuildRequires: clang @@ -1619,6 +1627,13 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Thu Jan 25 2024 Eduard Abdullin - 8.0.0-16.3.alma.1 +- dump: Add arch cleanup function +- target/s390x/arch_dump: Add arch cleanup function for PV + dumps +- target/s390x/dump: Remove unneeded dump info function pointer + init + * Tue Nov 07 2023 Eduard Abdullin - 8.0.0-16.1.alma.1 - Apply io-remove-io-watch-if-TLS-channel-is-closed.patch - Apply migration-Add-migration-prefix-to-functions-in-target.patch