vhost net backend needs to be notified when
frontend status changes. Add a callback,
similar to set_features.

Signed-off-by: Michael S. Tsirkin <m...@redhat.com>
---
 hw/s390-virtio-bus.c |    7 ++++++-
 hw/syborg_virtio.c   |    2 ++
 hw/virtio-pci.c      |    9 ++++++++-
 hw/virtio.h          |    1 +
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index fa0a74f..d7e3ae1 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -241,8 +241,13 @@ void s390_virtio_device_update_status(VirtIOS390Device 
*dev)
 {
     VirtIODevice *vdev = dev->vdev;
     uint32_t features;
+    uint8_t status;
 
-    vdev->status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS);
+    status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS);
+    if (vdev->set_status) {
+        vdev->set_status(vdev, status);
+    }
+    vdev->status = status;
 
     /* Update guest supported feature bitmap */
 
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index 65239a0..7a9e584 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -149,6 +149,8 @@ static void syborg_virtio_writel(void *opaque, 
target_phys_addr_t offset,
         virtio_queue_notify(vdev, value);
         break;
     case SYBORG_VIRTIO_STATUS:
+        if (vdev->set_status)
+            vdev->set_status(vdev, value & 0xFF);
         vdev->status = value & 0xFF;
         if (vdev->status == 0)
             virtio_reset(vdev);
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index bcd40f7..006ff38 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -206,6 +206,9 @@ static void virtio_ioport_write(void *opaque, uint32_t 
addr, uint32_t val)
         virtio_queue_notify(vdev, val);
         break;
     case VIRTIO_PCI_STATUS:
+        if (vdev->set_status) {
+            vdev->set_status(vdev, val & 0xFF);
+        }
         vdev->status = val & 0xFF;
         if (vdev->status == 0) {
             virtio_reset(proxy->vdev);
@@ -377,7 +380,11 @@ static void virtio_write_config(PCIDevice *pci_dev, 
uint32_t address,
 
     if (PCI_COMMAND == address) {
         if (!(val & PCI_COMMAND_MASTER)) {
-            proxy->vdev->status &= ~VIRTIO_CONFIG_S_DRIVER_OK;
+            uint8_t status = proxy->vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK;
+            if (proxy->vdev->set_status) {
+                proxy->vdev->set_status(proxy->vdev, status);
+            }
+            proxy->vdev->status = status;
         }
     }
 
diff --git a/hw/virtio.h b/hw/virtio.h
index 2ebf2dd..e12e8e3 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -115,6 +115,7 @@ struct VirtIODevice
     void (*get_config)(VirtIODevice *vdev, uint8_t *config);
     void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
     void (*reset)(VirtIODevice *vdev);
+    void (*set_status)(VirtIODevice *vdev, uint8_t val);
     VirtQueue *vq;
     const VirtIOBindings *binding;
     void *binding_opaque;
-- 
1.7.0.18.g0d53a5



Reply via email to