From: Yang Zhong <yang.zhong@intel.com>
To: qemu-devel@nongnu.org
Cc: yang.zhong@intel.com, pbonzini@redhat.com, stefanha@redhat.com,
mst@redhat.com
Subject: [PATCH] vhost-user-blk: reset the device if supported
Date: Fri, 10 Jan 2020 20:22:03 +0800 [thread overview]
Message-ID: <20200110122203.6735-1-yang.zhong@intel.com> (raw)
As the vhost-user-scsi did in f04724, if the vhost-user-blk backend
supports the VHOST_USER_F_RESET_DEVICE protocol feature, then the
device can be reset when requested.
If this feature is not supported, this reset will directly return.
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
hw/block/vhost-user-blk.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 63da9bb619..16ddc9b70c 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -50,6 +50,10 @@ static const int user_feature_bits[] = {
VHOST_INVALID_FEATURE_BIT
};
+enum VhostUserProtocolFeature {
+ VHOST_USER_PROTOCOL_F_RESET_DEVICE = 13,
+};
+
static void vhost_user_blk_update_config(VirtIODevice *vdev, uint8_t *config)
{
VHostUserBlk *s = VHOST_USER_BLK(vdev);
@@ -290,8 +294,23 @@ 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);
+ struct vhost_dev *dev = &s->dev;
vhost_dev_free_inflight(s->inflight);
+
+ /*
+ * Historically, reset was not implemented so only reset devices
+ * that are expecting it.
+ */
+ if (!virtio_has_feature(dev->protocol_features,
+ VHOST_USER_PROTOCOL_F_RESET_DEVICE)) {
+ return;
+ }
+
+ if (dev->vhost_ops->vhost_reset_device) {
+ dev->vhost_ops->vhost_reset_device(dev);
+ }
+
}
static int vhost_user_blk_connect(DeviceState *dev)
--
2.17.1
next reply other threads:[~2020-01-10 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 12:22 Yang Zhong [this message]
2020-01-14 16:33 ` [PATCH] vhost-user-blk: reset the device if supported 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=20200110122203.6735-1-yang.zhong@intel.com \
--to=yang.zhong@intel.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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).