[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/21] hw/virtio: gracefully handle unset vhost_dev vdev
From: |
Alex Bennée |
Subject: |
[PATCH v3 07/21] hw/virtio: gracefully handle unset vhost_dev vdev |
Date: |
Tue, 26 Jul 2022 20:21:36 +0100 |
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>
---
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,
--
2.30.2
- Re: [PATCH v3 03/21] hw/virtio: fix some coding style issues, (continued)
- [PATCH v3 15/21] tests/qtest: use qos_printf instead of g_test_message, Alex Bennée, 2022/07/26
- [PATCH v3 06/21] hw/virtio: incorporate backend features in features, Alex Bennée, 2022/07/26
- [PATCH v3 20/21] tests/qtest: add a get_features op to vhost-user-test, Alex Bennée, 2022/07/26
- [PATCH v3 04/21] hw/virtio: log potentially buggy guest drivers, Alex Bennée, 2022/07/26
- [PATCH v3 05/21] block/vhost-user-blk-server: don't expose VHOST_USER_F_PROTOCOL_FEATURES, Alex Bennée, 2022/07/26
- [PATCH v3 07/21] hw/virtio: gracefully handle unset vhost_dev vdev,
Alex Bennée <=
- [PATCH v3 08/21] hw/virtio: handle un-configured shutdown in virtio-pci, Alex Bennée, 2022/07/26
- [PATCH v3 09/21] hw/virtio: fix vhost_user_read tracepoint, Alex Bennée, 2022/07/26
- [PATCH v3 17/21] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES, Alex Bennée, 2022/07/26
- [PATCH v3 21/21] tests/qtest: enable tests for virtio-gpio, Alex Bennée, 2022/07/26
- [PATCH v3 19/21] tests/qtest: implement stub for VHOST_USER_GET_CONFIG, Alex Bennée, 2022/07/26
- [PATCH v3 13/21] tests/qtest: pass stdout/stderr down to subtests, Alex Bennée, 2022/07/26
- [PATCH v3 16/21] tests/qtest: catch unhandled vhost-user messages, Alex Bennée, 2022/07/26
- [PATCH v3 12/21] hw/virtio: add vhost-user-gpio-pci boilerplate, Alex Bennée, 2022/07/26