53 lines
1.8 KiB
Diff
53 lines
1.8 KiB
Diff
|
|
From edbbc82bdf7cdb21604bb1c8b4a222691b3c3665 Mon Sep 17 00:00:00 2001
|
||
|
|
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <alex.bennee@linaro.org>
|
||
|
|
Date: Thu, 28 Jul 2022 14:55:01 +0100
|
||
|
|
Subject: [PATCH] hw/virtio: gracefully handle unset vhost_dev vdev
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
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>
|
||
|
|
Signed-off-by: fangyi <eric.fangyi@huawei.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 2f0ddd35d6..8e8657fb0d 100644
|
||
|
|
--- a/hw/virtio/vhost.c
|
||
|
|
+++ b/hw/virtio/vhost.c
|
||
|
|
@@ -310,7 +310,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;
|
||
|
|
|
||
|
|
@@ -320,8 +320,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.27.0
|
||
|
|
|