提交 e616c2f3 编写于 作者: P Paolo Bonzini 提交者: Michael S. Tsirkin

virtio: remove ioeventfd_disabled altogether

Now that there is not anymore a switch from the generic ioeventfd handler
to the dataplane handler, virtio_bus_set_host_notifier(assign=true) is
always called with !bus->ioeventfd_started, hence virtio_bus_stop_ioeventfd
does nothing in this case.  Move the invocation to vhost.c, which is the
only place that needs it.
Reviewed-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 6019f3b9
...@@ -1196,6 +1196,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) ...@@ -1196,6 +1196,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
goto fail; goto fail;
} }
virtio_device_stop_ioeventfd(vdev);
for (i = 0; i < hdev->nvqs; ++i) { for (i = 0; i < hdev->nvqs; ++i) {
r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i, r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
true); true);
...@@ -1215,6 +1216,7 @@ fail_vq: ...@@ -1215,6 +1216,7 @@ fail_vq:
} }
assert (e >= 0); assert (e >= 0);
} }
virtio_device_start_ioeventfd(vdev);
fail: fail:
return r; return r;
} }
...@@ -1237,6 +1239,7 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) ...@@ -1237,6 +1239,7 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
} }
assert (r >= 0); assert (r >= 0);
} }
virtio_device_start_ioeventfd(vdev);
} }
/* Test and clear event pending status. /* Test and clear event pending status.
......
...@@ -190,7 +190,7 @@ int virtio_bus_start_ioeventfd(VirtioBusState *bus) ...@@ -190,7 +190,7 @@ int virtio_bus_start_ioeventfd(VirtioBusState *bus)
if (!k->ioeventfd_assign || !k->ioeventfd_enabled(proxy)) { if (!k->ioeventfd_assign || !k->ioeventfd_enabled(proxy)) {
return -ENOSYS; return -ENOSYS;
} }
if (bus->ioeventfd_started || bus->ioeventfd_disabled) { if (bus->ioeventfd_started) {
return 0; return 0;
} }
r = vdc->start_ioeventfd(vdev); r = vdc->start_ioeventfd(vdev);
...@@ -226,8 +226,8 @@ bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus) ...@@ -226,8 +226,8 @@ bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus)
} }
/* /*
* This function switches from/to the generic ioeventfd handler. * This function switches ioeventfd on/off in the device.
* assign==false means 'use generic ioeventfd handler'. * The caller must set or clear the handlers for the EventNotifier.
*/ */
int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
{ {
...@@ -237,19 +237,12 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) ...@@ -237,19 +237,12 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
if (!k->ioeventfd_assign) { if (!k->ioeventfd_assign) {
return -ENOSYS; return -ENOSYS;
} }
bus->ioeventfd_disabled = assign;
if (assign) { if (assign) {
/* assert(!bus->ioeventfd_started);
* Stop using the generic ioeventfd, we are doing eventfd handling } else {
* ourselves below if (!bus->ioeventfd_started) {
* return 0;
* FIXME: We should just switch the handler and not deassign the }
* ioeventfd.
* Otherwise, there's a window where we don't have an
* ioeventfd and we may end up with a notification where
* we don't expect one.
*/
virtio_bus_stop_ioeventfd(bus);
} }
return set_host_notifier_internal(proxy, bus, n, assign); return set_host_notifier_internal(proxy, bus, n, assign);
} }
......
...@@ -93,12 +93,6 @@ typedef struct VirtioBusClass { ...@@ -93,12 +93,6 @@ typedef struct VirtioBusClass {
struct VirtioBusState { struct VirtioBusState {
BusState parent_obj; BusState parent_obj;
/*
* Set if the default ioeventfd handlers are disabled by vhost
* or dataplane.
*/
bool ioeventfd_disabled;
/* /*
* Set if ioeventfd has been started. * Set if ioeventfd has been started.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册