- 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
This commit is contained in:
eabdullin 2024-01-25 12:10:58 +03:00
parent 15d00ca921
commit a1f2fff182
9 changed files with 169 additions and 6 deletions

View File

@ -0,0 +1,49 @@
From e72629e5149aba6f44122ea6d2a803ef136a0c6b Mon Sep 17 00:00:00 2001
From: Janosch Frank <frankja@linux.ibm.com>
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 <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20231109120443.185979-3-frankja@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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 */

View File

@ -0,0 +1,64 @@
From d12a91e0baafce7b1cbacff7cf9339eeb0011732 Mon Sep 17 00:00:00 2001
From: Janosch Frank <frankja@linux.ibm.com>
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 <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20231109120443.185979-4-frankja@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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;
}

View File

@ -0,0 +1,36 @@
From 816644b1219900875f47d7adf9bfb283f1b29aa0 Mon Sep 17 00:00:00 2001
From: Janosch Frank <frankja@linux.ibm.com>
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 <frankja@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231109120443.185979-2-frankja@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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;
}

View File

@ -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,22 @@ 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
%if %{have_clang}
BuildRequires: clang
@ -1619,6 +1626,13 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
%endif
%changelog
* Thu Jan 25 2024 Eduard Abdullin <eabdullin@almalinux.org> - 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 <eabdullin@almalinux.org> - 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