From nobody Sun Nov 9 22:27:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551980987491108.97072220832501; Thu, 7 Mar 2019 09:49:47 -0800 (PST) Received: from localhost ([127.0.0.1]:56333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1x9I-0001Hf-Ag for importer@patchew.org; Thu, 07 Mar 2019 12:49:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wqh-000345-CR for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wqg-00081a-7Z for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:27 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wqf-00080x-Vr for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:26 -0500 Received: by mail-wr1-x441.google.com with SMTP id t18so18423174wrx.2 for ; Thu, 07 Mar 2019 09:30:25 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=j7EctTVSWu166VMRkNMv2Z+QB3+xjzdATMk5tC685zw=; b=YwGbHniN+qtnbnB7cCpNOsZVojyq/GtHi18pwhsp09sG5ME7UjwnlXE7Z4fegE3iWo YWdwFDd9L5s1QWqnrB4sZcWjYraXN3vlLqBsdqz47VgcAZy195dhl70xGmL9Tqd44+FM nVxC8OY3sd5TftuG1RoMOb+WtK9RCgSjQYBQdZDdjiD8M/mcul15/EThrGYkmH/Wtsn5 9lu0s0LeMQwGsp5gvFP/WzyMJCQZinKhL+t6TJI80yG86dh3fJsJ0iBt89PSvsCz4w91 dGYtSiS8vzLxEA566slnarzAkcKUBsGQNEtKkQy8KNp6z1iWgn/3aCaiCa1CmTlFlmZl u9hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=j7EctTVSWu166VMRkNMv2Z+QB3+xjzdATMk5tC685zw=; b=aK3ZsZm5sPj9+7diAT8OBYrYF/HNGdOh0lZ+lCIEOFgwL053E7PqGYJFSpaXlUeyFn m/jkjzJVcql2M9W44+5mldxnkCdOEE2MxuBwUPeE3NaymDu2cqRlvK/FmIKUcG0+zFTT r+MXd+Z9gXH/UbK/7prKd8bvt8+j5ueSVK3MMRzUSBvkdYrmZb7qI92+4E/gk/tUGacK 9S1RwLeXaPbiA+nNgH69kqiYtJB9fFYi0Of96yEl+mWEtGvig8uCkPdxjP8oWo7pK18I vcnDmNlVhFwk+UUGS3WQGxblmzr67x/59mOAdnJ0zfv/R/s5+gvfV2bnYdfxqqHeUP/+ y68w== X-Gm-Message-State: APjAAAXYdRNkA8l5QevNJ15zCDqBf/YnKL/RRzUD6SZqIkMXESUTHYJE A00qr5owBsWkbXWV0uoJSakiBjQQ X-Google-Smtp-Source: APXvYqwrcBjRujxeveLHvdr6e4IwrUuA19asBA8likS2GzoDuZ3JXmGKQwk73rjDHr40AOswYrVe5w== X-Received: by 2002:a5d:574b:: with SMTP id q11mr7450636wrw.41.1551979824468; Thu, 07 Mar 2019 09:30:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:24 +0100 Message-Id: <1551979804-6060-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 17/57] 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: thuth@redhat.com, Emanuele Giuseppe Esposito , lviver@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito 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 Signed-off-by: Paolo Bonzini --- 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 37ca530..a890327 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -757,6 +757,7 @@ qos-test-obj-y +=3D tests/libqos/arm-raspi2-machine.o qos-test-obj-y +=3D tests/libqos/arm-sabrelite-machine.o qos-test-obj-y +=3D tests/libqos/arm-smdkc210-machine.o qos-test-obj-y +=3D tests/libqos/arm-xilinx-zynq-a9-machine.o +qos-test-obj-y +=3D tests/libqos/ppc64_pseries-machine.o qos-test-obj-y +=3D tests/libqos/x86_64_pc-machine.o =20 # Tests diff --git a/tests/libqos/ppc64_pseries-machine.c b/tests/libqos/ppc64_pser= ies-machine.c new file mode 100644 index 0000000..2f36400 --- /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, + QTestState *qts, + QGuestAllocator *alloc) +{ + host->obj.get_device =3D QSPAPR_host_get_device; + qpci_init_spapr(&host->pci, qts, alloc); +} + +/* ppc64/pseries machine */ + +static void spapr_destructor(QOSGraphObject *obj) +{ + Qppc64_pseriesMachine *machine =3D (Qppc64_pseriesMachine *) obj; + alloc_destroy(&machine->alloc); +} + +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(QTestState *qts) +{ + 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; + spapr_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS); + + qos_create_QSPAPR_host(&machine->bridge, qts, &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 1.8.3.1