diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-11-29 13:55:07 +0000 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2024-12-03 12:26:24 +0100 |
commit | d65c890a5806e1f3d608a4218295d4729d697cd8 (patch) | |
tree | 12d0bd22c85ff901286a07bc9b0340ed17378433 | |
parent | 8460459529215e29c7f84efec69a329194ad4f87 (diff) | |
download | qemu-d65c890a5806e1f3d608a4218295d4729d697cd8.zip qemu-d65c890a5806e1f3d608a4218295d4729d697cd8.tar.gz qemu-d65c890a5806e1f3d608a4218295d4729d697cd8.tar.bz2 |
tests/qtest: add test for querying balloon guest stats
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>
-rw-r--r-- | tests/qtest/virtio-balloon-test.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/qtest/virtio-balloon-test.c b/tests/qtest/virtio-balloon-test.c index 6bea33b..ecdd363 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(); } |