From patchwork Wed Jun 21 12:50:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 9801737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C06DA60329 for ; Wed, 21 Jun 2017 12:52:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6234282EC for ; Wed, 21 Jun 2017 12:52:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BABEC2851E; Wed, 21 Jun 2017 12:52:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70AAD282EC for ; Wed, 21 Jun 2017 12:52:34 +0000 (UTC) Received: from localhost ([::1]:53738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNf7Z-0007bt-C7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Jun 2017 08:52:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNf68-0007Y0-5S for qemu-devel@nongnu.org; Wed, 21 Jun 2017 08:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNf67-0004mN-Ae for qemu-devel@nongnu.org; Wed, 21 Jun 2017 08:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45594) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNf60-0004c1-PN; Wed, 21 Jun 2017 08:50:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8D50AB97A; Wed, 21 Jun 2017 12:50:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8D50AB97A Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B8D50AB97A Received: from localhost (unknown [10.40.205.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B433703A7; Wed, 21 Jun 2017 12:50:54 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 21 Jun 2017 14:50:23 +0200 Message-Id: <20170621125047.30294-2-mreitz@redhat.com> In-Reply-To: <20170621125047.30294-1-mreitz@redhat.com> References: <20170621125047.30294-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 21 Jun 2017 12:50:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 01/25] block/mirror: Small absolute-paths simplification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When invoking drive-mirror in absolute-paths mode, the target's backing BDS is assigned to it in mirror_exit(). The current logic only does so if the target does not have that backing BDS already; but it actually cannot have a backing BDS at all (the BDS is opened with O_NO_BACKING in qmp_drive_mirror()), so just assert that and assign the new backing BDS unconditionally. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/mirror.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 4618853..db57bee 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -529,12 +529,12 @@ static void mirror_exit(BlockJob *job, void *opaque) &error_abort); if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) { BlockDriverState *backing = s->is_none_mode ? src : s->base; - if (backing_bs(target_bs) != backing) { - bdrv_set_backing_hd(target_bs, backing, &local_err); - if (local_err) { - error_report_err(local_err); - data->ret = -EPERM; - } + + assert(!target_bs->backing); + bdrv_set_backing_hd(target_bs, backing, &local_err); + if (local_err) { + error_report_err(local_err); + data->ret = -EPERM; } }