[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/12] hw/virtio: handle un-configured shutdown in virtio-pci
From: |
Michael S. Tsirkin |
Subject: |
[PULL 03/12] hw/virtio: handle un-configured shutdown in virtio-pci |
Date: |
Wed, 17 Aug 2022 16:05:58 -0400 |
From: Alex Bennée <alex.bennee@linaro.org>
The assert() protecting against leakage is a little aggressive and
causes needless crashes if a device is shutdown without having been
configured. In this case no descriptors are lost because none have
been assigned.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220728135503.1060062-4-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 45327f0b31..5ce61f9b45 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d,
int nvqs, bool assign)
nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX);
- /* When deassigning, pass a consistent nvqs value
- * to avoid leaking notifiers.
+ /*
+ * When deassigning, pass a consistent nvqs value to avoid leaking
+ * notifiers. But first check we've actually been configured, exit
+ * early if we haven't.
*/
+ if (!assign && !proxy->nvqs_with_notifiers) {
+ return 0;
+ }
assert(assign || nvqs == proxy->nvqs_with_notifiers);
proxy->nvqs_with_notifiers = nvqs;
--
MST
- [PULL 00/12] pc,virtio: fixes, Michael S. Tsirkin, 2022/08/17
- [PULL 01/12] virtio-scsi: fix race in virtio_scsi_dataplane_start(), Michael S. Tsirkin, 2022/08/17
- [PULL 02/12] hw/virtio: gracefully handle unset vhost_dev vdev, Michael S. Tsirkin, 2022/08/17
- [PULL 03/12] hw/virtio: handle un-configured shutdown in virtio-pci,
Michael S. Tsirkin <=
- [PULL 04/12] hw/virtio: fix vhost_user_read tracepoint, Michael S. Tsirkin, 2022/08/17
- [PULL 05/12] x86: disable rng seeding via setup_data, Michael S. Tsirkin, 2022/08/17
- [PULL 06/12] hw/cxl: Fix memory leak in error paths, Michael S. Tsirkin, 2022/08/17
- [PULL 08/12] hw/cxl: Add stub write function for RO MemoryRegionOps entries., Michael S. Tsirkin, 2022/08/17
- [PULL 09/12] hw/cxl: Fix Get LSA input payload size which should be 8 bytes., Michael S. Tsirkin, 2022/08/17
- [PULL 10/12] hw/cxl: Correctly handle variable sized mailbox input payloads., Michael S. Tsirkin, 2022/08/17
- [PULL 11/12] tests: acpi: silence applesmc warning about invalid key, Michael S. Tsirkin, 2022/08/17
- [PULL 12/12] virtio-pci: don't touch pci on virtio reset, Michael S. Tsirkin, 2022/08/17
- [PULL 07/12] hw/cxl: Fix wrong query of target ports, Michael S. Tsirkin, 2022/08/17
- Re: [PULL 00/12] pc,virtio: fixes, Richard Henderson, 2022/08/18