]> git.proxmox.com Git - mirror_qemu.git/blame - tests/eepro100-test.c
vmstate: check subsection_found is enough
[mirror_qemu.git] / tests / eepro100-test.c
CommitLineData
92838a19
AF
1/*
2 * QTest testcase for eepro100 NIC
3 *
4 * Copyright (c) 2013-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"
92838a19 11#include "libqtest.h"
0b477302
EGE
12#include "libqos/qgraph.h"
13#include "libqos/pci.h"
92838a19 14
0b477302 15typedef struct QEEPRO100 QEEPRO100;
92838a19 16
0b477302
EGE
17struct QEEPRO100 {
18 QOSGraphObject obj;
19 QPCIDevice dev;
20};
92838a19
AF
21
22static const char *models[] = {
23 "i82550",
24 "i82551",
25 "i82557a",
26 "i82557b",
27 "i82557c",
28 "i82558a",
29 "i82558b",
30 "i82559a",
31 "i82559b",
32 "i82559c",
33 "i82559er",
34 "i82562",
35 "i82801",
36};
37
0b477302 38static void *eepro100_get_driver(void *obj, const char *interface)
92838a19 39{
0b477302 40 QEEPRO100 *eepro100 = obj;
92838a19 41
0b477302
EGE
42 if (!g_strcmp0(interface, "pci-device")) {
43 return &eepro100->dev;
44 }
92838a19 45
0b477302
EGE
46 fprintf(stderr, "%s not present in eepro100\n", interface);
47 g_assert_not_reached();
48}
92838a19 49
0b477302
EGE
50static void *eepro100_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
51{
52 QEEPRO100 *eepro100 = g_new0(QEEPRO100, 1);
53 QPCIBus *bus = pci_bus;
54
55 qpci_device_init(&eepro100->dev, bus, addr);
56 eepro100->obj.get_driver = eepro100_get_driver;
57
58 return &eepro100->obj;
59}
60
61static void eepro100_register_nodes(void)
62{
63 int i;
64 QOSGraphEdgeOptions opts = {
65 .extra_device_opts = "addr=04.0",
66 };
92838a19 67
0b477302
EGE
68 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
69 for (i = 0; i < ARRAY_SIZE(models); i++) {
70 qos_node_create_driver(models[i], eepro100_create);
71 qos_node_consumes(models[i], "pci-bus", &opts);
72 qos_node_produces(models[i], "pci-device");
73 }
92838a19 74}
0b477302
EGE
75
76libqos_init(eepro100_register_nodes);