peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame qemu-virtio-add-status-change-callback.patch

Justin M. Forbes 272dfe
vhost net backend needs to be notified when
Justin M. Forbes 272dfe
frontend status changes. Add a callback.
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes 272dfe
---
Justin M. Forbes 272dfe
 hw/s390-virtio-bus.c |    3 +++
Justin M. Forbes 272dfe
 hw/syborg_virtio.c   |    2 ++
Justin M. Forbes 272dfe
 hw/virtio-pci.c      |    6 ++++++
Justin M. Forbes 272dfe
 hw/virtio.h          |    1 +
Justin M. Forbes 272dfe
 4 files changed, 12 insertions(+), 0 deletions(-)
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
Justin M. Forbes 272dfe
index 980e7eb..f45b67d 100644
Justin M. Forbes 272dfe
--- a/hw/s390-virtio-bus.c
Justin M. Forbes 272dfe
+++ b/hw/s390-virtio-bus.c
Justin M. Forbes 272dfe
@@ -243,6 +243,9 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev)
Justin M. Forbes 272dfe
     uint32_t features;
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
     vdev->status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS);
Justin M. Forbes 272dfe
+    if (vdev->set_status) {
Justin M. Forbes 272dfe
+        vdev->set_status(vdev);
Justin M. Forbes 272dfe
+    }
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
     /* Update guest supported feature bitmap */
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
Justin M. Forbes 272dfe
index 65239a0..19f6473 100644
Justin M. Forbes 272dfe
--- a/hw/syborg_virtio.c
Justin M. Forbes 272dfe
+++ b/hw/syborg_virtio.c
Justin M. Forbes 272dfe
@@ -152,6 +152,8 @@ static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset,
Justin M. Forbes 272dfe
         vdev->status = value & 0xFF;
Justin M. Forbes 272dfe
         if (vdev->status == 0)
Justin M. Forbes 272dfe
             virtio_reset(vdev);
Justin M. Forbes 272dfe
+        if (vdev->set_status)
Justin M. Forbes 272dfe
+            vdev->set_status(vdev);
Justin M. Forbes 272dfe
         break;
Justin M. Forbes 272dfe
     case SYBORG_VIRTIO_INT_ENABLE:
Justin M. Forbes 272dfe
         s->int_enable = value;
Justin M. Forbes 272dfe
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
Justin M. Forbes 272dfe
index 573c98a..05898c8 100644
Justin M. Forbes 272dfe
--- a/hw/virtio-pci.c
Justin M. Forbes 272dfe
+++ b/hw/virtio-pci.c
Justin M. Forbes 272dfe
@@ -208,6 +208,9 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
Justin M. Forbes 272dfe
             virtio_reset(proxy->vdev);
Justin M. Forbes 272dfe
             msix_unuse_all_vectors(&proxy->pci_dev);
Justin M. Forbes 272dfe
         }
Justin M. Forbes 272dfe
+        if (vdev->set_status) {
Justin M. Forbes 272dfe
+            vdev->set_status(vdev);
Justin M. Forbes 272dfe
+        }
Justin M. Forbes 272dfe
         break;
Justin M. Forbes 272dfe
     case VIRTIO_MSI_CONFIG_VECTOR:
Justin M. Forbes 272dfe
         msix_vector_unuse(&proxy->pci_dev, vdev->config_vector);
Justin M. Forbes 272dfe
@@ -375,6 +378,9 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
Justin M. Forbes 272dfe
     if (PCI_COMMAND == address) {
Justin M. Forbes 272dfe
         if (!(val & PCI_COMMAND_MASTER)) {
Justin M. Forbes 272dfe
             proxy->vdev->status &= ~VIRTIO_CONFIG_S_DRIVER_OK;
Justin M. Forbes 272dfe
+            if (proxy->vdev->set_status) {
Justin M. Forbes 272dfe
+                proxy->vdev->set_status(proxy->vdev);
Justin M. Forbes 272dfe
+            }
Justin M. Forbes 272dfe
         }
Justin M. Forbes 272dfe
     }
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
diff --git a/hw/virtio.h b/hw/virtio.h
Justin M. Forbes 272dfe
index f140ca3..39d0763 100644
Justin M. Forbes 272dfe
--- a/hw/virtio.h
Justin M. Forbes 272dfe
+++ b/hw/virtio.h
Justin M. Forbes 272dfe
@@ -114,6 +114,7 @@ struct VirtIODevice
Justin M. Forbes 272dfe
     void (*get_config)(VirtIODevice *vdev, uint8_t *config);
Justin M. Forbes 272dfe
     void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
Justin M. Forbes 272dfe
     void (*reset)(VirtIODevice *vdev);
Justin M. Forbes 272dfe
+    void (*set_status)(VirtIODevice *vdev);
Justin M. Forbes 272dfe
     VirtQueue *vq;
Justin M. Forbes 272dfe
     const VirtIOBindings *binding;
Justin M. Forbes 272dfe
     void *binding_opaque;
Justin M. Forbes 272dfe
-- 
Justin M. Forbes 272dfe
1.6.6.144.g5c3af