From nobody Wed Nov 5 10:47:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534155464942120.43825422520956; Mon, 13 Aug 2018 03:17:44 -0700 (PDT) Received: from localhost ([::1]:38498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp9uu-0008Sg-Ts for importer@patchew.org; Mon, 13 Aug 2018 06:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp9sY-000751-Cu for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp9sW-0001to-Tc for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:14 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:41402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fp9sW-0001sm-JS; Mon, 13 Aug 2018 06:15:12 -0400 Received: by mail-ed1-x544.google.com with SMTP id s24-v6so7939336edr.8; Mon, 13 Aug 2018 03:15:12 -0700 (PDT) Received: from localhost.localdomain ([194.230.159.125]) by smtp.gmail.com with ESMTPSA id s27-v6sm11670006edb.73.2018.08.13.03.15.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 03:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=okrwQALFXXuW42DMq6tZb4XPejSs1aMMhUKnzOtJCxM=; b=LxHBK1stSkuKMT9KIRuuq5aHT1UkVGluBx6kKtesl9RrFTc6mo1QRj5v9y1JhA4Z73 pbIntw1og4rKX+yKuIaA50iiqepqVX5wAQ5DPecFNfWP4oKvfiKfC1dyPN8mq34P30s1 dc7tsx/OuJNatCM108aa39hnnOqcgRgtWjRo3/xgeZBP752YDN0YCpAqA2jWqh80cfnu DJpp7LgxhYsSdHFFdrhaFzDCG4TKHIZUI3B3QnICk//LPBi5JeLtxTRc1dyhBXQqvbH5 A70do86ZADLSso76JKq2f5yHQylWEkKj7yoM+vTWFCgrLvv/Ol8qZZNprR6Z8P8rQ/BL KjNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=okrwQALFXXuW42DMq6tZb4XPejSs1aMMhUKnzOtJCxM=; b=bslsiQPAUhazdogX0aYTAcDGN/POTN+o0GfkJ2Z/b3IzCh3QX2RRcl6HWz5Bo4S2xt wLU+xnhVbMsmDrjyCyh5glz4Uy96eQGYSOHOnujtlR5CuWYPLsp9PeHBHNpjV8kaap75 4TsO4oB10nP/jhAiPKA7rUKoFdOzii5Tz7MFU0PKAS8XP2DKo9FiLX7l6rYM+wCozOpn pCQZ1NMPVL1sPXAoSG1cJzGbzPo5LEbaW/vHf9epxLV3AIkuGIJ8G7Kgkgy4d+rG2YKj KybgmEi4wG8efOIhCQE87pIDidsHnRiFjcvtRMaTtZBCfYFIiKqjlYU8nf2+x4Oc3OLI FEKg== X-Gm-Message-State: AOUpUlGhSOdurMAc5EDrP/I2dR0CdauKpufqzRxoEhAtQ80HfZ8I6C6A Q9B+8OSLjLh4nFw6nU7b2dXqwEsvgFw= X-Google-Smtp-Source: AA+uWPzFFfUMsR+0AaQ/3YgB/Od0qjqjMcPn/DUvOD0jSwZ/JSpLq9uLpor/Q1G9YQfhwXEou7cbMA== X-Received: by 2002:aa7:c3d2:: with SMTP id l18-v6mr21032939edr.205.1534155311291; Mon, 13 Aug 2018 03:15:11 -0700 (PDT) From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 12:14:24 +0200 Message-Id: <20180813101453.10200-5-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180813101453.10200-1-e.emanuelegiuseppe@gmail.com> References: <20180813101453.10200-1-e.emanuelegiuseppe@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::544 Subject: [Qemu-devel] [PATCH 04/33] tests/qgraph: x86_64/pc machine node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Fam Zheng , qemu-block@nongnu.org, "Michael S. Tsirkin" , Jason Wang , Amit Shah , Emanuele Giuseppe Esposito , Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , John Snow , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 interfa= ce. Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 3 + tests/libqos/x86_64_pc-machine.c | 110 +++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/libqos/x86_64_pc-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index d99a58894b..2154e53944 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -771,7 +771,10 @@ libqos-imx-obj-y =3D $(libqos-obj-y) tests/libqos/i2c-= imx.o libqos-usb-obj-y =3D $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos= /usb.o libqos-virtio-obj-y =3D $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/lib= qos/virtio.o tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o tests/lib= qos/malloc-generic.o =20 +libqgraph-machines-obj-y =3D tests/libqos/x86_64_pc-machine.o + libqgraph-pci-obj-y =3D $(libqos-pc-obj-y) +libqgraph-pci-obj-y +=3D $(libqgraph-machines-obj-y) =20 check-unit-y +=3D 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-mach= ine.c new file mode 100644 index 0000000000..d8db18d0ff --- /dev/null +++ b/tests/libqos/x86_64_pc-machine.c @@ -0,0 +1,110 @@ +/* + * libqos driver framework + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * 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 + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "libqos/qgraph.h" +#include "pci-pc.h" +#include "malloc-pc.h" + +typedef struct QX86_64_PCMachine QX86_64_PCMachine; +typedef struct i440FX_pcihost i440FX_pcihost; +typedef struct QSDHCI_PCI QSDHCI_PCI; + +struct i440FX_pcihost { + QOSGraphObject obj; + QPCIBusPC pci; +}; + +struct QX86_64_PCMachine { + QOSGraphObject obj; + QGuestAllocator *alloc; + i440FX_pcihost bridge; +}; + +/* i440FX_pcihost */ + +static QOSGraphObject *i440FX_host_get_device(void *obj, const char *devic= e) +{ + i440FX_pcihost *host =3D 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, + QGuestAllocator *alloc) +{ + host->obj.get_device =3D i440FX_host_get_device; + qpci_init_pc(&host->pci, global_qtest, alloc); +} + +/* x86_64/pc machine */ + +static void pc_destructor(QOSGraphObject *obj) +{ + QX86_64_PCMachine *machine =3D (QX86_64_PCMachine *) obj; + pc_alloc_uninit(machine->alloc); + g_free(machine); +} + +static void *pc_get_driver(void *object, const char *interface) +{ + QX86_64_PCMachine *machine =3D 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) +{ + QX86_64_PCMachine *machine =3D 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(void) +{ + QX86_64_PCMachine *machine =3D g_new0(QX86_64_PCMachine, 1); + machine->obj.get_device =3D pc_get_device; + machine->obj.get_driver =3D pc_get_driver; + machine->obj.destructor =3D pc_destructor; + machine->alloc =3D pc_alloc_init_flags(global_qtest, ALLOC_NO_FLAGS); + qos_create_i440FX_host(&machine->bridge, machine->alloc); + + return &machine->obj; +} + +static void pc_machine_register_nodes(void) +{ + qos_node_create_machine("x86_64/pc", qos_create_machine_pc); + qos_node_create_driver("i440FX-pcihost", NULL); + qos_node_contains("x86_64/pc", "i440FX-pcihost", NULL); + qos_node_contains("i440FX-pcihost", "pci-bus-pc", NULL); +} + +libqos_init(pc_machine_register_nodes); --=20 2.17.1