]> git.proxmox.com Git - mirror_qemu.git/blame - tests/e1000-test.c
tests/libqos: fix usage of bool in pci-spapr.c
[mirror_qemu.git] / tests / e1000-test.c
CommitLineData
a21baf79
AF
1/*
2 * QTest testcase for e1000 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"
a21baf79 11#include "libqtest.h"
a138f266
EGE
12#include "libqos/qgraph.h"
13#include "libqos/pci.h"
a21baf79 14
a138f266 15typedef struct QE1000 QE1000;
b167383f 16
a138f266
EGE
17struct QE1000 {
18 QOSGraphObject obj;
19 QPCIDevice dev;
20};
a21baf79 21
b167383f
GS
22static const char *models[] = {
23 "e1000",
24 "e1000-82540em",
25 "e1000-82544gc",
26 "e1000-82545em",
b167383f
GS
27};
28
a138f266 29static void *e1000_get_driver(void *obj, const char *interface)
a21baf79 30{
a138f266 31 QE1000 *e1000 = obj;
a21baf79 32
a138f266
EGE
33 if (!g_strcmp0(interface, "pci-device")) {
34 return &e1000->dev;
35 }
a21baf79 36
a138f266
EGE
37 fprintf(stderr, "%s not present in e1000e\n", interface);
38 g_assert_not_reached();
39}
a21baf79 40
a138f266
EGE
41static void *e1000_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
42{
43 QE1000 *e1000 = g_new0(QE1000, 1);
44 QPCIBus *bus = pci_bus;
45
46 qpci_device_init(&e1000->dev, bus, addr);
47 e1000->obj.get_driver = e1000_get_driver;
48
49 return &e1000->obj;
50}
51
52static void e1000_register_nodes(void)
53{
54 int i;
55 QOSGraphEdgeOptions opts = {
56 .extra_device_opts = "addr=04.0",
57 };
58 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
a21baf79 59
a138f266
EGE
60 for (i = 0; i < ARRAY_SIZE(models); i++) {
61 qos_node_create_driver(models[i], e1000_create);
62 qos_node_consumes(models[i], "pci-bus", &opts);
63 qos_node_produces(models[i], "pci-device");
64 }
a21baf79 65}
a138f266
EGE
66
67libqos_init(e1000_register_nodes);