qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: <lv.mengzhao@zte.com.cn>
To: <mst@redhat.com>, <stefanha@redhat.com>, <kwolf@redhat.com>,
	<hreitz@redhat.com>
Cc: <qemu-block@nongnu.org>, <qemu-devel@nongnu.org>, <hu.jian@zte.com.cn>
Subject: [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
Date: Wed, 11 Oct 2023 15:17:54 +0800 (CST)	[thread overview]
Message-ID: <202310111517549668181@zte.com.cn> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 1675 bytes --]

From: hujian <hu.jian@zte.com.cn>

During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
is used to handle io request. But due to s->dataplane_disabled is false, it will be
returned directly, which drops io request.
Backtrace:
->virtio_blk_data_plane_stop
  ->virtio_bus_cleanup_host_notifier
    ->virtio_queue_host_notifier_read
      ->virtio_queue_notify_vq
        ->vq->handle_output
          ->virtio_blk_handle_output
            ->if (s->dataplane  && !s->dataplane_stoped)
              ->if (!s->dataplane_disabled)
                ->return *
            ->virtio_blk_handle_output_do
The above problem can occur when using "virsh reset" cmdline to reset guest, while
guest does io.
To fix this problem, don't try to start dataplane if s->stopping is true, and io will
be handled by virtio_blk_handle_vq().

Signed-off-by: hujian <hu.jian@zte.com.cn>
---
 hw/block/virtio-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 39e7f23..c2d5938 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIOBlock *s = (VirtIOBlock *)vdev;

-    if (s->dataplane && !s->dataplane_started) {
+    if (s->dataplane && !s->dataplane_started && !s->stopping) {
         /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
          * dataplane here instead of waiting for .set_status().
          */
--
1.8.3.1

[-- Attachment #1.1.2: Type: text/html , Size: 2685 bytes --]

             reply	other threads:[~2023-10-11 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  7:17 lv.mengzhao [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-10-11  6:14 [PATCH] virtio-blk: don't start dataplane during the stop of dataplane lv.mengzhao
2023-10-16 19:39 ` Stefan Hajnoczi
2023-10-17 14:03 ` Stefan Hajnoczi
2023-10-11  3:37 hujian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202310111517549668181@zte.com.cn \
    --to=lv.mengzhao@zte.com.cn \
    --cc=hreitz@redhat.com \
    --cc=hu.jian@zte.com.cn \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).