All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergio Lopez <slp@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 5/7] libqos: expose common virtqueue setup/cleanup functions
Date: Fri, 11 Oct 2019 14:23:58 +0200	[thread overview]
Message-ID: <87y2xrbhcx.fsf@redhat.com> (raw)
In-Reply-To: <20191011085611.4194-6-stefanha@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4242 bytes --]


Stefan Hajnoczi <stefanha@redhat.com> writes:

> The VIRTIO 1.0 code will need to perform additional steps but it will
> reuse the common virtqueue setup/cleanup code.  Make these functions
> public.
>
> Make sure to invoke callbacks via QVirtioBus instead of directly calling
> the virtio-pci Legacy versions of these functions.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  tests/libqos/virtio-pci.h |  8 ++++++++
>  tests/libqos/virtio-pci.c | 19 ++++++++++---------
>  2 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h
> index 443e53affc..b620c30451 100644
> --- a/tests/libqos/virtio-pci.h
> +++ b/tests/libqos/virtio-pci.h
> @@ -63,4 +63,12 @@ void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
>                                          QGuestAllocator *alloc, uint16_t entry);
>  void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
>                                          QGuestAllocator *alloc, uint16_t entry);
> +
> +/* Used by Legacy and Modern virtio-pci code */
> +QVirtQueue *qvirtio_pci_virtqueue_setup_common(QVirtioDevice *d,
> +                                               QGuestAllocator *alloc,
> +                                               uint16_t index);
> +void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue *vq,
> +                                          QGuestAllocator *alloc);
> +
>  #endif
> diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
> index 651f6dbfc6..3fb4af4016 100644
> --- a/tests/libqos/virtio-pci.c
> +++ b/tests/libqos/virtio-pci.c
> @@ -198,8 +198,9 @@ static void qvirtio_pci_set_queue_address(QVirtioDevice *d, QVirtQueue *vq)
>      qpci_io_writel(dev->pdev, dev->bar, VIRTIO_PCI_QUEUE_PFN, pfn);
>  }
>  
> -static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
> -                                        QGuestAllocator *alloc, uint16_t index)
> +QVirtQueue *qvirtio_pci_virtqueue_setup_common(QVirtioDevice *d,
> +                                               QGuestAllocator *alloc,
> +                                               uint16_t index)
>  {
>      uint32_t feat;
>      uint64_t addr;
> @@ -207,11 +208,11 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
>      QVirtioPCIDevice *qvpcidev = container_of(d, QVirtioPCIDevice, vdev);
>  
>      vqpci = g_malloc0(sizeof(*vqpci));
> -    feat = qvirtio_pci_get_guest_features(d);
> +    feat = d->bus->get_guest_features(d);
>  
> -    qvirtio_pci_queue_select(d, index);
> +    d->bus->queue_select(d, index);
>      vqpci->vq.index = index;
> -    vqpci->vq.size = qvirtio_pci_get_queue_size(d);
> +    vqpci->vq.size = d->bus->get_queue_size(d);
>      vqpci->vq.free_head = 0;
>      vqpci->vq.num_free = vqpci->vq.size;
>      vqpci->vq.align = VIRTIO_PCI_VRING_ALIGN;
> @@ -231,12 +232,12 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
>      addr = guest_alloc(alloc, qvring_size(vqpci->vq.size,
>                                            VIRTIO_PCI_VRING_ALIGN));
>      qvring_init(qvpcidev->pdev->bus->qts, alloc, &vqpci->vq, addr);
> -    qvirtio_pci_set_queue_address(d, &vqpci->vq);
> +    d->bus->set_queue_address(d, &vqpci->vq);
>  
>      return &vqpci->vq;
>  }
>  
> -static void qvirtio_pci_virtqueue_cleanup(QVirtQueue *vq,
> +void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue *vq,
>                                            QGuestAllocator *alloc)
>  {
>      QVirtQueuePCI *vqpci = container_of(vq, QVirtQueuePCI, vq);
> @@ -266,8 +267,8 @@ static const QVirtioBus qvirtio_pci_legacy = {
>      .queue_select = qvirtio_pci_queue_select,
>      .get_queue_size = qvirtio_pci_get_queue_size,
>      .set_queue_address = qvirtio_pci_set_queue_address,
> -    .virtqueue_setup = qvirtio_pci_virtqueue_setup,
> -    .virtqueue_cleanup = qvirtio_pci_virtqueue_cleanup,
> +    .virtqueue_setup = qvirtio_pci_virtqueue_setup_common,
> +    .virtqueue_cleanup = qvirtio_pci_virtqueue_cleanup_common,
>      .virtqueue_kick = qvirtio_pci_virtqueue_kick,
>  };

Reviewed-by: Sergio Lopez <slp@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-10-11 12:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  8:56 [PATCH v2 0/7] libqos: add VIRTIO PCI 1.0 support Stefan Hajnoczi
2019-10-11  8:56 ` [PATCH v2 1/7] libqos: extract Legacy virtio-pci.c code Stefan Hajnoczi
2019-10-11 12:20   ` Sergio Lopez
2019-10-16 12:04   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 2/7] libqos: add iteration support to qpci_find_capability() Stefan Hajnoczi
2019-10-11 12:22   ` Sergio Lopez
2019-10-16 12:12   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 3/7] libqos: pass full QVirtQueue to set_queue_address() Stefan Hajnoczi
2019-10-11 12:22   ` Sergio Lopez
2019-10-16 12:15   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 4/7] libqos: add MSI-X callbacks to QVirtioPCIDevice Stefan Hajnoczi
2019-10-11 12:23   ` Sergio Lopez
2019-10-17 13:25   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 5/7] libqos: expose common virtqueue setup/cleanup functions Stefan Hajnoczi
2019-10-11 12:23   ` Sergio Lopez [this message]
2019-10-17 14:13   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 6/7] libqos: make the virtio-pci BAR index configurable Stefan Hajnoczi
2019-10-11 12:06   ` Sergio Lopez
2019-10-14  9:52     ` Stefan Hajnoczi
2019-10-14 10:46       ` Sergio Lopez
2019-10-17 14:27   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 7/7] libqos: add VIRTIO PCI 1.0 support Stefan Hajnoczi
2019-10-11 12:24   ` Sergio Lopez
2019-10-17 14:52   ` Thomas Huth
2019-10-17 16:07     ` Stefan Hajnoczi
2019-10-17 16:18       ` Thomas Huth
2019-10-18  6:48         ` Thomas Huth
2019-10-18  6:51           ` Thomas Huth
2019-10-18 10:05           ` Stefan Hajnoczi

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=87y2xrbhcx.fsf@redhat.com \
    --to=slp@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.