[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/12] hw/virtio: gracefully handle unset vhost_dev vdev
From: |
Michael S. Tsirkin |
Subject: |
[PULL 02/12] hw/virtio: gracefully handle unset vhost_dev vdev |
Date: |
Wed, 17 Aug 2022 16:05:54 -0400 |
From: Alex Bennée <alex.bennee@linaro.org>
I've noticed asserts firing because we query the status of vdev after
a vhost connection is closed down. Rather than faulting on the NULL
indirect just quietly reply false.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220728135503.1060062-3-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 0827d631c0..f758f177bb 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -306,7 +306,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev
*dev, uint64_t size)
dev->log_size = size;
}
-static int vhost_dev_has_iommu(struct vhost_dev *dev)
+static bool vhost_dev_has_iommu(struct vhost_dev *dev)
{
VirtIODevice *vdev = dev->vdev;
@@ -316,8 +316,12 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev)
* does not have IOMMU, there's no need to enable this feature
* which may cause unnecessary IOTLB miss/update transactions.
*/
- return virtio_bus_device_iommu_enabled(vdev) &&
- virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+ if (vdev) {
+ return virtio_bus_device_iommu_enabled(vdev) &&
+ virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+ } else {
+ return false;
+ }
}
static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
--
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 <=
- [PULL 03/12] hw/virtio: handle un-configured shutdown in virtio-pci, Michael S. Tsirkin, 2022/08/17
- [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