From patchwork Tue Sep 22 10:07:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 520977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41B24140187 for ; Tue, 22 Sep 2015 20:07:50 +1000 (AEST) Received: from localhost ([::1]:38154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeKUG-00043Q-Fp for incoming@patchwork.ozlabs.org; Tue, 22 Sep 2015 06:07:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeKTz-0003lC-74 for qemu-devel@nongnu.org; Tue, 22 Sep 2015 06:07:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeKTy-0008Np-9G for qemu-devel@nongnu.org; Tue, 22 Sep 2015 06:07:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeKTs-0008Kn-6X; Tue, 22 Sep 2015 06:07:24 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B646E8DA34; Tue, 22 Sep 2015 10:07:23 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MA7LIq030831; Tue, 22 Sep 2015 06:07:22 -0400 Date: Tue, 22 Sep 2015 12:07:21 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150922100721.GC3999@noname.str.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, armbru@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-devel] [PATCH 00/16] block: Get rid of bdrv_swap() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Am 18.09.2015 um 13:03 hat Alberto Garcia geschrieben: > On Thu 17 Sep 2015 03:48:04 PM CEST, Kevin Wolf wrote: > > > bdrv_swap() has always been an ugly hack that we would rather have > > avoided. When it was introduced, we simply didn't have the > > infrastructure to update pointers instead of transplanting the > > contents of BDS object, so we grudgingly added bdrv_swap() as a quick > > solution. Meanwhile, most of the infrastructure exists and this > > series implements the final step necessary to implement the required > > functionality in a less adventurous way. > > I didn't have the chance to debug this further, but with this series if > I make a snapshot of a device with ongoing I/O I get lots of errors in > the guest: > > Buffer I/O error on device vda1, logical block 3801549 > end_request: I/O error, dev vda, sector 7604516 > [...] > > The drive is attached with -drive if=virtio,file=foo.qcow2,node-name=bar This is a stupid one. Now that bdrv_append() doesn't swap the meaning of its parameters any more, the snapshotting code makes the wrong node read-only. The more important point, though, is probably that qemu-iotests never tries to write to an image after taking an internal snapshot. Perhaps we should port the monitor to qemu-io (BenoƮt had some patches to add it to qemu-nbd, which should be similar; except that a "qmp" command in qemu-io could even be simpler), so we can test monitor commands more thoroughly without launching a full qemu (which allows to use the monitor commands in isolation, but mostly means that we don't do a lot of actual I/O). Anyway, patch below. Kevin diff --git a/blockdev.c b/blockdev.c index bc158ff..8926226 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1546,7 +1546,7 @@ static void external_snapshot_commit(BlkTransactionState *common) /* We don't need (or want) to use the transactional * bdrv_reopen_multiple() across all the entries at once, because we * don't want to abort all of them if one of them fails the reopen */ - bdrv_reopen(state->new_bs, state->new_bs->open_flags & ~BDRV_O_RDWR, + bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR, NULL); aio_context_release(state->aio_context);