From nobody Sun Nov 9 22:26:48 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 1551983512325312.2744165564667; Thu, 7 Mar 2019 10:31:52 -0800 (PST) Received: from localhost ([127.0.0.1]:57016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xo4-0003u2-4o for importer@patchew.org; Thu, 07 Mar 2019 13:31:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wrL-0003pY-7C for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wrK-00009w-Aa for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:07 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:40977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wrK-00009O-1N for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:31:06 -0500 Received: by mail-wr1-x434.google.com with SMTP id n2so18409129wrw.8 for ; Thu, 07 Mar 2019 09:31:05 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.31.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:31:03 -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=f6iufZumE/RPOI0L+CVS1J4JUVjjzDte2gwZqJFvB0E=; b=twkVcb0FxxjgkBfd42G5aCPPYwTqlCf3dvSsJIo7ZhpInCj0jzUjIps1OAHkOd4Tm/ EfCKvisYYe5/KVgvdBUpRGkNbYuPL7H0QFhmGXJ0kJqT4m0KAyGOC6GlmNlHXfhB/u+Z kxCZvvDSkvmWHI9inIvwi31SxKzsvnkoRMw43QKyic8+rOBWUJmNM8K5adnol3s+dIDU uFIZq1kBa7dID1hT9leAEntE42SffZMzrgdO/arpN7sEH7Wf4I86DpmQks4iZ72/kGRx w5yOWbx8OUyISqIhDmfIWP8cvExLnLHjotPMR3GCTHUSgWKVgSCm5FIOk6qn4Y3DBAqg N4Yw== 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=f6iufZumE/RPOI0L+CVS1J4JUVjjzDte2gwZqJFvB0E=; b=obzmEa2sE6ONtx7/K17HxCD9f4D91ceclPcNpah1BzWcTsTfCHAKNXVd6Mk6+km9ns KvVCrbvjk8sYA1uNjhKplfm0tq95qm/Ximy7XK0eoknbuuRkMUqxWSujBexkpA/x8ISz ZN4ravmrhsT5F4DpUAJgC7x3fafoYHVWcXFAHTfbQlowdtY83dTazTSv/s9md+RMS1kI qkdP+qqQ6cehnlsl1oX4A7jjXaN/scqPIDNF/LQbudWX05c9yfI3E/wfm31nL1AJQzzy TcQtYJlxFbBFz85iGyg9kke5aMTzuxJ1ntP+xDIX0mSjxLldz0CkcPXvmrAFNQ3t+u4U Sx1A== X-Gm-Message-State: APjAAAVE4/psjJwNN8RCJ6C6K8o+6gc3A+4h66gmu9jTXAI6iUY8pxgh E8gOIWN+Y+E2knftc7mBvhs0A2TA X-Google-Smtp-Source: APXvYqxopNxDGWwHfwIX0yaXcxTvJCKN7+w1WMEx5QuLq5xTAx9k3sTfqsit1zxnISJGNzxia8MFGQ== X-Received: by 2002:adf:ce91:: with SMTP id r17mr7367444wrn.80.1551979864575; Thu, 07 Mar 2019 09:31:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:57 +0100 Message-Id: <1551979804-6060-51-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::434 Subject: [Qemu-devel] [PULL 50/57] qos-test: pcnet 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/pcnet-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/pcnet-test.c | 46 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 46f8c34..0442be8 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -153,7 +153,6 @@ 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_PCNET_PCI) +=3D tests/pcnet-test$(EXESUF) check-qtest-pci-$(CONFIG_EEPRO100_PCI) +=3D tests/eepro100-test$(EXESUF) check-qtest-pci-$(CONFIG_ES1370) +=3D tests/es1370-test$(EXESUF) check-qtest-pci-$(CONFIG_VGA) +=3D tests/display-vga-test$(EXESUF) @@ -754,6 +753,7 @@ qos-test-obj-y +=3D tests/ipoctal232-test.o qos-test-obj-y +=3D tests/ne2000-test.o qos-test-obj-y +=3D tests/nvme-test.o qos-test-obj-y +=3D tests/pci-test.o +qos-test-obj-y +=3D tests/pcnet-test.o qos-test-obj-y +=3D tests/sdhci-test.o qos-test-obj-$(CONFIG_VHOST_NET_USER) +=3D tests/vhost-user-test.o $(chard= ev-obj-y) $(test-io-obj-y) qos-test-obj-y +=3D tests/virtio-test.o @@ -801,7 +801,6 @@ tests/q35-test$(EXESUF): tests/q35-test.o $(libqos-pc-o= bj-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/pcnet-test$(EXESUF): tests/pcnet-test.o tests/pnv-xscom-test$(EXESUF): tests/pnv-xscom-test.o tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c index efb1ef4..484448c 100644 --- a/tests/pcnet-test.c +++ b/tests/pcnet-test.c @@ -9,23 +9,49 @@ =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 pci_nop(void) +typedef struct QPCNet QPCNet; + +struct QPCNet { + QOSGraphObject obj; + QPCIDevice dev; +}; + +static void *pcnet_get_driver(void *obj, const char *interface) { + QPCNet *pcnet =3D obj; + + if (!g_strcmp0(interface, "pci-device")) { + return &pcnet->dev; + } + + fprintf(stderr, "%s not present in pcnet\n", interface); + g_assert_not_reached(); } =20 -int main(int argc, char **argv) +static void *pcnet_create(void *pci_bus, QGuestAllocator *alloc, void *add= r) { - int ret; + QPCNet *pcnet =3D g_new0(QPCNet, 1); + QPCIBus *bus =3D pci_bus; =20 - g_test_init(&argc, &argv, NULL); - qtest_add_func("/pcnet/pci/nop", pci_nop); + qpci_device_init(&pcnet->dev, bus, addr); + pcnet->obj.get_driver =3D pcnet_get_driver; =20 - qtest_start("-device pcnet"); - ret =3D g_test_run(); + return &pcnet->obj; +} =20 - qtest_end(); +static void pcnet_register_nodes(void) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "addr=3D04.0", + }; + add_qpci_address(&opts, &(QPCIAddress) { .devfn =3D QPCI_DEVFN(4, 0) }= ); =20 - return ret; + qos_node_create_driver("pcnet", pcnet_create); + qos_node_consumes("pcnet", "pci-bus", &opts); + qos_node_produces("pcnet", "pci-device"); } + +libqos_init(pcnet_register_nodes); --=20 1.8.3.1