[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] vhost: add vhost_dev_reset()
From: |
Michael Qiu |
Subject: |
[PATCH 2/3] vhost: add vhost_dev_reset() |
Date: |
Fri, 1 Apr 2022 07:06:12 -0400 |
Not all vhost-user backends support ops->vhost_reset_device(). Instead
of adding backend check and call backend ops directly, it's better to
implement a function in vhost framework, so that it could hide vhost_ops
details.
SIgned-off-by: Michael Qiu <qiudayu@archeros.com>
---
hw/virtio/vhost.c | 14 ++++++++++++++
include/hw/virtio/vhost.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b643f42..26667ae 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1854,3 +1854,17 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
return -ENOSYS;
}
+
+int vhost_dev_reset(struct vhost_dev *hdev)
+{
+ int ret = 0;
+
+ /* should only be called after backend is connected */
+ assert(hdev->vhost_ops);
+
+ if (hdev->vhost_ops->vhost_reset_device) {
+ ret = hdev->vhost_ops->vhost_reset_device(hdev);
+ }
+
+ return ret;
+}
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 58a73e7..b8b7c20 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -114,6 +114,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
void vhost_dev_cleanup(struct vhost_dev *hdev);
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
+int vhost_dev_reset(struct vhost_dev *hdev);
int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
--
1.8.3.1
- [PATCH 0/3] Refactor vhost device reset, Michael Qiu, 2022/04/01
- [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Michael Qiu, 2022/04/01
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Si-Wei Liu, 2022/04/01
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Jason Wang, 2022/04/01
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Michael Qiu, 2022/04/02
- Message not available
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Jason Wang, 2022/04/07
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Michael Qiu, 2022/04/08
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Si-Wei Liu, 2022/04/08
- Re: [PATCH 1/3] vhost: Refactor vhost_reset_device() in VhostOps, Jason Wang, 2022/04/11
[PATCH 2/3] vhost: add vhost_dev_reset(),
Michael Qiu <=
[PATCH 3/3 v5] vdpa: reset the backend device in the end of vhost_net_stop(), Michael Qiu, 2022/04/01