virtio-pci: mask notifier error handling fixups
PATCH 1/1 virtio-pci: mask notifier error handling fixups
Fix virtio-pci error handling in the mask notifiers: be careful to undo exactly what we did so far.
Reported-by Alex Williamson <[email protected]>
Signed-off-by Michael S. Tsirkin <[email protected]>
---
This is for qemu-kvm only.
hw/virtio-pci.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
hw/virtio-pci.c +12 -0
@@ -612,6 +612,9 @@ static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,return 0 ; undo:while (--n >=0 ) { +if (virtio_queue_vector (vdev, n) != vector) { +continue ; + }virtio_pci_mask_vq (dev, vector,virtio_get_queue (vdev, n), !masked); }return r;
@@ -681,9 +684,18 @@ static int virtio_pci_set_guest_notifiers(void *opaque, bool assign) assign_error:/* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */ +if (assign) { +msix_unset_mask_notifier (&proxy->pci_dev); + } +while (--n >=0 ) {virtio_pci_set_guest_notifier (opaque, n, !assign); } + +if (!assign) { +msix_set_mask_notifier (&proxy->pci_dev, + virtio_pci_mask_notifier); + }return r; }
Signature · 1 line
1.7.3.2.91.g446ac
Quoted 6 lines · Michael S. Tsirkin
Fix virtio-pci error handling in the mask notifiers: be careful to undo exactly what we did so far.
Reported-by Alex Williamson <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>---
Looks right.
Acked-by Alex Williamson <[email protected]>
Quoted 36 lines
hw/virtio-pci.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)hw/virtio-pci.c +12
-0@@ -612,6 +612,9 @@ static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,return 0 ; undo:while (--n >=0 ) { +if (virtio_queue_vector (vdev, n) != vector) { +continue ; + }virtio_pci_mask_vq (dev, vector,virtio_get_queue (vdev, n), !masked); }return r;@@ -681,9 +684,18 @@ static int virtio_pci_set_guest_notifiers(void *opaque, bool assign) assign_error:/* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */ +if (assign) { +msix_unset_mask_notifier (&proxy->pci_dev); + } +while (--n >=0 ) {virtio_pci_set_guest_notifier (opaque, n, !assign); } + +if (!assign) { +msix_set_mask_notifier (&proxy->pci_dev, + virtio_pci_mask_notifier); + }return r; }
Marcelo Tosatti
AppliedQuoted 11 lines · Michael S. Tsirkin
Fix virtio-pci error handling in the mask notifiers: be careful to undo exactly what we did so far.
Reported-by Alex Williamson <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>---
This is for qemu-kvm only.
hw/virtio-pci.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
Applied, thanks.