[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] IOMMU not supported by vhost-user.
From: |
lagarcia |
Subject: |
[PATCH v2] IOMMU not supported by vhost-user. |
Date: |
Wed, 17 Feb 2021 16:55:12 -0300 |
From: Leonardo Garcia <lagarcia@br.ibm.com>
Currently, as IOMMU is not supported, if a user mistakenly set it and
tries to mount the vhost-user filesystem (or use any other vhost-user
based device) inside the guest, whenever the user tries to access the
device, the system will hang forever (because virtiofsd will not be
running anymore).
Signed-off-by: Leonardo Garcia <lagarcia@br.ibm.com>
---
hw/virtio/vhost-user-fs.c | 5 +++++
hw/virtio/vhost-user.c | 7 +++++++
hw/virtio/vhost.c | 1 -
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index ac4fc34b36..059b0d2ef9 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -222,6 +222,11 @@ static void vuf_device_realize(DeviceState *dev, Error
**errp)
/* 1 high prio queue, plus the number configured */
fs->vhost_dev.nvqs = 1 + fs->conf.num_request_queues;
fs->vhost_dev.vqs = g_new0(struct vhost_virtqueue, fs->vhost_dev.nvqs);
+ /*
+ * vhost_user_backend_init does additional checks if VirtIODevice is
defined
+ * in vhost_dev
+ */
+ fs->vhost_dev.vdev = vdev;
ret = vhost_dev_init(&fs->vhost_dev, &fs->vhost_user,
VHOST_BACKEND_TYPE_USER, 0);
if (ret < 0) {
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 2fdd5daf74..6ab760364b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1849,6 +1849,13 @@ static int vhost_user_backend_init(struct vhost_dev
*dev, void *opaque)
}
}
+ if ((dev->vdev != NULL) &&
+ virtio_host_has_feature(dev->vdev, VIRTIO_F_IOMMU_PLATFORM) &&
+ !(features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) {
+ error_report("IOMMU is currently not supported with vhost-user");
+ return -1;
+ }
+
if (virtio_has_feature(features, VIRTIO_F_IOMMU_PLATFORM) &&
!(virtio_has_feature(dev->protocol_features,
VHOST_USER_PROTOCOL_F_SLAVE_REQ) &&
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6e17d631f7..78e58d2148 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1293,7 +1293,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
int i, r, n_initialized_vqs = 0;
Error *local_err = NULL;
- hdev->vdev = NULL;
hdev->migration_blocker = NULL;
r = vhost_set_backend_type(hdev, backend_type);
--
2.29.2
- [PATCH v2] IOMMU not supported by vhost-user.,
lagarcia <=