[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] vhost-user-blk: reset the device if supported
From: |
Yang Zhong |
Subject: |
[PATCH] vhost-user-blk: reset the device if supported |
Date: |
Fri, 10 Jan 2020 20:22:03 +0800 |
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 <address@hidden>
---
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
- [PATCH] vhost-user-blk: reset the device if supported,
Yang Zhong <=