[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/13] tests/qtest: add test for querying balloon guest stats
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 12/13] tests/qtest: add test for querying balloon guest stats |
Date: |
Tue, 3 Dec 2024 12:31:39 +0100 |
From: Daniel P. Berrangé <berrange@redhat.com>
This test would have identified the crash caused by the addition of new
balloon stats fields.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20241129135507.699030-4-berrange@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
tests/qtest/virtio-balloon-test.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tests/qtest/virtio-balloon-test.c
b/tests/qtest/virtio-balloon-test.c
index 6bea33b5901..ecdd363b06c 100644
--- a/tests/qtest/virtio-balloon-test.c
+++ b/tests/qtest/virtio-balloon-test.c
@@ -8,6 +8,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
+#include "standard-headers/linux/virtio_balloon.h"
/*
* https://gitlab.com/qemu-project/qemu/-/issues/2576
@@ -26,11 +27,30 @@ static void oss_fuzz_71649(void)
qtest_quit(s);
}
+static void query_stats(void)
+{
+ QTestState *s = qtest_init("-device virtio-balloon,id=balloon"
+ " -nodefaults");
+ QDict *ret = qtest_qmp_assert_success_ref(
+ s,
+ "{ 'execute': 'qom-get', 'arguments': " \
+ "{ 'path': '/machine/peripheral/balloon', " \
+ " 'property': 'guest-stats' } }");
+ QDict *stats = qdict_get_qdict(ret, "stats");
+
+ /* We expect 1 entry in the dict for each known kernel stat */
+ assert(qdict_size(stats) == VIRTIO_BALLOON_S_NR);
+
+ qobject_unref(ret);
+ qtest_quit(s);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
qtest_add_func("virtio-balloon/oss_fuzz_71649", oss_fuzz_71649);
+ qtest_add_func("virtio-balloon/query-stats", query_stats);
return g_test_run();
}
--
2.45.2
- [PULL 03/13] ui/cocoa: Temporarily ignore annoying deprecated declaration warnings, (continued)
- [PULL 03/13] ui/cocoa: Temporarily ignore annoying deprecated declaration warnings, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 04/13] MAINTAINERS: add myself as the maintainer for LoongArch VirtMachine, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 05/13] meson: Add missing SDL dependency to system/main.c, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 06/13] MAINTAINERS: update email addr for Brian Cain, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 07/13] hw/core/machine: diagnose wrapping of maxmem, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 08/13] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt(), Philippe Mathieu-Daudé, 2024/12/03
- [PULL 09/13] hw/display/vga: Do not reset 'big_endian_fb' in vga_common_reset(), Philippe Mathieu-Daudé, 2024/12/03
- [PULL 10/13] hw/virtio: fix crash in processing balloon stats, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 11/13] tests/qtest: drop 'fuzz-' prefix from virtio-balloon test, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 12/13] tests/qtest: add test for querying balloon guest stats,
Philippe Mathieu-Daudé <=
- [PULL 13/13] system: Select HVF by default when no other accelerator is available, Philippe Mathieu-Daudé, 2024/12/03
- Re: [PULL 00/13] Misc fixes for 2024-12-03, Peter Maydell, 2024/12/03