All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com, "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH for-3.2 09/11] libvhost-user: add vu_queue_unpop()
Date: Mon, 26 Nov 2018 16:42:48 +0400	[thread overview]
Message-ID: <20181126124250.29985-10-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20181126124250.29985-1-marcandre.lureau@redhat.com>

vhost-user-input will make use of this function to undo some queue pop
in case the virtio queue does not have enough room.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 contrib/libvhost-user/libvhost-user.h | 14 ++++++++++++++
 contrib/libvhost-user/libvhost-user.c | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h
index a4afbc3a46..6c7cbe14b6 100644
--- a/contrib/libvhost-user/libvhost-user.h
+++ b/contrib/libvhost-user/libvhost-user.h
@@ -459,6 +459,20 @@ void vu_queue_notify(VuDev *dev, VuVirtq *vq);
  */
 void *vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz);
 
+
+/**
+ * vu_queue_unpop:
+ * @dev: a VuDev context
+ * @vq: a VuVirtq queue
+ * @elem: The #VuVirtqElement
+ * @len: number of bytes written
+ *
+ * Pretend the most recent element wasn't popped from the virtqueue.  The next
+ * call to vu_queue_pop() will refetch the element.
+ */
+void vu_queue_unpop(VuDev *dev, VuVirtq *vq, VuVirtqElement *elem,
+                    size_t len);
+
 /**
  * vu_queue_rewind:
  * @dev: a VuDev context
diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index 41470daf57..e011a6ed1c 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -1966,6 +1966,22 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz)
     return elem;
 }
 
+static void
+vu_queue_detach_element(VuDev *dev, VuVirtq *vq, VuVirtqElement *elem,
+                        size_t len)
+{
+    vq->inuse--;
+    /* unmap, when DMA support is added */
+}
+
+void
+vu_queue_unpop(VuDev *dev, VuVirtq *vq, VuVirtqElement *elem,
+               size_t len)
+{
+    vq->last_avail_idx--;
+    vu_queue_detach_element(dev, vq, elem, len);
+}
+
 bool
 vu_queue_rewind(VuDev *dev, VuVirtq *vq, unsigned int num)
 {
-- 
2.20.0.rc1

  parent reply	other threads:[~2018-11-26 12:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 12:42 [Qemu-devel] [PATCH for-3.2 00/11] vhost-user-backend & vhost-user-input Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 01/11] vhost-user: define conventions for vhost-user backends Marc-André Lureau
2018-11-26 20:57   ` Eric Blake
2018-12-10 14:29   ` Gerd Hoffmann
2018-12-10 18:36     ` Marc-André Lureau
2018-12-10 23:37       ` Michael S. Tsirkin
2018-12-11  7:42         ` Hoffmann, Gerd
2018-12-11  9:29           ` Daniel P. Berrangé
2018-12-11 18:56             ` Michael S. Tsirkin
2018-12-18 18:35               ` Marc-André Lureau
2018-12-18 23:20                 ` Michael S. Tsirkin
2018-12-19  8:01                   ` Marc-André Lureau
2018-12-19 15:42                     ` Michael S. Tsirkin
2018-12-20 12:40                       ` Marc-André Lureau
2018-12-20 16:33                         ` Michael S. Tsirkin
2019-01-08 13:23                           ` Marc-André Lureau
2019-01-09  8:45                             ` Hoffmann, Gerd
2019-01-09 20:53                               ` Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 02/11] vhost-user: simplify vhost_user_init/vhost_user_cleanup Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 03/11] libvhost-user: exit by default on VHOST_USER_NONE Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 04/11] vhost-user: wrap some read/write with retry handling Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 05/11] Add vhost-user-backend Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 06/11] vhost-user: split vhost_user_read() Marc-André Lureau
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 07/11] vhost-user: add vhost_user_input_get_config() Marc-André Lureau
2018-12-10 14:26   ` Gerd Hoffmann
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 08/11] libvhost-user-glib: export vug_source_new() Marc-André Lureau
2018-11-26 12:42 ` Marc-André Lureau [this message]
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 10/11] Add vhost-user-input-pci Marc-André Lureau
2018-12-10 14:26   ` Gerd Hoffmann
2018-11-26 12:42 ` [Qemu-devel] [PATCH for-3.2 11/11] contrib: add vhost-user-input Marc-André Lureau

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=20181126124250.29985-10-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.