From nobody Wed Nov 5 10:47:35 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 1534155833917560.9828775394154; Mon, 13 Aug 2018 03:23:53 -0700 (PDT) Received: from localhost ([::1]:38546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpA0q-0005kd-9x for importer@patchew.org; Mon, 13 Aug 2018 06:23:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp9t6-0007aN-Na for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp9t5-0002fU-Iv for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:15:48 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:40937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fp9t5-0002f4-C9; Mon, 13 Aug 2018 06:15:47 -0400 Received: by mail-ed1-x543.google.com with SMTP id e19-v6so7945617edq.7; Mon, 13 Aug 2018 03:15:47 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 03:15:45 -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=bQwUwguOGkj1HFkQX3KDlocpUrqsJLtj0zWhH1zx9DA=; b=YqvZ+wLzYhS/DOg360SaWF0S3ceDItXZCBurU5UrGwSfwpiDYybLt2+6IY05FcdxIM QxM+dofTraNOX8R3BOUWumEVisQ/akeolAESkhIHj7Li749/IJtFXHpNzI33D4UySHaR 2RNmpDlZXaIrJJhWw8UzdDse2QS5aMJShcLsAi35/KouTBKv7GnkQuZgbFtoO7rXdc5i yZYLjIcTAMN2n5bu1ipzCONFWNEStgxb20NVzNQwACkPKTIZDkb1cDBRdBEIEbeU2ZwE 75XHgral73fY7kRii+zVpHyrb3ZbA8FYTr4osuaZIgGyzAqWPEYHVmGaIkOWVmDya62x BBUw== 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=bQwUwguOGkj1HFkQX3KDlocpUrqsJLtj0zWhH1zx9DA=; b=rovqNxGz6Hx0PK1rBuosBk686pzG5sm8EFJeXyvq0C03XC2JK/1i79SdpepqSuCn/0 75HznOorx6qHZyaOvGFyzE159Aug8CRhP0cB0kRDvo6Sv8uAH9LDRGfmQcTzeBADLAMB zNWILDeME/a/pTyKtZkcntqx1mO1HoRPWY+OlQweeMgX+UBhGRNyIDCjaK4NEXKpvQeJ OOED5z/tUXimh8kOV1a8skQy97QjG3Bq5/ZQBzUuU4QFcfxYeiDutVkF65b+kfD5AOun AGdOrtUEHYLdpT5pybu+7dqe+BgUyzkR9IARs9+xRhhbIM2yBiDqw2LUrO/vUP0fNLK4 GiRw== X-Gm-Message-State: AOUpUlGbfEsQqgVHxxjb5AgOoKP60Hhp5XgiLIMJQ90jVxjYF2UjHJBt IgLePZHanGWJYyQDqKi3D1ZqiVcXZsk= X-Google-Smtp-Source: AA+uWPyPu1ZpGLPbjo4dmL9QJXhK5yJMe/IQo8WzYTLMn1hVyuWuCM1SXzU6a8eqsx6L3xCZBpjR+w== X-Received: by 2002:a50:8103:: with SMTP id 3-v6mr21445043edc.131.1534155345998; Mon, 13 Aug 2018 03:15:45 -0700 (PDT) From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 12:14:36 +0200 Message-Id: <20180813101453.10200-17-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::543 Subject: [Qemu-devel] [PATCH 16/33] tests/qgraph: arm/virt 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 arm/virt machine to the graph. This machine contains virtio-mmio, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 1 + tests/libqos/virt-machine.c | 90 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/libqos/virt-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 5220136473..20cb983ed0 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 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 +libqgraph-machines-obj-y +=3D tests/libqos/virt-machine.o =20 libqgraph-pci-obj-y =3D $(libqos-virtio-obj-y) libqgraph-pci-obj-y +=3D $(libqgraph-machines-obj-y) diff --git a/tests/libqos/virt-machine.c b/tests/libqos/virt-machine.c new file mode 100644 index 0000000000..c8910a58f4 --- /dev/null +++ b/tests/libqos/virt-machine.c @@ -0,0 +1,90 @@ +/* + * 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/malloc.h" +#include "libqos/qgraph.h" +#include "libqos/virtio-mmio.h" +#include "libqos/malloc-generic.h" + +#define ARM_PAGE_SIZE 4096 +#define VIRTIO_MMIO_BASE_ADDR 0x0A003E00 +#define ARM_VIRT_RAM_ADDR 0x40000000 +#define ARM_VIRT_RAM_SIZE 0x20000000 +#define VIRTIO_MMIO_SIZE 0x00000200 + +typedef struct QVirtioMachine QVirtioMachine; + +struct QVirtioMachine { + QOSGraphObject obj; + QGuestAllocator *alloc; + QVirtioMMIODevice virtio_mmio; +}; + +static void virtio_destructor(QOSGraphObject *obj) +{ + QVirtioMachine *machine =3D (QVirtioMachine *) obj; + generic_alloc_uninit(machine->alloc); + g_free(obj); +} + +static void *virtio_get_driver(void *object, const char *interface) +{ + QVirtioMachine *machine =3D object; + if (!g_strcmp0(interface, "memory")) { + return machine->alloc; + } + + fprintf(stderr, "%s not present in arm/virtio\n", interface); + g_assert_not_reached(); +} + +static QOSGraphObject *virtio_get_device(void *obj, const char *device) +{ + QVirtioMachine *machine =3D obj; + if (!g_strcmp0(device, "virtio-mmio")) { + return &machine->virtio_mmio.obj; + } + + fprintf(stderr, "%s not present in arm/virtio\n", device); + g_assert_not_reached(); +} + +static void *qos_create_machine_arm_virt(void) +{ + QVirtioMachine *machine =3D g_new0(QVirtioMachine, 1); + + machine->alloc =3D generic_alloc_init(ARM_VIRT_RAM_ADDR, ARM_VIRT_RAM_= SIZE, + ARM_PAGE_SIZE); + qvirtio_mmio_init_device(&machine->virtio_mmio, VIRTIO_MMIO_BASE_ADDR, + VIRTIO_MMIO_SIZE); + + machine->obj.get_device =3D virtio_get_device; + machine->obj.get_driver =3D virtio_get_driver; + machine->obj.destructor =3D virtio_destructor; + return machine; +} + +static void virtio_mmio_register_nodes(void) +{ + qos_node_create_machine("arm/virt", qos_create_machine_arm_virt); + qos_node_contains("arm/virt", "virtio-mmio", NULL); +} + +libqos_init(virtio_mmio_register_nodes); --=20 2.17.1