From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Weißschuh" <thomas@t-8ch.de>,
"Thomas Huth" <thuth@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL v3 38/41] tests/qtest/pvpanic: add tests for pvshutdown event
Date: Wed, 5 Jun 2024 19:37:00 -0400 [thread overview]
Message-ID: <a9aed05f6b7ded621c851cdab47b39fd34d5f704.1717630437.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1717630437.git.mst@redhat.com>
From: Thomas Weißschuh <thomas@t-8ch.de>
Validate that a shutdown via the pvpanic device emits the correct
QMP events.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20240527-pvpanic-shutdown-v8-7-5a28ec02558b@t-8ch.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/qtest/pvpanic-pci-test.c | 39 ++++++++++++++++++++++++++++++++++
tests/qtest/pvpanic-test.c | 29 +++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c
index b372caf41d..dc021c2fdf 100644
--- a/tests/qtest/pvpanic-pci-test.c
+++ b/tests/qtest/pvpanic-pci-test.c
@@ -85,11 +85,50 @@ static void test_panic(void)
qtest_quit(qts);
}
+static void test_pvshutdown(void)
+{
+ uint8_t val;
+ QDict *response, *data;
+ QTestState *qts;
+ QPCIBus *pcibus;
+ QPCIDevice *dev;
+ QPCIBar bar;
+
+ qts = qtest_init("-device pvpanic-pci,addr=04.0");
+ pcibus = qpci_new_pc(qts, NULL);
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
+ qpci_device_enable(dev);
+ bar = qpci_iomap(dev, 0, NULL);
+
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
+ g_assert_cmpuint(val, ==, PVPANIC_EVENTS);
+
+ val = PVPANIC_SHUTDOWN;
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
+
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN");
+ qobject_unref(response);
+
+ response = qtest_qmp_eventwait_ref(qts, "SHUTDOWN");
+ g_assert(qdict_haskey(response, "data"));
+ data = qdict_get_qdict(response, "data");
+ g_assert(qdict_haskey(data, "guest"));
+ g_assert(qdict_get_bool(data, "guest"));
+ g_assert(qdict_haskey(data, "reason"));
+ g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown");
+ qobject_unref(response);
+
+ g_free(dev);
+ qpci_free_pc(pcibus);
+ qtest_quit(qts);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
qtest_add_func("/pvpanic-pci/panic", test_panic);
qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause);
+ qtest_add_func("/pvpanic-pci/pvshutdown", test_pvshutdown);
return g_test_run();
}
diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c
index ccc603472f..d49d2ba931 100644
--- a/tests/qtest/pvpanic-test.c
+++ b/tests/qtest/pvpanic-test.c
@@ -58,11 +58,40 @@ static void test_panic(void)
qtest_quit(qts);
}
+static void test_pvshutdown(void)
+{
+ uint8_t val;
+ QDict *response, *data;
+ QTestState *qts;
+
+ qts = qtest_init("-device pvpanic");
+
+ val = qtest_inb(qts, 0x505);
+ g_assert_cmpuint(val, ==, PVPANIC_EVENTS);
+
+ qtest_outb(qts, 0x505, PVPANIC_SHUTDOWN);
+
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN");
+ qobject_unref(response);
+
+ response = qtest_qmp_eventwait_ref(qts, "SHUTDOWN");
+ g_assert(qdict_haskey(response, "data"));
+ data = qdict_get_qdict(response, "data");
+ g_assert(qdict_haskey(data, "guest"));
+ g_assert(qdict_get_bool(data, "guest"));
+ g_assert(qdict_haskey(data, "reason"));
+ g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown");
+ qobject_unref(response);
+
+ qtest_quit(qts);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
qtest_add_func("/pvpanic/panic", test_panic);
qtest_add_func("/pvpanic/panic-nopause", test_panic_nopause);
+ qtest_add_func("/pvpanic/pvshutdown", test_pvshutdown);
return g_test_run();
}
--
MST
next prev parent reply other threads:[~2024-06-05 23:39 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 23:34 [PULL v3 00/41] virtio: features,fixes Michael S. Tsirkin
2024-06-05 23:34 ` [PULL v3 01/41] vhost: dirty log should be per backend type Michael S. Tsirkin
2024-06-05 23:34 ` [PULL v3 02/41] vhost: Perform memory section dirty scans once per iteration Michael S. Tsirkin
2024-06-05 23:34 ` [PULL v3 03/41] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Michael S. Tsirkin
2024-06-05 23:34 ` [PULL v3 04/41] virtio/virtio-pci: Handle extra notification data Michael S. Tsirkin
2024-06-05 23:34 ` [PULL v3 05/41] virtio: Prevent creation of device using notification-data with ioeventfd Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 06/41] virtio-mmio: Handle extra notification data Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 07/41] virtio-ccw: " Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 08/41] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 09/41] Fix vhost user assertion when sending more than one fd Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 10/41] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 11/41] hw/virtio: Fix obtain the buffer id from the last descriptor Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 12/41] virtio-pci: only reset pm state during resetting Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 13/41] vhost-user-gpu: fix import of DMABUF Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 14/41] Revert "vhost-user: fix lost reconnect" Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 15/41] vhost-user: fix lost reconnect again Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 16/41] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 17/41] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 18/41] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 19/41] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 20/41] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Michael S. Tsirkin
2024-06-05 23:35 ` [PULL v3 21/41] hw/mem/cxl_type3: Add support to create DC regions to " Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 22/41] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 23/41] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 24/41] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 25/41] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 26/41] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 27/41] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 28/41] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 29/41] hw/mem/cxl_type3: Allow to release extent superset in QMP interface Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 30/41] hw/acpi/GI: Fix trivial parameter alignment issue Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 31/41] hw/acpi: Insert an acpi-generic-node base under acpi-generic-initiator Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 32/41] scripts/update-linux-headers: Copy setup_data.h to correct directory Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 33/41] linux-headers: update to 6.10-rc1 Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 34/41] hw/misc/pvpanic: centralize definition of supported events Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 35/41] tests/qtest/pvpanic: use centralized " Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 36/41] hw/misc/pvpanic: add support for normal shutdowns Michael S. Tsirkin
2024-06-05 23:36 ` [PULL v3 37/41] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Michael S. Tsirkin
2024-06-05 23:37 ` Michael S. Tsirkin [this message]
2024-06-05 23:37 ` [PULL v3 39/41] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" Michael S. Tsirkin
2024-06-05 23:37 ` [PULL v3 40/41] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() Michael S. Tsirkin
2024-06-05 23:37 ` [PULL v3 41/41] hw/cxl: Fix read from bogus memory Michael S. Tsirkin
2024-06-05 23:56 ` [PULL v3 00/41] virtio: features,fixes Richard Henderson
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=a9aed05f6b7ded621c851cdab47b39fd34d5f704.1717630437.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thomas@t-8ch.de \
--cc=thuth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).