@@ -744,6 +744,7 @@ static void vhost_iommu_region_del(MemoryListener *listener,
}
}
+
static int vhost_virtqueue_set_addr(struct vhost_dev *dev,
struct vhost_virtqueue *vq,
unsigned idx, bool enable_log)
@@ -1661,6 +1662,11 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
}
}
+ r = vhost_set_start(hdev, true);
+ if (r) {
+ goto fail_log;
+ }
+
if (vhost_dev_has_iommu(hdev)) {
hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true);
@@ -1697,6 +1703,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
/* should only be called after backend is connected */
assert(hdev->vhost_ops);
+ vhost_set_start(hdev, false);
+
for (i = 0; i < hdev->nvqs; ++i) {
vhost_virtqueue_stop(hdev,
vdev,
@@ -1722,3 +1730,12 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
return -1;
}
+
+int vhost_set_start(struct vhost_dev *hdev, bool started)
+{
+
+ if (hdev->vhost_ops->vhost_dev_start) {
+ hdev->vhost_ops->vhost_dev_start(hdev, started);
+ }
+ return 0;
+}
@@ -92,6 +92,7 @@ struct vhost_dev {
const VhostDevConfigOps *config_ops;
};
+
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
VhostBackendType backend_type,
uint32_t busyloop_timeout);
@@ -137,4 +138,5 @@ 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,
struct vhost_inflight *inflight);
+int vhost_set_start(struct vhost_dev *dev, bool started);
#endif
use the vhost_dev_start callback to send the status to backend Signed-off-by: Cindy Lu <lulu@redhat.com> --- hw/virtio/vhost.c | 17 +++++++++++++++++ include/hw/virtio/vhost.h | 2 ++ 2 files changed, 19 insertions(+)