2014-02-09 07:43:10 +04:00
|
|
|
/*
|
|
|
|
* QTest testcase for VirtIO RNG
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 SUSE LINUX Products GmbH
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2016-02-08 21:08:51 +03:00
|
|
|
#include "qemu/osdep.h"
|
2014-02-09 07:43:10 +04:00
|
|
|
#include "libqtest.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2018-07-26 12:24:50 +03:00
|
|
|
#include "libqos/qgraph.h"
|
|
|
|
#include "libqos/virtio-rng.h"
|
2014-09-26 13:28:09 +04:00
|
|
|
|
|
|
|
#define PCI_SLOT_HP 0x06
|
2014-02-09 07:43:10 +04:00
|
|
|
|
2018-07-26 12:24:50 +03:00
|
|
|
static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
|
2014-09-26 13:28:09 +04:00
|
|
|
{
|
2019-04-09 15:25:57 +03:00
|
|
|
QVirtioPCIDevice *dev = obj;
|
|
|
|
QTestState *qts = dev->pdev->bus->qts;
|
|
|
|
|
2016-10-17 13:30:24 +03:00
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
|
2018-08-06 09:53:35 +03:00
|
|
|
qtest_qmp_device_add("virtio-rng-pci", "rng1",
|
|
|
|
"{'addr': %s}", stringify(PCI_SLOT_HP));
|
2016-10-17 13:30:24 +03:00
|
|
|
|
|
|
|
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
|
2019-04-09 15:25:57 +03:00
|
|
|
qpci_unplug_acpi_device_test(qts, "rng1", PCI_SLOT_HP);
|
2016-10-17 13:30:24 +03:00
|
|
|
}
|
2014-09-26 13:28:09 +04:00
|
|
|
}
|
|
|
|
|
2018-07-26 12:24:50 +03:00
|
|
|
static void register_virtio_rng_test(void)
|
2014-02-09 07:43:10 +04:00
|
|
|
{
|
2018-07-26 12:24:50 +03:00
|
|
|
qos_add_test("hotplug", "virtio-rng-pci", rng_hotplug, NULL);
|
2014-02-09 07:43:10 +04:00
|
|
|
}
|
2018-07-26 12:24:50 +03:00
|
|
|
|
|
|
|
libqos_init(register_virtio_rng_test);
|