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 1534156016686468.5866409155615; Mon, 13 Aug 2018 03:26:56 -0700 (PDT) Received: from localhost ([::1]:38569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpA3r-0000v7-CI for importer@patchew.org; Mon, 13 Aug 2018 06:26:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp9si-0007FV-1w for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp9sg-00024l-Ch for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:23 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:35272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fp9sg-00023c-2X; Mon, 13 Aug 2018 06:15:22 -0400 Received: by mail-ed1-x542.google.com with SMTP id e6-v6so7968234edr.2; Mon, 13 Aug 2018 03:15:22 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 03:15:20 -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=/5GKT1SAZjzPGznEazPvXPfAXr1s8LIn82mGbplzX7M=; b=DfFfcL5gowmb1vea4kVLJInDRIBEJX/WgMdxum4IFlbecObG4MwWJXswROEdFCD+hB iMBrvO3jXXWsCx6J2lwpnjmBXSD1Q2GV3wvvlnc8a8D+2FimvaRnzezfzUDqfN5MAyeO vrVNuKjXOkCtdK1q+iJPhO+OwzoBxjAC7A96v/FMNLnOA0A9czNI79e8M6xWah0KDDX2 Xsuf4T277b+z1G45/FmaEhiWkKNKKvL6rMElYFcTuJZXtaTFtpndrOs5Vo31SQfhUME/ LTR0wJPm63zaAk+6fTEKF1eX3D+emPEZfPc+1PO4D9OWJ1d9S4yCs2NegbOSIXdXWPtB w5OQ== 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=/5GKT1SAZjzPGznEazPvXPfAXr1s8LIn82mGbplzX7M=; b=hX6gdHExjxMSG72iu16jMytCuWgHnkSqiHKPnFe3q4Hnhvz2itioiwUpE1K1gqFtH4 GGPgKIkGefY5qQLPKW/Ql88JwZQ+PiwmlT8MEDZyoofyFyUmMXA4h/kyvjLH0a7SBPjI kaoXJcuRq1F9FJgq5G6f85kvXEHdptMOZ2SDj8750mEXBA5pA+OUiRgqkSJkVP7JYBJ1 EG6BdhAgWqPCPuDhitQyjWlmPaq28mRLrgZiGd2N9dZlrEAChSHPBVlB6LeERKnuwJ73 cLLFhreHYx5j5CRb/ACVKes4mD1kZETzRLM9QgyozKZGjPjgBrEri2/fkYBKY7pSBpYP T7Zg== X-Gm-Message-State: AOUpUlFecB0ayExPP12dN28mML54SdKnJ7lO/tfHnA+54TbWW47eeLSf k8v4hpAzq960ce3hAUTR83OcrbKOPvE= X-Google-Smtp-Source: AA+uWPwyKf0rkRs3g2JymKpRfRs5zbW3pWH0O7USGOHt9bKIeTFl9zULx6fGtmNglEwgpgc0ZSd4kA== X-Received: by 2002:a50:ab13:: with SMTP id s19-v6mr22177076edc.133.1534155320725; Mon, 13 Aug 2018 03:15:20 -0700 (PDT) From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 12:14:29 +0200 Message-Id: <20180813101453.10200-10-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::542 Subject: [Qemu-devel] [PATCH 09/33] tests/qgraph: ppc64/pseries 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 pseries machine for the ppc64 QEMU binary. This machine contains a spapr-pci-host-bridge driver, that contains itself a pci-bus-spapr that produces the pci-bus interface. Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 1 + tests/libqos/ppc64_pseries-machine.c | 111 +++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 tests/libqos/ppc64_pseries-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 5713be3ec4..7c712406e1 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -770,6 +770,7 @@ libqos-virtio-obj-y =3D $(libqos-spapr-obj-y) $(libqos-= pc-obj-y) tests/libqos/virt =20 libqgraph-machines-obj-y =3D tests/libqos/x86_64_pc-machine.o libqgraph-machines-obj-y +=3D tests/libqos/raspi2-machine.o +libqgraph-machines-obj-y +=3D tests/libqos/ppc64_pseries-machine.o =20 libqgraph-pci-obj-y =3D $(libqos-pc-obj-y) $(libqos-spapr-obj-y) libqgraph-pci-obj-y +=3D $(libqgraph-machines-obj-y) diff --git a/tests/libqos/ppc64_pseries-machine.c b/tests/libqos/ppc64_pser= ies-machine.c new file mode 100644 index 0000000000..c860e9bc5b --- /dev/null +++ b/tests/libqos/ppc64_pseries-machine.c @@ -0,0 +1,111 @@ +/* + * 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-spapr.h" +#include "libqos/malloc-spapr.h" + +typedef struct QSPAPR_pci_host QSPAPR_pci_host; +typedef struct Qppc64_pseriesMachine Qppc64_pseriesMachine; + +struct QSPAPR_pci_host { + QOSGraphObject obj; + QPCIBusSPAPR pci; +}; + +struct Qppc64_pseriesMachine { + QOSGraphObject obj; + QGuestAllocator *alloc; + QSPAPR_pci_host bridge; +}; + +/* QSPAPR_pci_host */ + +static QOSGraphObject *QSPAPR_host_get_device(void *obj, const char *devic= e) +{ + QSPAPR_pci_host *host =3D obj; + if (!g_strcmp0(device, "pci-bus-spapr")) { + return &host->pci.obj; + } + fprintf(stderr, "%s not present in QSPAPR_pci_host\n", device); + g_assert_not_reached(); +} + +static void qos_create_QSPAPR_host(QSPAPR_pci_host *host, + QGuestAllocator *alloc) +{ + host->obj.get_device =3D QSPAPR_host_get_device; + qpci_init_spapr(&host->pci, global_qtest, alloc); +} + +/* ppc64/pseries machine */ + +static void spapr_destructor(QOSGraphObject *obj) +{ + Qppc64_pseriesMachine *machine =3D (Qppc64_pseriesMachine *) obj; + spapr_alloc_uninit(machine->alloc); + g_free(obj); +} + +static void *spapr_get_driver(void *object, const char *interface) +{ + Qppc64_pseriesMachine *machine =3D object; + if (!g_strcmp0(interface, "memory")) { + return machine->alloc; + } + + fprintf(stderr, "%s not present in ppc64/pseries\n", interface); + g_assert_not_reached(); +} + +static QOSGraphObject *spapr_get_device(void *obj, const char *device) +{ + Qppc64_pseriesMachine *machine =3D obj; + if (!g_strcmp0(device, "spapr-pci-host-bridge")) { + return &machine->bridge.obj; + } + + fprintf(stderr, "%s not present in ppc64/pseries\n", device); + g_assert_not_reached(); +} + +static void *qos_create_machine_spapr(void) +{ + Qppc64_pseriesMachine *machine =3D g_new0(Qppc64_pseriesMachine, 1); + machine->obj.get_device =3D spapr_get_device; + machine->obj.get_driver =3D spapr_get_driver; + machine->obj.destructor =3D spapr_destructor; + machine->alloc =3D spapr_alloc_init_flags(global_qtest, + ALLOC_NO_FLAGS); + qos_create_QSPAPR_host(&machine->bridge, machine->alloc); + + return &machine->obj; +} + +static void spapr_machine_register_nodes(void) +{ + qos_node_create_machine("ppc64/pseries", qos_create_machine_spapr); + qos_node_create_driver("spapr-pci-host-bridge", NULL); + qos_node_contains("ppc64/pseries", "spapr-pci-host-bridge", NULL); + qos_node_contains("spapr-pci-host-bridge", "pci-bus-spapr", NULL); +} + +libqos_init(spapr_machine_register_nodes); + --=20 2.17.1