[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node |
Date: |
Thu, 7 Mar 2019 18:29:14 +0100 |
From: Emanuele Giuseppe Esposito <address@hidden>
Add pc machine for the x86_64 QEMU binary. This machine contains an
i440FX-pcihost
driver, that contains itself a pci-bus-pc that produces the pci-bus interface.
Signed-off-by: Emanuele Giuseppe Esposito <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
tests/Makefile.include | 3 ++
tests/libqos/x86_64_pc-machine.c | 114 +++++++++++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+)
create mode 100644 tests/libqos/x86_64_pc-machine.c
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 5a7ea15..8a760bd 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -753,6 +753,9 @@ libqos-virtio-obj-y = $(libqos-spapr-obj-y)
$(libqos-pc-obj-y) tests/libqos/virt
qos-test-obj-y = tests/qos-test.o $(libqgraph-obj-y)
qos-test-obj-y += $(libqos-pc-obj-y)
+# Machines
+qos-test-obj-y += tests/libqos/x86_64_pc-machine.o
+
check-unit-y += tests/test-qgraph$(EXESUF)
tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y)
diff --git a/tests/libqos/x86_64_pc-machine.c b/tests/libqos/x86_64_pc-machine.c
new file mode 100644
index 0000000..8bd0360
--- /dev/null
+++ b/tests/libqos/x86_64_pc-machine.c
@@ -0,0 +1,114 @@
+/*
+ * libqos driver framework
+ *
+ * Copyright (c) 2018 Emanuele Giuseppe Esposito <address@hidden>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>
+ */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+#include "libqos/qgraph.h"
+#include "pci-pc.h"
+#include "malloc-pc.h"
+
+typedef struct QX86PCMachine QX86PCMachine;
+typedef struct i440FX_pcihost i440FX_pcihost;
+typedef struct QSDHCI_PCI QSDHCI_PCI;
+
+struct i440FX_pcihost {
+ QOSGraphObject obj;
+ QPCIBusPC pci;
+};
+
+struct QX86PCMachine {
+ QOSGraphObject obj;
+ QGuestAllocator alloc;
+ i440FX_pcihost bridge;
+};
+
+/* i440FX_pcihost */
+
+static QOSGraphObject *i440FX_host_get_device(void *obj, const char *device)
+{
+ i440FX_pcihost *host = obj;
+ if (!g_strcmp0(device, "pci-bus-pc")) {
+ return &host->pci.obj;
+ }
+ fprintf(stderr, "%s not present in i440FX-pcihost\n", device);
+ g_assert_not_reached();
+}
+
+static void qos_create_i440FX_host(i440FX_pcihost *host,
+ QTestState *qts,
+ QGuestAllocator *alloc)
+{
+ host->obj.get_device = i440FX_host_get_device;
+ qpci_init_pc(&host->pci, qts, alloc);
+}
+
+/* x86_64/pc machine */
+
+static void pc_destructor(QOSGraphObject *obj)
+{
+ QX86PCMachine *machine = (QX86PCMachine *) obj;
+ alloc_destroy(&machine->alloc);
+}
+
+static void *pc_get_driver(void *object, const char *interface)
+{
+ QX86PCMachine *machine = object;
+ if (!g_strcmp0(interface, "memory")) {
+ return &machine->alloc;
+ }
+
+ fprintf(stderr, "%s not present in x86_64/pc\n", interface);
+ g_assert_not_reached();
+}
+
+static QOSGraphObject *pc_get_device(void *obj, const char *device)
+{
+ QX86PCMachine *machine = obj;
+ if (!g_strcmp0(device, "i440FX-pcihost")) {
+ return &machine->bridge.obj;
+ }
+
+ fprintf(stderr, "%s not present in x86_64/pc\n", device);
+ g_assert_not_reached();
+}
+
+static void *qos_create_machine_pc(QTestState *qts)
+{
+ QX86PCMachine *machine = g_new0(QX86PCMachine, 1);
+ machine->obj.get_device = pc_get_device;
+ machine->obj.get_driver = pc_get_driver;
+ machine->obj.destructor = pc_destructor;
+ pc_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS);
+ qos_create_i440FX_host(&machine->bridge, qts, &machine->alloc);
+
+ return &machine->obj;
+}
+
+static void pc_machine_register_nodes(void)
+{
+ qos_node_create_machine("i386/pc", qos_create_machine_pc);
+ qos_node_contains("i386/pc", "i440FX-pcihost", NULL);
+
+ qos_node_create_machine("x86_64/pc", qos_create_machine_pc);
+ qos_node_contains("x86_64/pc", "i440FX-pcihost", NULL);
+
+ qos_node_create_driver("i440FX-pcihost", NULL);
+ qos_node_contains("i440FX-pcihost", "pci-bus-pc", NULL);
+}
+
+libqos_init(pc_machine_register_nodes);
--
1.8.3.1
- [Qemu-devel] [PULL 00/57] qgraph merge, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 02/57] tests/libqos: introduce virtio_start_device, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 01/57] chardev-socket: do not blindly reset handlers when switching GMainContext, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 03/57] tests/libqos: rename qpci_init_pc and qpci_init_spapr functions, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/57] tests/libqos: pci-pc driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 09/57] tests/libqos: arm/raspi2 machine node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 04/57] tests/libqos: embed allocators instead of malloc-ing them separately, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 08/57] tests/libqos: sdhci driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 10/57] tests/libqos: arm/smdkc210 machine node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 13/57] tests/libqos: aarch64/xlnx-zcu102 machine node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 11/57] tests/libqos: arm/sabrelite machine node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 15/57] tests/qgraph: add generic PCI testcases, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 12/57] tests/libqos: arm/xilinx-zynq-a9 machine node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 16/57] tests/libqos: pci-spapr driver and interface nodes, Paolo Bonzini, 2019/03/07