Message ID | 1459342088-24311-2-git-send-email-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, 30 Mar 2016 14:48:00 +0200 Paolo Bonzini <pbonzini@redhat.com> wrote: > There is no need to run the handler one last time; the device is being > reset and it is okay to drop requests that are pending in the virtqueue. What about virtio_blk_save()? Could there be any pending requests in that case? > By omitting this call, we dodge a possible cause of races between the > dataplane thread on one side and the main/vCPU threads on the other. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > hw/block/dataplane/virtio-blk.c | 2 +- > hw/scsi/virtio-scsi-dataplane.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-)
On 30/03/2016 15:23, Cornelia Huck wrote: > > There is no need to run the handler one last time; the device is being > > reset and it is okay to drop requests that are pending in the virtqueue. > > What about virtio_blk_save()? Could there be any pending requests in > that case? Those would be processed when dataplane is restarted on the destination side, I think. virtio_queue_set_host_notifier_fd_handler calls virtio_queue_host_notifier_read which connects the host notifier to the I/O thread and calls event_notifier_set to start processing it. Paolo
On Wed, 30 Mar 2016 15:30:04 +0200 Paolo Bonzini <pbonzini@redhat.com> wrote: > On 30/03/2016 15:23, Cornelia Huck wrote: > > > There is no need to run the handler one last time; the device is being > > > reset and it is okay to drop requests that are pending in the virtqueue. > > > > What about virtio_blk_save()? Could there be any pending requests in > > that case? > > Those would be processed when dataplane is restarted on the destination > side, I think. virtio_queue_set_host_notifier_fd_handler calls > virtio_queue_host_notifier_read which connects the host notifier to the > I/O thread and calls event_notifier_set to start processing it. Makes sense; maybe mention that in the patch description as well?
On Wed, 30 Mar 2016 14:48:00 +0200 Paolo Bonzini <pbonzini@redhat.com> wrote: > There is no need to run the handler one last time; the device is being > reset and it is okay to drop requests that are pending in the virtqueue. > By omitting this call, we dodge a possible cause of races between the > dataplane thread on one side and the main/vCPU threads on the other. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > hw/block/dataplane/virtio-blk.c | 2 +- > hw/scsi/virtio-scsi-dataplane.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 36f3d2b..0d76110 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -261,7 +261,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s) aio_context_acquire(s->ctx); /* Stop notifications for new requests from guest */ - virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, true, false); /* Drain and switch bs back to the QEMU main loop */ blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context()); diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c index 367e476..c57480e 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -71,10 +71,10 @@ static void virtio_scsi_clear_aio(VirtIOSCSI *s) VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); int i; - virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, false, false); - virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, true, false); + virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, true, false); for (i = 0; i < vs->conf.num_queues; i++) { - virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, true, false); } }
There is no need to run the handler one last time; the device is being reset and it is okay to drop requests that are pending in the virtqueue. By omitting this call, we dodge a possible cause of races between the dataplane thread on one side and the main/vCPU threads on the other. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- hw/block/dataplane/virtio-blk.c | 2 +- hw/scsi/virtio-scsi-dataplane.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)