From nobody Sun Nov 9 22:39:43 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 1551982851493749.3369541326532; Thu, 7 Mar 2019 10:20:51 -0800 (PST) Received: from localhost ([127.0.0.1]:56802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xdP-0002dH-9Y for importer@patchew.org; Thu, 07 Mar 2019 13:20:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wrS-0003vo-Eb for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wrR-0000Ef-GL for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:14 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:40427) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wrR-0000E3-8g for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:13 -0500 Received: by mail-wm1-x333.google.com with SMTP id g20so9985342wmh.5 for ; Thu, 07 Mar 2019 09:31:13 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.31.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:31:11 -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=4VfXBQJnjopNit5y6AgATqkoYdvOtk5Cv85by7uizdY=; b=Z2ndWU8HCjQQ2FTErO1BiYvHVQF2ZrkhZNXQ1NUVTK3Mi1FB419EnB1BD0ix14xqfV hUa7hvmKqUNOMyYnmbknqdPn8bxao1B0J+S2cLwx0wecHt7sc5AIXrhhGXgsJwKoLHGU iUkCFSu/pjcGqtYsDsF2nP8c2C+Qr7Bd92sfw2d2vLSKER1U+hQJtbJ+Z0FJDlyLeuKo 2y9V6RqYvivlXFW3V+1M0JcIbB1lzHEbASIS5iChOExxmSoHzBBSwDIBLBehUPYuEgOD wPi8WN13TWFfyVqRxyl3+kw7zW3PXMhcIJBjl92yqaUjWE9a2iCZhqweAHhaXh+Ebk8R wq1A== 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=4VfXBQJnjopNit5y6AgATqkoYdvOtk5Cv85by7uizdY=; b=AbjzR740ylHzMtoZVZLno8in50QJB7qTLI6eo+N2TNIEZSj9pONWffAby+K1bGzSH4 ycwCQ9Lw69vm30cT/HoDWcaTXmipdSqfSuFgSoAepP+vhHAA7e+vlDcVvV9/A5d6qtWK ySji8dQGdd9rdx8nFAH3V1LewIYqPQtAS22+ck15IbA3AHT4ASUeBkX69UnleOpRes5a 7d3AeVkwB8Vmf7csCSNbGpEhB5Ba/9UZVFiIL8eN0Dcnm/xdBrZSicH16wKKyY9c8/5R +WWgEeF2rgYl+Sb/QSTmBlrjw77QuNil8n4rY3+lugPuRTRNRX3gFTbfWefs3lREO49h z2dw== X-Gm-Message-State: APjAAAV0GyPG51rYERFV0ul9yQ+vrb2M9MFwXkxYt72Cd1LJwu+SbVxa zBZ4CPBIPgoCK55h2oJk6rBqM8/x X-Google-Smtp-Source: APXvYqwMywPNTYO+pumCMm81CHre7qQesfDCKoZ932rRI4DPkIaUUa3vsO7Vf3pegDKlqc9scsDn+g== X-Received: by 2002:a7b:c74b:: with SMTP id w11mr6286944wmk.79.1551979871947; Thu, 07 Mar 2019 09:31:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:30:03 +0100 Message-Id: <1551979804-6060-57-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::333 Subject: [Qemu-devel] [PULL 56/57] qos-test: e1000 test 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 Convert tests/e1000-test to a driver node; currently it runs the PCI nop test only, therefore we're not placing it in tests/libqos. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 3 +-- tests/e1000-test.c | 64 +++++++++++++++++++++++++++++++---------------= ---- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index befeb8f..5bc6d63 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -151,7 +151,6 @@ check-qtest-generic-y +=3D tests/qmp-cmd-test$(EXESUF) check-qtest-generic-y +=3D tests/device-introspect-test$(EXESUF) check-qtest-generic-y +=3D tests/cdrom-test$(EXESUF) =20 -check-qtest-pci-y +=3D tests/e1000-test$(EXESUF) check-qtest-pci-$(CONFIG_RTL8139_PCI) +=3D tests/rtl8139-test$(EXESUF) check-qtest-pci-$(CONFIG_VGA) +=3D tests/display-vga-test$(EXESUF) check-qtest-pci-$(CONFIG_HDA) +=3D tests/intel-hda-test$(EXESUF) @@ -742,6 +741,7 @@ qos-test-obj-y +=3D tests/libqos/x86_64_pc-machine.o =20 # Tests qos-test-obj-y +=3D tests/ac97-test.o +qos-test-obj-y +=3D tests/e1000-test.o qos-test-obj-y +=3D tests/e1000e-test.o qos-test-obj-y +=3D tests/eepro100-test.o qos-test-obj-y +=3D tests/es1370-test.o @@ -797,7 +797,6 @@ tests/m25p80-test$(EXESUF): tests/m25p80-test.o tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/q35-test$(EXESUF): tests/q35-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) -tests/e1000-test$(EXESUF): tests/e1000-test.o tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o $(libqos-pc-obj-y) tests/pnv-xscom-test$(EXESUF): tests/pnv-xscom-test.o tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o diff --git a/tests/e1000-test.c b/tests/e1000-test.c index 0c5fcdc..9e67916 100644 --- a/tests/e1000-test.c +++ b/tests/e1000-test.c @@ -9,22 +9,15 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/qgraph.h" +#include "libqos/pci.h" =20 -/* Tests only initialization so far. TODO: Replace with functional tests */ -static void test_device(gconstpointer data) -{ - const char *model =3D data; - QTestState *s; - char *args; - - args =3D g_strdup_printf("-device %s", model); - s =3D qtest_start(args); +typedef struct QE1000 QE1000; =20 - if (s) { - qtest_quit(s); - } - g_free(args); -} +struct QE1000 { + QOSGraphObject obj; + QPCIDevice dev; +}; =20 static const char *models[] =3D { "e1000", @@ -33,19 +26,42 @@ static const char *models[] =3D { "e1000-82545em", }; =20 -int main(int argc, char **argv) +static void *e1000_get_driver(void *obj, const char *interface) { - int i; + QE1000 *e1000 =3D obj; =20 - g_test_init(&argc, &argv, NULL); + if (!g_strcmp0(interface, "pci-device")) { + return &e1000->dev; + } =20 - for (i =3D 0; i < ARRAY_SIZE(models); i++) { - char *path; + fprintf(stderr, "%s not present in e1000e\n", interface); + g_assert_not_reached(); +} =20 - path =3D g_strdup_printf("e1000/%s", models[i]); - qtest_add_data_func(path, models[i], test_device); - g_free(path); - } +static void *e1000_create(void *pci_bus, QGuestAllocator *alloc, void *add= r) +{ + QE1000 *e1000 =3D g_new0(QE1000, 1); + QPCIBus *bus =3D pci_bus; + + qpci_device_init(&e1000->dev, bus, addr); + e1000->obj.get_driver =3D e1000_get_driver; + + return &e1000->obj; +} + +static void e1000_register_nodes(void) +{ + int i; + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "addr=3D04.0", + }; + add_qpci_address(&opts, &(QPCIAddress) { .devfn =3D QPCI_DEVFN(4, 0) }= ); =20 - return g_test_run(); + for (i =3D 0; i < ARRAY_SIZE(models); i++) { + qos_node_create_driver(models[i], e1000_create); + qos_node_consumes(models[i], "pci-bus", &opts); + qos_node_produces(models[i], "pci-device"); + } } + +libqos_init(e1000_register_nodes); --=20 1.8.3.1