]> git.proxmox.com Git - mirror_qemu.git/blame - tests/vmxnet3-test.c
iotests: Test cancelling a job and closing the VM
[mirror_qemu.git] / tests / vmxnet3-test.c
CommitLineData
4a053e7f
AF
1/*
2 * QTest testcase for vmxnet3 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"
4a053e7f 11#include "libqtest.h"
53bfb429
EGE
12#include "libqos/qgraph.h"
13#include "libqos/pci.h"
4a053e7f 14
53bfb429
EGE
15typedef struct QVmxnet3 QVmxnet3;
16
17struct QVmxnet3 {
18 QOSGraphObject obj;
19 QPCIDevice dev;
20};
21
22static void *vmxnet3_get_driver(void *obj, const char *interface)
4a053e7f 23{
53bfb429
EGE
24 QVmxnet3 *vmxnet3 = obj;
25
26 if (!g_strcmp0(interface, "pci-device")) {
27 return &vmxnet3->dev;
28 }
29
30 fprintf(stderr, "%s not present in vmxnet3\n", interface);
31 g_assert_not_reached();
4a053e7f
AF
32}
33
53bfb429 34static void *vmxnet3_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
4a053e7f 35{
53bfb429
EGE
36 QVmxnet3 *vmxnet3 = g_new0(QVmxnet3, 1);
37 QPCIBus *bus = pci_bus;
4a053e7f 38
53bfb429
EGE
39 qpci_device_init(&vmxnet3->dev, bus, addr);
40 vmxnet3->obj.get_driver = vmxnet3_get_driver;
4a053e7f 41
53bfb429
EGE
42 return &vmxnet3->obj;
43}
4a053e7f 44
53bfb429
EGE
45static void vmxnet3_register_nodes(void)
46{
47 QOSGraphEdgeOptions opts = {
48 .extra_device_opts = "addr=04.0",
49 };
50 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
4a053e7f 51
53bfb429
EGE
52 qos_node_create_driver("vmxnet3", vmxnet3_create);
53 qos_node_consumes("vmxnet3", "pci-bus", &opts);
54 qos_node_produces("vmxnet3", "pci-device");
4a053e7f 55}
53bfb429
EGE
56
57libqos_init(vmxnet3_register_nodes);