From patchwork Tue Apr 26 21:32:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 615314 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 3qvbtM227zz9t42 for ; Wed, 27 Apr 2016 07:33:15 +1000 (AEST) Received: from localhost ([::1]:39691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAbY-0007qT-Vb for incoming@patchwork.ozlabs.org; Tue, 26 Apr 2016 17:33:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAar-0006RY-MQ for qemu-devel@nongnu.org; Tue, 26 Apr 2016 17:32:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avAaq-0003s3-Lk for qemu-devel@nongnu.org; Tue, 26 Apr 2016 17:32:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAao-0003rK-KL; Tue, 26 Apr 2016 17:32:26 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 485A081106; Tue, 26 Apr 2016 21:32:26 +0000 (UTC) Received: from localhost (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3QLWOcO027650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 26 Apr 2016 17:32:25 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 26 Apr 2016 23:32:01 +0200 Message-Id: <1461706338-20219-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1461706338-20219-1-git-send-email-mreitz@redhat.com> References: <1461706338-20219-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/19] block: Add BDS.backing_overridden 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If the backing file is overridden, this most probably does change the guest-visible data of a BDS. Therefore, we will need to consider this in bdrv_refresh_filename(). Adding a new field to the BDS is not nice, but it is very simple and exactly keeps track of whether the backing file has been overridden. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block.c | 2 ++ include/block/block_int.h | 1 + 2 files changed, 3 insertions(+) diff --git a/block.c b/block.c index e349e83..e178488 100644 --- a/block.c +++ b/block.c @@ -1299,6 +1299,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, reference = qdict_get_try_str(parent_options, bdref_key); if (reference || qdict_haskey(options, "file.filename")) { + bs->backing_overridden = true; backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { QDECREF(options); @@ -1589,6 +1590,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, backing = qdict_get_try_str(options, "backing"); if (backing && *backing == '\0') { flags |= BDRV_O_NO_BACKING; + bs->backing_overridden = true; qdict_del(options, "backing"); } diff --git a/include/block/block_int.h b/include/block/block_int.h index 10d8759..d73e9ce 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -409,6 +409,7 @@ struct BlockDriverState { char backing_file[PATH_MAX]; /* if non zero, the image is a diff of this file image */ char backing_format[16]; /* if non-zero and backing_file exists */ + bool backing_overridden; /* backing file has been specified by the user */ QDict *full_open_options; char exact_filename[PATH_MAX];