qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, lviver@redhat.com
Subject: [Qemu-devel] [PULL 43/57] tests/libqos: remove pre-qgraph QVirtioPCIDevice API
Date: Thu,  7 Mar 2019 18:29:50 +0100	[thread overview]
Message-ID: <1551979804-6060-44-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com>

Remove the qvirtio_pci_device_find* and qvirtio_pci_device_free
APIs, now that they do not have any users.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/libqos/virtio-pci.c | 112 +++++++---------------------------------------
 tests/libqos/virtio-pci.h |   4 --
 2 files changed, 17 insertions(+), 99 deletions(-)

diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 0b58b74..993d347 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.
  */
 
-typedef struct QVirtioPCIForeachData {
-    void (*func)(QVirtioDevice *d, void *data);
-    uint16_t device_type;
-    bool has_slot;
-    int slot;
-    void *user_data;
-} QVirtioPCIForeachData;
-
 static inline bool qvirtio_pci_is_big_endian(QVirtioPCIDevice *dev)
 {
     QPCIBus *bus = dev->pdev->bus;
@@ -51,50 +43,6 @@ static inline bool qvirtio_pci_is_big_endian(QVirtioPCIDevice *dev)
     return qtest_big_endian(bus->qts);
 }
 
-void qvirtio_pci_device_free(QVirtioPCIDevice *dev)
-{
-    g_free(dev->pdev);
-}
-
-static void qvirtio_pci_init_from_pcidev(QVirtioPCIDevice *dev, QPCIDevice *pci_dev)
-{
-    dev->pdev = pci_dev;
-    dev->vdev.device_type = qpci_config_readw(pci_dev, PCI_SUBSYSTEM_ID);
-
-    dev->config_msix_entry = -1;
-
-    dev->vdev.bus = &qvirtio_pci;
-    dev->vdev.big_endian = qvirtio_pci_is_big_endian(dev);
-
-    /* each virtio-xxx-pci device should override at least this function */
-    dev->obj.get_driver = NULL;
-    dev->obj.start_hw = qvirtio_pci_start_hw;
-    dev->obj.destructor = qvirtio_pci_destructor;
-}
-
-static void qvirtio_pci_foreach_callback(
-                        QPCIDevice *dev, int devfn, void *data)
-{
-    QVirtioPCIForeachData *d = data;
-    QVirtioPCIDevice *vpcidev = g_new0(QVirtioPCIDevice, 1);
-
-    qvirtio_pci_init_from_pcidev(vpcidev, dev);
-    if (vpcidev->vdev.device_type == d->device_type &&
-        (!d->has_slot || vpcidev->pdev->devfn == d->slot << 3)) {
-        d->func(&vpcidev->vdev, d->user_data);
-    } else {
-        qvirtio_pci_device_free(vpcidev);
-        g_free(vpcidev);
-    }
-}
-
-static void qvirtio_pci_assign_device(QVirtioDevice *d, void *data)
-{
-    QVirtioPCIDevice **vpcidev = data;
-    assert(!*vpcidev);
-    *vpcidev = container_of(d, QVirtioPCIDevice, vdev);
-}
-
 #define CONFIG_BASE(dev) (VIRTIO_PCI_CONFIG_OFF((dev)->pdev->msix_enabled))
 
 static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off)
@@ -317,48 +265,6 @@ const QVirtioBus qvirtio_pci = {
     .virtqueue_kick = qvirtio_pci_virtqueue_kick,
 };
 
-/* TODO: delete this once qgraph is completed */
-static void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,
-                bool has_slot, int slot,
-                void (*func)(QVirtioDevice *d, void *data), void *data)
-{
-    QVirtioPCIForeachData d = { .func = func,
-                                .device_type = device_type,
-                                .has_slot = has_slot,
-                                .slot = slot,
-                                .user_data = data };
-
-    qpci_device_foreach(bus, PCI_VENDOR_ID_REDHAT_QUMRANET, -1,
-                        qvirtio_pci_foreach_callback, &d);
-}
-
-QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
-{
-    QVirtioPCIDevice *dev = NULL;
-
-    qvirtio_pci_foreach(bus, device_type, false, 0,
-                        qvirtio_pci_assign_device, &dev);
-
-    if (dev) {
-        dev->vdev.bus = &qvirtio_pci;
-    }
-
-    return dev;
-}
-
-QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus,
-                                               uint16_t device_type, int slot)
-{
-    QVirtioPCIDevice *dev = NULL;
-
-    qvirtio_pci_foreach(bus, device_type, true, slot,
-                        qvirtio_pci_assign_device, &dev);
-
-    dev->vdev.bus = &qvirtio_pci;
-
-    return dev;
-}
-
 void qvirtio_pci_device_enable(QVirtioPCIDevice *d)
 {
     qpci_device_enable(d->pdev);
@@ -445,7 +351,7 @@ void qvirtio_pci_destructor(QOSGraphObject *obj)
 {
     QVirtioPCIDevice *dev = (QVirtioPCIDevice *)obj;
     qvirtio_pci_device_disable(dev);
-    qvirtio_pci_device_free(dev);
+    g_free(dev->pdev);
 }
 
 void qvirtio_pci_start_hw(QOSGraphObject *obj)
@@ -455,6 +361,22 @@ void qvirtio_pci_start_hw(QOSGraphObject *obj)
     qvirtio_start_device(&dev->vdev);
 }
 
+static void qvirtio_pci_init_from_pcidev(QVirtioPCIDevice *dev, QPCIDevice *pci_dev)
+{
+    dev->pdev = pci_dev;
+    dev->vdev.device_type = qpci_config_readw(pci_dev, PCI_SUBSYSTEM_ID);
+
+    dev->config_msix_entry = -1;
+
+    dev->vdev.bus = &qvirtio_pci;
+    dev->vdev.big_endian = qvirtio_pci_is_big_endian(dev);
+
+    /* each virtio-xxx-pci device should override at least this function */
+    dev->obj.get_driver = NULL;
+    dev->obj.start_hw = qvirtio_pci_start_hw;
+    dev->obj.destructor = qvirtio_pci_destructor;
+}
+
 void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr)
 {
     QPCIDevice *pci_dev = qpci_device_find(bus, addr->devfn);
diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h
index 5631352..728b471 100644
--- a/tests/libqos/virtio-pci.h
+++ b/tests/libqos/virtio-pci.h
@@ -35,10 +35,6 @@ extern const QVirtioBus qvirtio_pci;
 
 void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr);
 QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr);
-QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type);
-QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus,
-                                               uint16_t device_type, int slot);
-void qvirtio_pci_device_free(QVirtioPCIDevice *dev);
 
 /* virtio-pci object functions available for subclasses that
  * override the original start_hw and destroy
-- 
1.8.3.1

  parent reply	other threads:[~2019-03-07 17:30 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07 17:29 [Qemu-devel] [PULL 00/57] qgraph merge Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 01/57] chardev-socket: do not blindly reset handlers when switching GMainContext Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 02/57] tests/libqos: introduce virtio_start_device Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 03/57] tests/libqos: rename qpci_init_pc and qpci_init_spapr functions Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 04/57] tests/libqos: embed allocators instead of malloc-ing them separately Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 05/57] tests: qgraph API for the qtest driver framework Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 06/57] tests/libqos: pci-pc driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 08/57] tests/libqos: sdhci driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 09/57] tests/libqos: arm/raspi2 machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 10/57] tests/libqos: arm/smdkc210 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 11/57] tests/libqos: arm/sabrelite " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 12/57] tests/libqos: arm/xilinx-zynq-a9 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 13/57] tests/libqos: aarch64/xlnx-zcu102 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 14/57] qos-test: sdhci test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 15/57] tests/qgraph: add generic PCI testcases Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 16/57] tests/libqos: pci-spapr driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 17/57] tests/qgraph: ppc64/pseries machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 18/57] tests/libqos: has_buggy_msi flag Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 19/57] tests/libqos: e1000e driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 20/57] qos-test: e1000e test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 21/57] tests/libqos: virtio-pci driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 22/57] tests/libqos: remove global_qtest from virtio endianness checks Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 23/57] tests/libqos: virtio-mmio driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 24/57] tests/libqos: arm/virt machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 25/57] tests/qgraph: add generic virtio testcases Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 26/57] tests/libqos: virtio-serial driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 27/57] qos-test: virtio-console and virtio-serial test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 28/57] tests/libqos: virtio-9p driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 29/57] qos-test: virtio-9p test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 30/57] tests/libqos: virtio-balloon driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 31/57] tests/qgraph: remove virtio-balloon-test Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 32/57] tests/libqos: virtio-rng driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 33/57] qos-test: virtio-rng test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 34/57] tests/libqos: virtio-blk driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 35/57] qos-test: virtio-blk test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 36/57] tests/libqos: virtio-net driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 37/57] qos-test: virtio-net test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-net Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 39/57] vhost-user-test: always use 256 MiB of guest memory Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 40/57] qos-test: vhost-user test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 41/57] tests/libqos: virtio-scsi driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 42/57] qos-test: virtio-scsi test node Paolo Bonzini
2019-03-07 17:29 ` Paolo Bonzini [this message]
2019-03-07 17:29 ` [Qemu-devel] [PULL 44/57] tests: move virtio entirely to qos-test Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 45/57] qos-test: ac97 test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 46/57] qos-test: tpci200 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 47/57] qos-test: ipoctal232 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 48/57] qos-test: ne2k_pci " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 49/57] qos-test: nvme " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 50/57] qos-test: pcnet " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 51/57] qos-test: spapr-phb " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 52/57] qos-test: usb-hcd-ohci " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 53/57] qos-test: vmxnet3 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 54/57] qos-test: es1370 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 55/57] qos-test: eepro100 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 56/57] qos-test: e1000 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 57/57] qos-test: megasas " Paolo Bonzini
2019-03-08 15:16 ` [Qemu-devel] [PULL 00/57] qgraph merge Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1551979804-6060-44-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=lviver@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).