@@ -552,6 +552,17 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
return vhost_ops->vhost_net_set_mtu(&net->dev, mtu);
}
+void vhost_net_toggle_device_iotlb(struct vhost_dev *dev)
+{
+ const VhostOps *vhost_ops = dev->vhost_ops;
+
+ if (!vhost_ops->vhost_toggle_device_iotlb) {
+ return;
+ }
+
+ vhost_ops->vhost_toggle_device_iotlb(dev);
+}
+
void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
int vq_index)
{
@@ -3844,6 +3844,12 @@ static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev)
return &net->dev;
}
+static void virtio_net_toggle_device_iotlb(VirtIODevice *vdev)
+{
+ if (vdev->vhost_started)
+ vhost_net_toggle_device_iotlb(virtio_net_get_vhost(vdev));
+}
+
static const VMStateDescription vmstate_virtio_net = {
.name = "virtio-net",
.minimum_version_id = VIRTIO_NET_VM_VERSION,
@@ -3949,6 +3955,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
vdc->vmsd = &vmstate_virtio_net_device;
vdc->primary_unplug_pending = primary_unplug_pending;
vdc->get_vhost = virtio_net_get_vhost;
+ vdc->toggle_device_iotlb = virtio_net_toggle_device_iotlb;
}
static const TypeInfo virtio_net_info = {
@@ -56,4 +56,6 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
int vq_index);
void vhost_net_save_acked_features(NetClientState *nc);
+
+void vhost_net_toggle_device_iotlb(struct vhost_dev *dev);
#endif
If vhost is enabled for virtio-net, Device-TLB enable/disable events must be passed to vhost for proper IOMMU unmap flag selection. Signed-off-by: Viktor Prutyanov <viktor@daynix.com> --- hw/net/vhost_net.c | 11 +++++++++++ hw/net/virtio-net.c | 7 +++++++ include/net/vhost_net.h | 2 ++ 3 files changed, 20 insertions(+)