All of lore.kernel.org
 help / color / mirror / Atom feed
From: elohimes@gmail.com
To: mst@redhat.com, stefanha@gmail.com, marcandre.lureau@redhat.com,
	berrange@redhat.com, jasowang@redhat.com,
	maxime.coquelin@redhat.com, yury-kotov@yandex-team.ru,
	wrfsh@yandex-team.ru
Cc: qemu-devel@nongnu.org, zhangyu31@baidu.com, chaiwen@baidu.com,
	nixun@baidu.com, lilin24@baidu.com,
	Xie Yongji <xieyongji@baidu.com>
Subject: [Qemu-devel] [PATCH v5 4/6] vhost-user-blk: Add support to get/set inflight buffer
Date: Tue, 22 Jan 2019 16:31:50 +0800	[thread overview]
Message-ID: <20190122083152.10705-5-xieyongji@baidu.com> (raw)
In-Reply-To: <20190122083152.10705-1-xieyongji@baidu.com>

From: Xie Yongji <xieyongji@baidu.com>

This patch adds support for vhost-user-blk device to get/set
inflight buffer from/to backend.

Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
---
 hw/block/vhost-user-blk.c          | 26 ++++++++++++++++++++++++++
 include/hw/virtio/vhost-user-blk.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index c3af28fad4..1f899ac1c0 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -126,6 +126,13 @@ static void vhost_user_blk_start(VirtIODevice *vdev)
     }
 
     s->dev.acked_features = vdev->guest_features;
+
+    ret = vhost_dev_set_inflight(&s->dev, s->inflight);
+    if (ret < 0) {
+        error_report("Error set inflight: %d", -ret);
+        goto err_guest_notifiers;
+    }
+
     ret = vhost_dev_start(&s->dev, vdev);
     if (ret < 0) {
         error_report("Error starting vhost: %d", -ret);
@@ -245,6 +252,13 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
     }
 }
 
+static void vhost_user_blk_reset(VirtIODevice *vdev)
+{
+    VHostUserBlk *s = VHOST_USER_BLK(vdev);
+
+    vhost_dev_reset_inflight(s->inflight);
+}
+
 static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -285,6 +299,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
                          vhost_user_blk_handle_output);
     }
 
+    s->inflight = g_new0(struct vhost_inflight, 1);
+
     s->dev.nvqs = s->num_queues;
     s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
     s->dev.vq_index = 0;
@@ -311,12 +327,19 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
         s->blkcfg.num_queues = s->num_queues;
     }
 
+    ret = vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight);
+    if (ret < 0) {
+        error_setg(errp, "vhost-user-blk: get inflight failed");
+        goto vhost_err;
+    }
+
     return;
 
 vhost_err:
     vhost_dev_cleanup(&s->dev);
 virtio_err:
     g_free(vqs);
+    g_free(s->inflight);
     virtio_cleanup(vdev);
 
     vhost_user_cleanup(user);
@@ -332,7 +355,9 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
 
     vhost_user_blk_set_status(vdev, 0);
     vhost_dev_cleanup(&s->dev);
+    vhost_dev_free_inflight(s->inflight);
     g_free(vqs);
+    g_free(s->inflight);
     virtio_cleanup(vdev);
 
     if (s->vhost_user) {
@@ -382,6 +407,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data)
     vdc->set_config = vhost_user_blk_set_config;
     vdc->get_features = vhost_user_blk_get_features;
     vdc->set_status = vhost_user_blk_set_status;
+    vdc->reset = vhost_user_blk_reset;
 }
 
 static const TypeInfo vhost_user_blk_info = {
diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h
index d52944aeeb..445516604a 100644
--- a/include/hw/virtio/vhost-user-blk.h
+++ b/include/hw/virtio/vhost-user-blk.h
@@ -36,6 +36,7 @@ typedef struct VHostUserBlk {
     uint32_t queue_size;
     uint32_t config_wce;
     struct vhost_dev dev;
+    struct vhost_inflight *inflight;
     VhostUserState *vhost_user;
 } VHostUserBlk;
 
-- 
2.17.1

  parent reply	other threads:[~2019-01-22  8:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22  8:31 [Qemu-devel] [PATCH v5 0/6] vhost-user-blk: Add support for backend reconnecting elohimes
2019-01-22  8:31 ` [Qemu-devel] [PATCH v5 1/6] vhost-user: Support transferring inflight buffer between qemu and backend elohimes
2019-01-29  4:11   ` Stefan Hajnoczi
2019-01-29  4:26     ` Michael S. Tsirkin
2019-01-29  6:15       ` Yongji Xie
2019-01-29 14:15         ` Michael S. Tsirkin
2019-01-30  2:07           ` Yongji Xie
2019-01-30  2:30             ` Michael S. Tsirkin
2019-01-30  3:49               ` Yongji Xie
2019-01-30  4:07                 ` Michael S. Tsirkin
2019-01-30  4:11                   ` Yongji Xie
2019-01-22  8:31 ` [Qemu-devel] [PATCH v5 2/6] libvhost-user: Introduce vu_queue_map_desc() elohimes
2019-01-22  8:31 ` [Qemu-devel] [PATCH v5 3/6] libvhost-user: Support tracking inflight I/O in shared memory elohimes
2019-01-30  2:31   ` Jason Wang
2019-01-30  3:14     ` Michael S. Tsirkin
2019-01-30  9:52       ` Jason Wang
2019-01-30  3:58     ` Yongji Xie
2019-02-01  2:26       ` Jason Wang
2019-01-30  5:48     ` Yongji Xie
2019-02-01  2:27       ` Jason Wang
2019-02-05  1:37         ` Yongji Xie
2019-01-22  8:31 ` elohimes [this message]
2019-01-22  8:31 ` [Qemu-devel] [PATCH v5 5/6] vhost-user-blk: Add support to reconnect backend elohimes
2019-01-22  8:31 ` [Qemu-devel] [PATCH v5 6/6] contrib/vhost-user-blk: enable inflight I/O tracking elohimes
2019-01-30  2:29 ` [Qemu-devel] [PATCH v5 0/6] vhost-user-blk: Add support for backend reconnecting Jason Wang
2019-01-30  3:40   ` Michael S. Tsirkin

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=20190122083152.10705-5-xieyongji@baidu.com \
    --to=elohimes@gmail.com \
    --cc=berrange@redhat.com \
    --cc=chaiwen@baidu.com \
    --cc=jasowang@redhat.com \
    --cc=lilin24@baidu.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mst@redhat.com \
    --cc=nixun@baidu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=wrfsh@yandex-team.ru \
    --cc=xieyongji@baidu.com \
    --cc=yury-kotov@yandex-team.ru \
    --cc=zhangyu31@baidu.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.