From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWl9M-0004Xy-Hr for qemu-devel@nongnu.org; Wed, 24 Sep 2014 07:54:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWl9G-0007XB-Cb for qemu-devel@nongnu.org; Wed, 24 Sep 2014 07:54:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWl9G-0007W4-4S for qemu-devel@nongnu.org; Wed, 24 Sep 2014 07:54:18 -0400 From: Igor Mammedov Date: Wed, 24 Sep 2014 11:47:52 +0000 Message-Id: <1411559299-19042-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1411559299-19042-1-git-send-email-imammedo@redhat.com> References: <1411559299-19042-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 03/30] test: virtio-rng: check if hot-plug/unplug works List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: dmitry@daynix.com, borntraeger@de.ibm.com, mst@redhat.com, agraf@suse.de, cornelia.huck@de.ibm.com, kraxel@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, rth@twiddle.net Signed-off-by: Igor Mammedov --- tests/virtio-rng-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c index 402c206..7f62f84 100644 --- a/tests/virtio-rng-test.c +++ b/tests/virtio-rng-test.c @@ -12,17 +12,55 @@ #include "libqtest.h" #include "qemu/osdep.h" +#define PCI_SLOT_HP 0x06 +#define ACPI_PCIHP_ADDR 0xae00 +#define PCI_EJ_BASE 0x0008 + /* Tests only initialization so far. TODO: Replace with functional tests */ static void pci_nop(void) { } +static void hotplug(void) +{ + QDict *response; + + response = qmp("{\"execute\": \"device_add\"," + " \"arguments\": {" + " \"driver\": \"virtio-rng-pci\"," + " \"addr\": \"" stringify(PCI_SLOT_HP) "\"," + " \"id\": \"rng1\"" + "}}"); + + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + response = qmp("{\"execute\": \"device_del\"," + " \"arguments\": {" + " \"id\": \"rng1\"" + "}}"); + + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << PCI_SLOT_HP); + + response = qmp(""); + g_assert(response); + g_assert(qdict_haskey(response, "event")); + g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); + QDECREF(response); +} + int main(int argc, char **argv) { int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/virtio/rng/pci/nop", pci_nop); + qtest_add_func("/virtio/rng/pci/hotplug", hotplug); qtest_start("-device virtio-rng-pci"); ret = g_test_run(); -- 1.8.3.1