]> Git Repo - qemu.git/commitdiff
hw/virtio: gracefully handle unset vhost_dev vdev
authorAlex Bennée <[email protected]>
Thu, 28 Jul 2022 13:55:01 +0000 (14:55 +0100)
committerMichael S. Tsirkin <[email protected]>
Wed, 17 Aug 2022 11:07:37 +0000 (07:07 -0400)
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 <[email protected]>
Message-Id: <20220728135503.1060062[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
hw/virtio/vhost.c

index 0827d631c09e62d73045480ca1c7095f8468ef6e..f758f177bb523cfcfab8a8fab1ca44d77364d0e1 100644 (file)
@@ -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,
This page took 0.028678 seconds and 4 git commands to generate.