@@ -1546,6 +1546,17 @@ void vhost_dev_set_config_notifier(struct vhost_dev *hdev,
hdev->config_ops = ops;
}
+int vhost_dev_set_virtio_status(struct vhost_dev *hdev, uint8_t status)
+{
+ const VhostOps *vhost_ops = hdev->vhost_ops;
+
+ if (vhost_ops && vhost_ops->vhost_set_virtio_status) {
+ return vhost_ops->vhost_set_virtio_status(hdev, status);
+ }
+
+ return 0;
+}
+
/* Host notifiers must be enabled at this point. */
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
{
@@ -94,6 +94,8 @@ typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *data,
uint32_t flags);
typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config,
uint32_t config_len);
+typedef int (*vhost_set_virtio_status_op)(struct vhost_dev *dev,
+ uint8_t status);
typedef struct VhostOps {
VhostBackendType backend_type;
@@ -130,6 +132,7 @@ typedef struct VhostOps {
vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg;
vhost_get_config_op vhost_get_config;
vhost_set_config_op vhost_set_config;
+ vhost_set_virtio_status_op vhost_set_virtio_status;
} VhostOps;
extern const VhostOps user_ops;
@@ -121,4 +121,7 @@ int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data,
*/
void vhost_dev_set_config_notifier(struct vhost_dev *dev,
const VhostDevConfigOps *ops);
+
+int vhost_dev_set_virtio_status(struct vhost_dev *hdev, uint8_t status);
+
#endif
This patch adds a function to notify the vhost backend with virtio device status updates. Suggested-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> --- hw/virtio/vhost.c | 11 +++++++++++ include/hw/virtio/vhost-backend.h | 3 +++ include/hw/virtio/vhost.h | 3 +++ 3 files changed, 17 insertions(+)