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