tests/qtest/dump: reject win-dmp without vmcoreinfo

Requesting the Windows crashdump format (win-dmp) on a guest that does not
expose a Windows dump header through vmcoreinfo must be rejected, not
silently turned into a bogus dump. Add a test that asks for win-dmp on a
plain VM and checks the request fails with "invalid vmcoreinfo note size"
and that the VM stays usable afterwards (a subsequent ELF dump succeeds).

The test is x86_64 only, where win_dump_available() performs this check.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260619101834.228432-7-den@openvz.org>
This commit is contained in:
Denis V. Lunev
2026-06-19 12:18:33 +02:00
committed by Marc-André Lureau
parent 952303c355
commit 62ef6152ab

View File

@@ -174,8 +174,51 @@ static void test_dump_invalid_protocol(void)
qtest_quit(qts);
}
/*
* Requesting win-dmp without a Windows dump header in vmcoreinfo must be
* rejected with a clear error -- and must leave the VM usable, rather than
* produce a bogus dump.
*/
static void test_dump_win_dmp_unavailable(void)
{
QTestState *qts = dump_test_start();
g_autofree char *tmp = NULL;
g_autofree char *proto = NULL;
g_autofree char *path = NULL;
GError *err = NULL;
QDict *resp, *error;
const char *desc;
int fd;
fd = g_file_open_tmp("dump-test-XXXXXX", &tmp, &err);
g_assert_no_error(err);
close(fd);
proto = g_strdup_printf("file:%s", tmp);
resp = qtest_qmp(qts,
"{ 'execute': 'dump-guest-memory',"
" 'arguments': { 'paging': false, 'protocol': %s,"
" 'format': 'win-dmp' } }", proto);
error = qdict_get_qdict(resp, "error");
g_assert_nonnull(error);
desc = qdict_get_try_str(error, "desc");
g_assert_nonnull(desc);
g_assert_nonnull(strstr(desc, "vmcoreinfo"));
qobject_unref(resp);
unlink(tmp);
/* the failed request must not wedge the VM: a plain dump still works */
path = do_dump(qts, NULL);
assert_valid_elf_core(path);
unlink(path);
qtest_quit(qts);
}
int main(int argc, char **argv)
{
const char *arch = qtest_get_arch();
g_test_init(&argc, &argv, NULL);
qtest_add_func("/dump/query-capability", test_query_capability);
@@ -184,5 +227,11 @@ int main(int argc, char **argv)
qtest_add_func("/dump/kdump-raw-zlib", test_dump_kdump_raw_zlib);
qtest_add_func("/dump/invalid-protocol", test_dump_invalid_protocol);
/* win-dmp is an x86_64-only format */
if (g_str_equal(arch, "x86_64")) {
qtest_add_func("/dump/win-dmp-unavailable",
test_dump_win_dmp_unavailable);
}
return g_test_run();
}