]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qtest/virtio-rng-test.c
tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable
[mirror_qemu.git] / tests / qtest / virtio-rng-test.c
CommitLineData
b6f46f02
AF
1/*
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
681c28a3 10#include "qemu/osdep.h"
907b5105 11#include "libqtest.h"
0b8fa32f 12#include "qemu/module.h"
a25f56ae
EGE
13#include "libqos/qgraph.h"
14#include "libqos/virtio-rng.h"
d1f3fc24
IM
15
16#define PCI_SLOT_HP 0x06
b6f46f02 17
a25f56ae 18static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
d1f3fc24 19{
6ebb8d2a
TH
20 QVirtioPCIDevice *dev = obj;
21 QTestState *qts = dev->pdev->bus->qts;
22
02ee7a8a
EA
23 if (dev->pdev->bus->not_hotpluggable) {
24 g_test_skip("pci bus does not support hotplug");
25 return;
26 }
27
30ca440e
LV
28 const char *arch = qtest_get_arch();
29
e5758de4 30 qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1",
82cab70b 31 "{'addr': %s}", stringify(PCI_SLOT_HP));
30ca440e
LV
32
33 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
6ebb8d2a 34 qpci_unplug_acpi_device_test(qts, "rng1", PCI_SLOT_HP);
30ca440e 35 }
d1f3fc24
IM
36}
37
a25f56ae 38static void register_virtio_rng_test(void)
b6f46f02 39{
a25f56ae 40 qos_add_test("hotplug", "virtio-rng-pci", rng_hotplug, NULL);
b6f46f02 41}
a25f56ae
EGE
42
43libqos_init(register_virtio_rng_test);