From: Jin Yu <jin.yu@intel.com>
To: raphael.norwitz@nutanix.com, mst@redhat.com, kwolf@redhat.com,
mreitz@redhat.com
Cc: Jin Yu <jin.yu@intel.com>, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: [PATCH v2] vhost-blk: set features before setting inflight feature
Date: Tue, 3 Nov 2020 20:36:17 +0800 [thread overview]
Message-ID: <20201103123617.28256-1-jin.yu@intel.com> (raw)
In-Reply-To: <20200910134851.7817-1-jin.yu@intel.com>
Virtqueue has split and packed, so before setting inflight,
you need to inform the back-end virtqueue format.
Signed-off-by: Jin Yu <jin.yu@intel.com>
Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
v2:
* Fixed the segfault.
---
hw/block/vhost-user-blk.c | 6 ++++++
hw/virtio/vhost.c | 20 ++++++++++++++++++++
include/hw/virtio/vhost.h | 1 +
3 files changed, 27 insertions(+)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 39aec42dae..db079a89c0 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev)
s->dev.acked_features = vdev->guest_features;
+ ret = vhost_dev_prepare_inflight(&s->dev, vdev);
+ if (ret < 0) {
+ error_report("Error set inflight format: %d", -ret);
+ goto err_guest_notifiers;
+ }
+
if (!s->inflight->addr) {
ret = vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight);
if (ret < 0) {
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1a1384e7a6..6ffbfbfb9e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1616,6 +1616,26 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f)
return 0;
}
+int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev)
+{
+ int r;
+
+ if (hdev->vhost_ops->vhost_get_inflight_fd == NULL ||
+ hdev->vhost_ops->vhost_set_inflight_fd == NULL) {
+ return 0;
+ }
+
+ hdev->vdev = vdev;
+
+ r = vhost_dev_set_features(hdev, hdev->log_enabled);
+ if (r < 0) {
+ VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed");
+ return r;
+ }
+
+ return 0;
+}
+
int vhost_dev_set_inflight(struct vhost_dev *dev,
struct vhost_inflight *inflight)
{
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 767a95ec0b..d25f0947f7 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *inflight);
void vhost_dev_free_inflight(struct vhost_inflight *inflight);
void vhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f);
int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f);
+int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev);
int vhost_dev_set_inflight(struct vhost_dev *dev,
struct vhost_inflight *inflight);
int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,
--
2.17.2
prev parent reply other threads:[~2020-11-03 5:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 13:48 [PATCH] vhost-blk: set features before setting inflight feature Jin Yu
2020-09-15 1:25 ` Raphael Norwitz
2020-09-15 2:52 ` Yu, Jin
2020-09-21 23:03 ` Raphael Norwitz
2020-09-22 7:02 ` Yu, Jin
2020-10-02 3:02 ` Raphael Norwitz
2020-11-03 12:36 ` Jin Yu [this message]
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=20201103123617.28256-1-jin.yu@intel.com \
--to=jin.yu@intel.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=raphael.norwitz@nutanix.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.