From nobody Sun Nov 9 21:39:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551896643270737.1083070058972; Wed, 6 Mar 2019 10:24:03 -0800 (PST) Received: from localhost ([127.0.0.1]:37338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1bCv-0004iR-5D for importer@patchew.org; Wed, 06 Mar 2019 13:23:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1b2f-00058a-6C for qemu-devel@nongnu.org; Wed, 06 Mar 2019 13:13:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1b2V-0006ma-Ml for qemu-devel@nongnu.org; Wed, 06 Mar 2019 13:13:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:59307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1b2R-0005g0-NX; Wed, 06 Mar 2019 13:13:09 -0500 Received: from 87-92-21-153.bb.dnainternet.fi ([87.92.21.153] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1h1b10-0004qz-KB; Wed, 06 Mar 2019 19:11:38 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1h1b0m-0005OW-A1; Wed, 06 Mar 2019 20:11:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=LC1wZPxjMc4N6YtAMPEaZibi0AurPctm7RkldSCcBSo=; b=oBQCdwCme+0P4y2BtrqmjtiiET2KzmrQm52EYMDJH+JQxKnaNW9QLTH985YFzWAxdnP3sV296/BKWl8VRlPjcbTny9TJLT8jdXRbgWl0o8UdUhJYltcN52eDbWAsxZTLdMnDAF6A1ytTuNPvEHN1f2x5HxRE2dp7xMlx1daSKCCdICGWlgAJ0dHc5DrbY0Wfm1zDCFo7zFXyLTvmsL/dg5z/FUkKWtFIlo9ZZSR7HntBwvV8WRNQDVJvhH/qQTlwNA/xhSUIufW5+L7qTPnADQB+3tppLvaNN5UxbmpCDGrI44ojlT5rKPiwkTXeprFM2x1SYDPCBIiGQY3NhLiadg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 20:11:07 +0200 Message-Id: <2aa65ff5c15e667d64aea53b6787205c0344b6c5.1551895814.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v2 07/13] block: Allow omitting the 'backing' option in certain cases 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-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Of all options of type BlockdevRef used to specify children in BlockdevOptions, 'backing' is the only one that is optional. For "x-blockdev-reopen" we want that if an option is omitted then it must be reset to its default value. The default value of 'backing' means that QEMU opens the backing file specified in the image metadata, but this is not something that we want to support for the reopen operation. Because of this the 'backing' option has to be specified during reopen, pointing to the existing backing file if we want to keep it, or pointing to a different one (or NULL) if we want to replace it (to be implemented in a subsequent patch). In order to simplify things a bit and not to require that the user passes the 'backing' option to every single block device even when it's clearly not necessary, this patch allows omitting this option if the block device being reopened doesn't have a backing file attached _and_ no default backing file is specified in the image metadata. Signed-off-by: Alberto Garcia --- block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index d7fa577c18..6db8a65e61 100644 --- a/block.c +++ b/block.c @@ -3414,7 +3414,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, =20 drv_prepared =3D true; =20 - if (drv->supports_backing && reopen_state->backing_missing) { + /* + * We must provide the 'backing' option if the BDS has a backing + * file or if the image file has a backing file name as part of + * its metadata. Otherwise the 'backing' option can be omitted. + */ + if (drv->supports_backing && reopen_state->backing_missing && + (backing_bs(reopen_state->bs) || reopen_state->bs->backing_file[0]= )) { error_setg(errp, "backing is missing for '%s'", reopen_state->bs->node_name); ret =3D -EINVAL; --=20 2.11.0