blob: 092ba130684dfdc378265f17ba1d779aec75fa35 [file] [log] [blame]
Andreas Färberb6f46f02014-02-09 04:43:10 +01001/*
2 * QTest testcase for VirtIO RNG
3 *
4 * Copyright (c) 2014 SUSE LINUX Products GmbH
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
Andreas Färberb6f46f02014-02-09 04:43:10 +010010#include "qemu/osdep.h"
Peter Maydell681c28a2016-02-08 18:08:51 +000011#include "libqtest.h"
Markus Armbruster0b8fa322019-05-23 16:35:07 +020012#include "qemu/module.h"
Emanuele Giuseppe Espositoa25f56a2018-07-26 11:24:50 +020013#include "libqos/qgraph.h"
14#include "libqos/virtio-rng.h"
Igor Mammedovd1f3fc22014-09-26 09:28:09 +000015
16#define PCI_SLOT_HP 0x06
Andreas Färberb6f46f02014-02-09 04:43:10 +010017
Emanuele Giuseppe Espositoa25f56a2018-07-26 11:24:50 +020018static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
Igor Mammedovd1f3fc22014-09-26 09:28:09 +000019{
Thomas Huth6ebb8d22019-04-09 14:25:57 +020020 QVirtioPCIDevice *dev = obj;
21 QTestState *qts = dev->pdev->bus->qts;
22
Laurent Vivier30ca4402016-10-17 12:30:24 +020023 const char *arch = qtest_get_arch();
24
Thomas Huthe5758de2019-07-22 17:10:55 +020025 qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1",
Markus Armbruster82cab702018-08-06 08:53:35 +020026 "{'addr': %s}", stringify(PCI_SLOT_HP));
Laurent Vivier30ca4402016-10-17 12:30:24 +020027
28 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
Thomas Huth6ebb8d22019-04-09 14:25:57 +020029 qpci_unplug_acpi_device_test(qts, "rng1", PCI_SLOT_HP);
Laurent Vivier30ca4402016-10-17 12:30:24 +020030 }
Igor Mammedovd1f3fc22014-09-26 09:28:09 +000031}
32
Emanuele Giuseppe Espositoa25f56a2018-07-26 11:24:50 +020033static void register_virtio_rng_test(void)
Andreas Färberb6f46f02014-02-09 04:43:10 +010034{
Emanuele Giuseppe Espositoa25f56a2018-07-26 11:24:50 +020035 qos_add_test("hotplug", "virtio-rng-pci", rng_hotplug, NULL);
Andreas Färberb6f46f02014-02-09 04:43:10 +010036}
Emanuele Giuseppe Espositoa25f56a2018-07-26 11:24:50 +020037
38libqos_init(register_virtio_rng_test);