qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ed Swierk <eswierk@skyportsystems.com>,
	Fam Zheng <famz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Assertion failure taking external snapshot with virtio drive + iothread
Date: Fri, 17 Mar 2017 18:11:35 +0100	[thread overview]
Message-ID: <f8f478b3-70a0-b67b-c4df-3f68ac66308a@redhat.com> (raw)
In-Reply-To: <CAO_EM_kn4QEw=+j23F7e+LzLW2_TPwNENoopqyBb-hdKYAow9w@mail.gmail.com>



On 17/03/2017 17:55, Ed Swierk wrote:
> I'm running into the same problem taking an external snapshot with a
> virtio-blk drive with iothread, so it's not specific to virtio-scsi.
> Run a Linux guest on qemu master
> 
>   qemu-system-x86_64 -nographic -enable-kvm -monitor
> telnet:0.0.0.0:1234,server,nowait -m 1024 -object
> iothread,id=iothread1 -drive file=/x/drive.qcow2,if=none,id=drive0
> -device virtio-blk-pci,iothread=iothread1,drive=drive0
> 
> Then in the monitor
> 
>   snapshot_blkdev drive0 /x/snap1.qcow2
> 
> qemu bombs with
> 
>   qemu-system-x86_64: /x/qemu/include/block/aio.h:457:
> aio_enable_external: Assertion `ctx->external_disable_cnt > 0' failed.
> 
> whereas without the iothread the assertion failure does not occur.

Please try this patch:

diff --git a/block/block-backend.c b/block/block-backend.c
index 5742c09..1d95879 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1876,6 +1876,7 @@ static void blk_root_drained_begin(BdrvChild *child)
     if (blk->public.io_limits_disabled++ == 0) {
         throttle_group_restart_blk(blk);
     }
+    aio_disable_external(bdrv_get_aio_context(bs));
 }
 
 static void blk_root_drained_end(BdrvChild *child)
@@ -1883,5 +1884,6 @@ static void blk_root_drained_end(BdrvChild *child)
     BlockBackend *blk = child->opaque;
 
     assert(blk->public.io_limits_disabled);
+    aio_enable_external(bdrv_get_aio_context(bs));
     --blk->public.io_limits_disabled;
 }
diff --git a/block/io.c b/block/io.c
index 2709a70..a6dcef5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -224,7 +224,6 @@ void bdrv_drained_begin(BlockDriverState *bs)
     }
 
     if (!bs->quiesce_counter++) {
-        aio_disable_external(bdrv_get_aio_context(bs));
         bdrv_parent_drained_begin(bs);
     }
 
@@ -239,7 +238,6 @@ void bdrv_drained_end(BlockDriverState *bs)
     }
 
     bdrv_parent_drained_end(bs);
-    aio_enable_external(bdrv_get_aio_context(bs));
 }
 
 /*

This is not a proper fix, the right one would move the calls into
virtio-blk and virtio-scsi, but it might be a start.  I think the
issue is that you have one call to aio_disable_external for drive.qcow2
before the snapshot, and two calls to aio_enable_external (one for
drive.qcow2 and one for snap1.qcow2) after.

Paolo

  reply	other threads:[~2017-03-17 17:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 16:55 [Qemu-devel] Assertion failure taking external snapshot with virtio drive + iothread Ed Swierk
2017-03-17 17:11 ` Paolo Bonzini [this message]
2017-03-17 17:15   ` Paolo Bonzini
2017-03-17 17:32     ` Ed Swierk
2017-03-17 18:10       ` Paolo Bonzini
2017-03-17 19:27       ` Paolo Bonzini
2017-03-20 21:54         ` Ed Swierk
2017-03-21  1:48         ` Ed Swierk
2017-03-21  5:26 ` Fam Zheng
2017-03-21 12:20   ` Ed Swierk
2017-03-21 12:50     ` Fam Zheng
2017-03-21 13:05       ` Ed Swierk
2017-03-22  9:19         ` Fam Zheng
2017-03-22 17:36           ` Ed Swierk

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=f8f478b3-70a0-b67b-c4df-3f68ac66308a@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=eswierk@skyportsystems.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).