2 * QTest testcase for e1000 NIC
4 * Copyright (c) 2013-2014 SUSE LINUX Products GmbH
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.
10 #include "qemu/osdep.h"
12 #include "libqos/qgraph.h"
13 #include "libqos/pci.h"
15 typedef struct QE1000 QE1000
;
22 static const char *models
[] = {
29 static void *e1000_get_driver(void *obj
, const char *interface
)
33 if (!g_strcmp0(interface
, "pci-device")) {
37 fprintf(stderr
, "%s not present in e1000e\n", interface
);
38 g_assert_not_reached();
41 static void *e1000_create(void *pci_bus
, QGuestAllocator
*alloc
, void *addr
)
43 QE1000
*e1000
= g_new0(QE1000
, 1);
44 QPCIBus
*bus
= pci_bus
;
46 qpci_device_init(&e1000
->dev
, bus
, addr
);
47 e1000
->obj
.get_driver
= e1000_get_driver
;
52 static void e1000_register_nodes(void)
55 QOSGraphEdgeOptions opts
= {
56 .extra_device_opts
= "addr=04.0",
58 add_qpci_address(&opts
, &(QPCIAddress
) { .devfn
= QPCI_DEVFN(4, 0) });
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");
67 libqos_init(e1000_register_nodes
);