mirror of https://github.com/xemu-project/xemu.git
virtio: unify dataplane and non-dataplane ->handle_output()
Now that virtio-blk and virtio-scsi are ready, get rid of the handle_aio_output() callback. It's no longer needed. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20211207132336.36627-7-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
d6fbfe2b83
commit
db608fb784
|
@ -154,17 +154,6 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)
|
||||||
g_free(s);
|
g_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_blk_data_plane_handle_output(VirtIODevice *vdev,
|
|
||||||
VirtQueue *vq)
|
|
||||||
{
|
|
||||||
VirtIOBlock *s = (VirtIOBlock *)vdev;
|
|
||||||
|
|
||||||
assert(s->dataplane);
|
|
||||||
assert(s->dataplane_started);
|
|
||||||
|
|
||||||
virtio_blk_handle_vq(s, vq);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Context: QEMU global mutex held */
|
/* Context: QEMU global mutex held */
|
||||||
int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
||||||
{
|
{
|
||||||
|
@ -258,8 +247,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
||||||
for (i = 0; i < nvqs; i++) {
|
for (i = 0; i < nvqs; i++) {
|
||||||
VirtQueue *vq = virtio_get_queue(s->vdev, i);
|
VirtQueue *vq = virtio_get_queue(s->vdev, i);
|
||||||
|
|
||||||
virtio_queue_aio_set_host_notifier_handler(vq, s->ctx,
|
virtio_queue_aio_attach_host_notifier(vq, s->ctx);
|
||||||
virtio_blk_data_plane_handle_output);
|
|
||||||
}
|
}
|
||||||
aio_context_release(s->ctx);
|
aio_context_release(s->ctx);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -302,7 +290,7 @@ static void virtio_blk_data_plane_stop_bh(void *opaque)
|
||||||
for (i = 0; i < s->conf->num_queues; i++) {
|
for (i = 0; i < s->conf->num_queues; i++) {
|
||||||
VirtQueue *vq = virtio_get_queue(s->vdev, i);
|
VirtQueue *vq = virtio_get_queue(s->vdev, i);
|
||||||
|
|
||||||
virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL);
|
virtio_queue_aio_detach_host_notifier(vq, s->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,45 +49,6 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_scsi_data_plane_handle_cmd(VirtIODevice *vdev,
|
|
||||||
VirtQueue *vq)
|
|
||||||
{
|
|
||||||
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
|
||||||
|
|
||||||
virtio_scsi_acquire(s);
|
|
||||||
if (!s->dataplane_fenced) {
|
|
||||||
assert(s->ctx && s->dataplane_started);
|
|
||||||
virtio_scsi_handle_cmd_vq(s, vq);
|
|
||||||
}
|
|
||||||
virtio_scsi_release(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
|
|
||||||
VirtQueue *vq)
|
|
||||||
{
|
|
||||||
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
|
||||||
|
|
||||||
virtio_scsi_acquire(s);
|
|
||||||
if (!s->dataplane_fenced) {
|
|
||||||
assert(s->ctx && s->dataplane_started);
|
|
||||||
virtio_scsi_handle_ctrl_vq(s, vq);
|
|
||||||
}
|
|
||||||
virtio_scsi_release(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
|
|
||||||
VirtQueue *vq)
|
|
||||||
{
|
|
||||||
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
|
||||||
|
|
||||||
virtio_scsi_acquire(s);
|
|
||||||
if (!s->dataplane_fenced) {
|
|
||||||
assert(s->ctx && s->dataplane_started);
|
|
||||||
virtio_scsi_handle_event_vq(s, vq);
|
|
||||||
}
|
|
||||||
virtio_scsi_release(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int virtio_scsi_set_host_notifier(VirtIOSCSI *s, VirtQueue *vq, int n)
|
static int virtio_scsi_set_host_notifier(VirtIOSCSI *s, VirtQueue *vq, int n)
|
||||||
{
|
{
|
||||||
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
|
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
|
||||||
|
@ -112,10 +73,10 @@ static void virtio_scsi_dataplane_stop_bh(void *opaque)
|
||||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
|
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, NULL);
|
virtio_queue_aio_detach_host_notifier(vs->ctrl_vq, s->ctx);
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, NULL);
|
virtio_queue_aio_detach_host_notifier(vs->event_vq, s->ctx);
|
||||||
for (i = 0; i < vs->conf.num_queues; i++) {
|
for (i = 0; i < vs->conf.num_queues; i++) {
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, NULL);
|
virtio_queue_aio_detach_host_notifier(vs->cmd_vqs[i], s->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,14 +137,11 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
|
||||||
memory_region_transaction_commit();
|
memory_region_transaction_commit();
|
||||||
|
|
||||||
aio_context_acquire(s->ctx);
|
aio_context_acquire(s->ctx);
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx,
|
virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
|
||||||
virtio_scsi_data_plane_handle_ctrl);
|
virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx);
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx,
|
|
||||||
virtio_scsi_data_plane_handle_event);
|
|
||||||
|
|
||||||
for (i = 0; i < vs->conf.num_queues; i++) {
|
for (i = 0; i < vs->conf.num_queues; i++) {
|
||||||
virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx,
|
virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
|
||||||
virtio_scsi_data_plane_handle_cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s->dataplane_starting = false;
|
s->dataplane_starting = false;
|
||||||
|
|
|
@ -3525,10 +3525,8 @@ static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n)
|
||||||
virtio_queue_set_notification(vq, 1);
|
virtio_queue_set_notification(vq, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
|
void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
|
||||||
VirtIOHandleOutput handle_output)
|
|
||||||
{
|
{
|
||||||
if (handle_output) {
|
|
||||||
aio_set_event_notifier(ctx, &vq->host_notifier, true,
|
aio_set_event_notifier(ctx, &vq->host_notifier, true,
|
||||||
virtio_queue_host_notifier_read,
|
virtio_queue_host_notifier_read,
|
||||||
virtio_queue_host_notifier_aio_poll,
|
virtio_queue_host_notifier_aio_poll,
|
||||||
|
@ -3536,12 +3534,14 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
|
||||||
aio_set_event_notifier_poll(ctx, &vq->host_notifier,
|
aio_set_event_notifier_poll(ctx, &vq->host_notifier,
|
||||||
virtio_queue_host_notifier_aio_poll_begin,
|
virtio_queue_host_notifier_aio_poll_begin,
|
||||||
virtio_queue_host_notifier_aio_poll_end);
|
virtio_queue_host_notifier_aio_poll_end);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
|
||||||
|
{
|
||||||
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
|
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
|
||||||
/* Test and clear notifier before after disabling event,
|
/* Test and clear notifier before after disabling event,
|
||||||
* in case poll callback didn't have time to run. */
|
* in case poll callback didn't have time to run. */
|
||||||
virtio_queue_host_notifier_read(&vq->host_notifier);
|
virtio_queue_host_notifier_read(&vq->host_notifier);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtio_queue_host_notifier_read(EventNotifier *n)
|
void virtio_queue_host_notifier_read(EventNotifier *n)
|
||||||
|
|
|
@ -316,8 +316,8 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
|
||||||
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
|
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
|
||||||
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
|
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
|
||||||
void virtio_queue_host_notifier_read(EventNotifier *n);
|
void virtio_queue_host_notifier_read(EventNotifier *n);
|
||||||
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
|
void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
|
||||||
VirtIOHandleOutput handle_output);
|
void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
|
||||||
VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
|
VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
|
||||||
VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
|
VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue