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>
Denis V. Lunev committed
Jun 19, 2026 at 12:18 UTC
62ef6152ab4a5b29a24869993cb417b090160a1f
1 file changed
+49
tests/qtest/dump-test.c
+49
@@ -174,8 +174,51 @@ static void test_dump_invalid_protocol(void)
174
qtest_quit(qts);
175
}
176
177
+/*
178
+ * Requesting win-dmp without a Windows dump header in vmcoreinfo must be
179
+ * rejected with a clear error -- and must leave the VM usable, rather than
180
+ * produce a bogus dump.
181
+ */
182
+static void test_dump_win_dmp_unavailable(void)
183
+{
184
+ QTestState *qts = dump_test_start();
185
+ g_autofree char *tmp = NULL;
186
+ g_autofree char *proto = NULL;
187
+ g_autofree char *path = NULL;
188
+ GError *err = NULL;
189
+ QDict *resp, *error;
190
+ const char *desc;
191
+ int fd;
192
+
193
+ fd = g_file_open_tmp("dump-test-XXXXXX", &tmp, &err);
194
+ g_assert_no_error(err);
195
+ close(fd);
196
+ proto = g_strdup_printf("file:%s", tmp);
197
+
198
+ resp = qtest_qmp(qts,
199
+ "{ 'execute': 'dump-guest-memory',"
200
+ " 'arguments': { 'paging': false, 'protocol': %s,"
201
+ " 'format': 'win-dmp' } }", proto);
202
+ error = qdict_get_qdict(resp, "error");
203
+ g_assert_nonnull(error);
204
+ desc = qdict_get_try_str(error, "desc");
205
+ g_assert_nonnull(desc);
206
+ g_assert_nonnull(strstr(desc, "vmcoreinfo"));
207
+ qobject_unref(resp);
208
+ unlink(tmp);
209
+
210
+ /* the failed request must not wedge the VM: a plain dump still works */
211
+ path = do_dump(qts, NULL);
212
+ assert_valid_elf_core(path);
213
+ unlink(path);
214
+
215
+ qtest_quit(qts);
216
+}
217
+
218
int main(int argc, char **argv)
219
{
220
+ const char *arch = qtest_get_arch();
221
+
222
g_test_init(&argc, &argv, NULL);
223
224
qtest_add_func("/dump/query-capability", test_query_capability);
@@ -184,5 +227,11 @@ int main(int argc, char **argv)
227
qtest_add_func("/dump/kdump-raw-zlib", test_dump_kdump_raw_zlib);
228
qtest_add_func("/dump/invalid-protocol", test_dump_invalid_protocol);
229
230
+ /* win-dmp is an x86_64-only format */
231
+ if (g_str_equal(arch, "x86_64")) {
232
+ qtest_add_func("/dump/win-dmp-unavailable",
233
+ test_dump_win_dmp_unavailable);
234
+ }
235
+
236
return g_test_run();
237
}