From nobody Sun Nov 9 22:34:28 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 1551982259622784.8613597290885; Thu, 7 Mar 2019 10:10:59 -0800 (PST) Received: from localhost ([127.0.0.1]:56676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xTr-0002lF-FR for importer@patchew.org; Thu, 07 Mar 2019 13:10:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wqt-0003K9-Rt for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wqr-0008BO-PA for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:39 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:35446) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wqp-00086i-KI for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:35 -0500 Received: by mail-wm1-x336.google.com with SMTP id y15so10119343wma.0 for ; Thu, 07 Mar 2019 09:30:33 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:32 -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=AhLswjmBjTbfNLDca7Rmx9gVUVlaW7z4DApF2fOvSXY=; b=g0Gioad9pNOxJYid0fw//a4Q9K+fZdFpg95thIc5Ro7dZDupRKu0bPbTaTzcVwkAOE sni6uEOVvgSgxEwIdnTEqxlziqdpcZNNo+RqcOK5h33s+p0gu0cSdJYPg+WOTShAHrdR DEnBFJwtASmt5CUgG337Sf1BxceBUEpke+1kYN5nsTBgz72cRC9Ogwey5I5PQy46Z/ns adxdLyQfhhhpA7nHRKv9QU1+KZKCsp5YNikUrWKI6wEeVS5akEWfh1IMzNaQ0+ZqJpsf nSJOQcSrCNCYhTQWQbd/KZZAdGp8z+CSrmkz7WDFex4EpUEbNdO6L0LRa9r59XbWXTI0 HtHA== 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=AhLswjmBjTbfNLDca7Rmx9gVUVlaW7z4DApF2fOvSXY=; b=lPtgk45E0ZLYlXqNDmCOu8t62L+ZUaQ+Rjo1KbEY+MzKieXkoZqimicL7ptoA3DEpV U0JtId9EOMTOj+ZCi75vY/xqC4ye4TFEeRPsGOof7SACYod3dahjPRYrPkRJJumOj3Q9 w3XEuBsfS/OZ97wZQAdCsu+yTEdJQcByFa7kwdLa20YK4TPGOYTj6ktIJ7Eb4TbVgP92 AWMvwEIVWpDHxa8pqhkZBCEC6o8RgvAdX4m7PYvyc7RWa5NF9VnFXevjR4TF3KAKwInk m5lGVru3PhKML93uAKFLp2CwJCXiYTwSB16eLpWonX8AX5+IwhFY9wx9z2ofFp5SNXkz xf6A== X-Gm-Message-State: APjAAAVjAW4sGvVZB2E8OHgKO1tUGFL1yX8sa683URJwfP9yOwNRjeB7 /JdrogOlMs8Ezyob8JprmV4Z59Tu X-Google-Smtp-Source: APXvYqwgchf4TIZ1zDYIfQ5uumexd6FsJJHJE2B1uohjsafy2zaTlSK4JiR0Bmcq7VGhOS2aeV9h3w== X-Received: by 2002:a1c:80d6:: with SMTP id b205mr6708819wmd.109.1551979832510; Thu, 07 Mar 2019 09:30:32 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:31 +0100 Message-Id: <1551979804-6060-25-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::336 Subject: [Qemu-devel] [PULL 24/57] tests/libqos: 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: 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 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 Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 1 + tests/libqos/arm-virt-machine.c | 90 +++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 91 insertions(+) create mode 100644 tests/libqos/arm-virt-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index c9c6019..4a9e2e4 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -757,6 +757,7 @@ qos-test-obj-y +=3D tests/libqos/aarch64-xlnx-zcu102-ma= chine.o 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-virt-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 diff --git a/tests/libqos/arm-virt-machine.c b/tests/libqos/arm-virt-machin= e.c new file mode 100644 index 0000000..2abc431 --- /dev/null +++ b/tests/libqos/arm-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" + +#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 QVirtMachine QVirtMachine; + +struct QVirtMachine { + QOSGraphObject obj; + QGuestAllocator alloc; + QVirtioMMIODevice virtio_mmio; +}; + +static void virt_destructor(QOSGraphObject *obj) +{ + QVirtMachine *machine =3D (QVirtMachine *) obj; + alloc_destroy(&machine->alloc); +} + +static void *virt_get_driver(void *object, const char *interface) +{ + QVirtMachine *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 *virt_get_device(void *obj, const char *device) +{ + QVirtMachine *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(QTestState *qts) +{ + QVirtMachine *machine =3D g_new0(QVirtMachine, 1); + + alloc_init(&machine->alloc, 0, + ARM_VIRT_RAM_ADDR, + ARM_VIRT_RAM_ADDR + ARM_VIRT_RAM_SIZE, + ARM_PAGE_SIZE); + qvirtio_mmio_init_device(&machine->virtio_mmio, qts, VIRTIO_MMIO_BASE_= ADDR, + VIRTIO_MMIO_SIZE); + + machine->obj.get_device =3D virt_get_device; + machine->obj.get_driver =3D virt_get_driver; + machine->obj.destructor =3D virt_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 1.8.3.1