From nobody Mon Feb 9 09:22:54 2026 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1570724787; cv=none; d=zoho.com; s=zohoarc; b=NXKx5Y+AGfLQoScPIrVMHX8vkblg+B2Gg1gvoWowun+vZ/OAPqv0MIyJlnWI1x7sNmK2/hw1u72uu7+27p3mdrnmkPji3r6lpef2LqnFPA29Aa6sEawrEwk5Tycj4WD3f6SYnAcPc8d1OUaQi6kTfjNz5iXXa56WeNnzkJj1TkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570724787; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mm53B5ZfYGBTZoN3pu9GHsvqrhtrbf+vxroFHBUhiJo=; b=kAWL0E5AU0P8QGK4ocxfus3Qw7YspG9hJhDSWAFlFS54MlqWpOotFXtXXicx+NPz/IFcq7Qp/bD0PbM6wrIhrrYb+aP7VNkEeBPqZ/CdUOXaIXtAedoY8jOwRaJkfrkzCRgbBKYI6jI067fcbNcmUJzWrI72s6zrPQ0xYhDp79w= ARC-Authentication-Results: i=1; mx.zoho.com; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570724787678988.67927280971; Thu, 10 Oct 2019 09:26:27 -0700 (PDT) Received: from localhost ([::1]:42068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIbGh-00069W-HO for importer@patchew.org; Thu, 10 Oct 2019 12:26:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39154) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIaqN-0005Ki-8Y for qemu-devel@nongnu.org; Thu, 10 Oct 2019 11:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIaqM-00034b-2N for qemu-devel@nongnu.org; Thu, 10 Oct 2019 11:59:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49266) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIaqK-00033e-9v for qemu-devel@nongnu.org; Thu, 10 Oct 2019 11:59:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8116A18067F7 for ; Thu, 10 Oct 2019 15:59:07 +0000 (UTC) Received: from localhost (ovpn-117-170.ams2.redhat.com [10.36.117.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ADBE600F8; Thu, 10 Oct 2019 15:59:01 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 1/7] libqos: extract Legacy virtio-pci.c code Date: Thu, 10 Oct 2019 16:58:47 +0100 Message-Id: <20191010155853.4325-2-stefanha@redhat.com> In-Reply-To: <20191010155853.4325-1-stefanha@redhat.com> References: <20191010155853.4325-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 10 Oct 2019 15:59:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The current libqos virtio-pci.c code implements the VIRTIO Legacy interface. Extract existing code in preparation for VIRTIO 1.0 support. Signed-off-by: Stefan Hajnoczi --- tests/libqos/virtio-pci.h | 2 -- tests/libqos/virtio-pci.c | 25 ++++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h index 728b4715f1..0d105d67b3 100644 --- a/tests/libqos/virtio-pci.h +++ b/tests/libqos/virtio-pci.h @@ -31,8 +31,6 @@ typedef struct QVirtQueuePCI { uint32_t msix_data; } QVirtQueuePCI; =20 -extern const QVirtioBus qvirtio_pci; - void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * ad= dr); QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr); =20 diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index 50499e75ef..c8d736f4d1 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -35,14 +35,6 @@ * original qvirtio_pci_destructor and qvirtio_pci_start_hw. */ =20 -static inline bool qvirtio_pci_is_big_endian(QVirtioPCIDevice *dev) -{ - QPCIBus *bus =3D dev->pdev->bus; - - /* FIXME: virtio 1.0 is always little-endian */ - return qtest_big_endian(bus->qts); -} - #define CONFIG_BASE(dev) (VIRTIO_PCI_CONFIG_OFF((dev)->pdev->msix_enabled)) =20 static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off) @@ -55,8 +47,7 @@ static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d,= uint64_t off) * but virtio ( < 1.0) is in guest order * so with a big-endian guest the order has been reversed, * reverse it again - * virtio-1.0 is always little-endian, like PCI, but this - * case will be managed inside qvirtio_pci_is_big_endian() + * virtio-1.0 is always little-endian, like PCI */ =20 static uint16_t qvirtio_pci_config_readw(QVirtioDevice *d, uint64_t off) @@ -258,7 +249,7 @@ static void qvirtio_pci_virtqueue_kick(QVirtioDevice *d= , QVirtQueue *vq) qpci_io_writew(dev->pdev, dev->bar, VIRTIO_PCI_QUEUE_NOTIFY, vq->index= ); } =20 -const QVirtioBus qvirtio_pci =3D { +static const QVirtioBus qvirtio_pci_legacy =3D { .config_readb =3D qvirtio_pci_config_readb, .config_readw =3D qvirtio_pci_config_readw, .config_readl =3D qvirtio_pci_config_readl, @@ -374,15 +365,19 @@ void qvirtio_pci_start_hw(QOSGraphObject *obj) qvirtio_start_device(&dev->vdev); } =20 +static void qvirtio_pci_init_legacy(QVirtioPCIDevice *dev) +{ + dev->vdev.device_type =3D qpci_config_readw(dev->pdev, PCI_SUBSYSTEM_I= D); + dev->vdev.bus =3D &qvirtio_pci_legacy; + dev->vdev.big_endian =3D qtest_big_endian(dev->pdev->bus->qts); +} + static void qvirtio_pci_init_from_pcidev(QVirtioPCIDevice *dev, QPCIDevice= *pci_dev) { dev->pdev =3D pci_dev; - dev->vdev.device_type =3D qpci_config_readw(pci_dev, PCI_SUBSYSTEM_ID); - dev->config_msix_entry =3D -1; =20 - dev->vdev.bus =3D &qvirtio_pci; - dev->vdev.big_endian =3D qvirtio_pci_is_big_endian(dev); + qvirtio_pci_init_legacy(dev); =20 /* each virtio-xxx-pci device should override at least this function */ dev->obj.get_driver =3D NULL; --=20 2.21.0