vhost: check region type before casting
commit388a86df9c59334e94ede099526509d8f466b0c8
authorTiwei Bie <tiwei.bie@intel.com>
Fri, 20 Jul 2018 08:36:44 +0000 (20 16:36 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 3 Aug 2018 08:35:21 +0000 (3 11:35 +0300)
tree6e38dc74775cdcdfca6dcdc4dd09b59cf0f1440e
parentf7502360397d291be04bc040e9f96c92ff2d8030
vhost: check region type before casting

Check region type first before casting the memory region
to IOMMUMemoryRegion. Otherwise QEMU will abort with below
error message when casting non-IOMMU memory region:

vhost_iommu_region_add: Object 0x561f28bce4f0 is not an
instance of type qemu:iommu-memory-region

Fixes: cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/vhost.c