From nobody Tue Nov 4 22:00:42 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 1533566302673546.6292876192832; Mon, 6 Aug 2018 07:38:22 -0700 (PDT) Received: from localhost ([::1]:34367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmgeL-0007MP-Hc for importer@patchew.org; Mon, 06 Aug 2018 10:38:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmgb6-00054m-0a for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmgb4-0000w9-Rr for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:35:00 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:39563) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmgb4-0000vE-Jg for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:34:58 -0400 Received: by mail-ed1-x543.google.com with SMTP id h4-v6so5253337edi.6 for ; Mon, 06 Aug 2018 07:34:58 -0700 (PDT) Received: from localhost.localdomain ([194.230.159.126]) by smtp.gmail.com with ESMTPSA id x13-v6sm14615157edx.17.2018.08.06.07.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 07:34:57 -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=Q7SpMJV7lpaM108sb36xQkxluA5iJZIfUFs9JXb+jhU=; b=eX09QCUaenXDNgE/4CMzA0p0xc01aa9RmAE34S20Xl/S5/yhBu+VcxXM0BwGVg12km ChQKGN0ROdopFiX7jGmLILPZ+PMiJMsXqgggl+qttKTeS12y46lcZ6w1XrJL4idWIzc6 erEHE7Loz1FAEaqqf8qhUEK+ZWZ6kJp21xpjyFPzAJLhE4kR5xDtHUsGzaRvn0+Cki87 TBh5P58jZcaFrOE8rIREHZTqlFSxYWueadHro+CX7uWdPVmy/EjTcl+nxdhQnSuFysg9 e2XWHawhdNh5RnCJzBXevyDDbok4n6z4m16cUaJx50jzPcdJLBUAmj9kMOQQYaxIZoMe 9G9w== 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=Q7SpMJV7lpaM108sb36xQkxluA5iJZIfUFs9JXb+jhU=; b=f5m9EPn4idDLuzXRIz5iQUU9MhqoDZgpCi0K9Y9XmIKRmdUVirDYZCh7iptSkB+Xji Ujvb7d8NpCRPbrxqPzD0PQutfqrwGfiQaOnKTLKc/Sjf2KSoRzp0nYhxD0oNfmOWEreG w2p9HPfWq5SYzC5rmzlwMvylvQUMW9OBKPJicgVmYmSZ0qiH/1wxezuHiCk0e22fbZxj lu7tp/RRBqunnn1bfYDEec73cP+J3cvz4RSgD4E7yvW53jPlAE8Sa1/pzJVF8lcwb6Zs zJwy/rYkv5nPDWazMkDbLr87II9y6ORmmRZAjy/82zdLb4TY4SLjOlXNTASa0eRmloUY RjRw== X-Gm-Message-State: AOUpUlGcQFWwY+nx7JAuK5DvlZI81/YKrxB328a9uykX6OcbdDE6AhCD Hfhsp8V/dS65dC54CfBvDhc= X-Google-Smtp-Source: AAOMgpf1qw0/ON9kE7MSfj9crOIDbajUpCNySgZHqiw/B/Mh++qpB8qKrBXF0tKmIPfhzdtMqLR3pg== X-Received: by 2002:a50:c082:: with SMTP id k2-v6mr17967742edf.294.1533566097582; Mon, 06 Aug 2018 07:34:57 -0700 (PDT) From: Emanuele Giuseppe Esposito To: Paolo Bonzini Date: Mon, 6 Aug 2018 16:33:55 +0200 Message-Id: <20180806143412.27722-18-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806143412.27722-1-e.emanuelegiuseppe@gmail.com> References: <20180806143412.27722-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 v2 17/34] test/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 , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org 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 8dfbe049e7..4659785baf 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..e23fb95191 --- /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_destroy(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, "guest_allocator")) { + return machine->alloc; + } + + printf("%s not present in arm/virtio\n", interface); + abort(); +} + +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; + } + + printf("%s not present in arm/virtio\n", device); + abort(); +} + +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_destroy; + return machine; +} + +static void virtio_machine(void) +{ + qos_node_create_machine("arm/virt", qos_create_machine_arm_virt); + qos_node_contains("arm/virt", "virtio-mmio", NULL); +} + +libqos_init(virtio_machine); --=20 2.17.1