From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Subject: [GIT PULL 4/8] dump: make win_dump_available() check vmcoreinfo for a Windows dump header
Date: Tue, 30 Jun 2026 19:13:19 +0400 [thread overview]
Message-ID: <20260630-dump-v1-4-7df3087dffc9@redhat.com> (raw)
In-Reply-To: <20260630-dump-v1-0-7df3087dffc9@redhat.com>
From: "Denis V. Lunev" <den@openvz.org>
QMP query-dump-guest-memory-capability reports win-dmp as available for
any x86 VM, and dump-guest-memory accepts the win-dmp format
unconditionally. Both are wrong: win-dmp only works when the guest has
published a Windows dump header through vmcoreinfo.
The guest registers that note with the vmcoreinfo device (its physical
address and size), so win_dump_available() can read it back directly and
validate the note size and the Windows dump header signature. This needs
no other guest state, so it does not stop the vCPUs.
The capability query reads the note on the main thread with the BQL held
and has no migration guard of its own, so it is skipped while a migration
destination is still receiving guest RAM: there the read would deadlock
against the postcopy load (which needs the BQL) or, in precopy, see
incomplete pages.
Based on the original work of Nikolai Barybin.
Signed-off-by: Denis V. Lunev <den@openvz.org>
[ MA - changed physical_memory_read() call ]
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260619101834.228432-5-den@openvz.org>
---
dump/win_dump-x86.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-)
diff --git a/dump/win_dump-x86.c b/dump/win_dump-x86.c
index 8848c8bfca3..0dd0c503c56 100644
--- a/dump/win_dump-x86.c
+++ b/dump/win_dump-x86.c
@@ -18,11 +18,10 @@
#include "qemu/win_dump_defs.h"
#include "win_dump.h"
#include "cpu.h"
-
-bool win_dump_available(Error **errp)
-{
- return true;
-}
+#include "qemu/bswap.h"
+#include "hw/misc/vmcoreinfo.h"
+#include "migration/misc.h"
+#include "standard-headers/linux/qemu_fw_cfg.h"
static size_t win_dump_ptr_size(bool x64)
{
@@ -404,6 +403,46 @@ static void restore_context(WinDumpHeader *h, bool x64,
}
}
+bool win_dump_available(Error **errp)
+{
+ VMCoreInfoState *vmci = vmcoreinfo_find();
+ g_autofree uint8_t *note = NULL;
+ Error *local_err = NULL;
+ WinDumpHeader *h;
+ uint32_t size;
+ bool x64 = true;
+
+ if (migration_guest_ram_loading()) {
+ error_setg(errp, "win-dump: not available during migration");
+ return false;
+ }
+
+ if (!vmci || !vmci->has_vmcoreinfo ||
+ le16_to_cpu(vmci->vmcoreinfo.guest_format) !=
+ FW_CFG_VMCOREINFO_FORMAT_ELF) {
+ error_setg(errp, "win-dump: no vmcoreinfo note from the guest");
+ return false;
+ }
+
+ size = le32_to_cpu(vmci->vmcoreinfo.size);
+ if (size != VMCOREINFO_WIN_DUMP_NOTE_SIZE32 &&
+ size != VMCOREINFO_WIN_DUMP_NOTE_SIZE64) {
+ error_setg(errp, "win-dump: invalid vmcoreinfo note size");
+ return false;
+ }
+
+ note = g_malloc(size);
+ physical_memory_read(le64_to_cpu(vmci->vmcoreinfo.paddr), note, size);
+
+ h = (void *)(note + VMCOREINFO_ELF_NOTE_HDR_SIZE);
+ if (!check_header(h, &x64, &local_err)) {
+ error_propagate(errp, local_err);
+ return false;
+ }
+
+ return true;
+}
+
void create_win_dump(DumpState *s, Error **errp)
{
WinDumpHeader *h = (void *)(s->guest_note + VMCOREINFO_ELF_NOTE_HDR_SIZE);
--
2.54.0
next prev parent reply other threads:[~2026-06-30 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 15:13 [GIT PULL 0/8] Dump patches for 2026-06-30 Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 1/8] migration: add migration_guest_ram_loading() helper Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 2/8] dump: refuse dump-guest-memory while guest RAM is being migrated Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 3/8] system/cpus: refuse memsave/pmemsave " Marc-André Lureau
2026-06-30 15:13 ` Marc-André Lureau [this message]
2026-06-30 15:13 ` [GIT PULL 5/8] tests/qtest: add dump-guest-memory test Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 6/8] tests/qtest/dump: reject win-dmp without vmcoreinfo Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 7/8] tests/qtest/dump: cover win-dmp availability via vmcoreinfo Marc-André Lureau
2026-06-30 15:13 ` [GIT PULL 8/8] dump: fix misleading VMCOREINFO phys_base parse error Marc-André Lureau
2026-07-02 18:49 ` [GIT PULL 0/8] Dump patches for 2026-06-30 Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630-dump-v1-4-7df3087dffc9@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.