From nobody Tue Nov 4 15:13:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302727147151023.3683311632626; Fri, 29 Jun 2018 04:45:14 -0700 (PDT) Received: from localhost ([::1]:41378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrpt-0007MO-B4 for importer@patchew.org; Fri, 29 Jun 2018 07:45:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjE-0001sT-68 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HS-He for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:16 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004Tg-3N; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriP-0006Oz-BV; Fri, 29 Jun 2018 13:37:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Kg-R3; Fri, 29 Jun 2018 14:37:10 +0300 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=QxL5LWzrie8mVYyKbhrlEw3MTsS+tXADdGh8zePZEAs=; b=B9oF/BGp63YkcKZV1jo2tnhHck+hQn0VpRFlFe70lCCQkOo5ewhjvSQ+JQDYiNLovbDhsPutOilTbSlQIrqnA5/wc1yUxfARi6dORA47AvH2JVeZ4Xgb8LOvz1Okf4Fbj1JYdku7neLvi9Xrw/XJWhwW6UhBlb+ySDO6VQYgpf+dm9VG6g7vGM/cALZxknXF9iIa5vJg9MstJCj6WrhpDSxTKoMJ5bB5G/cAKgBpZVVWWkuV8nqaAULgcEXe3dpWd+VPLMOMi2vzcpWOmtk6xvFPd7HXTU8jgMGlJKPicQKyLCCAeOkBIus/M3uwm4Tx5e0zED9r9QjKN3656SavyQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:37:02 +0300 Message-Id: <7115bcf1fb0c856f96690225eed964f95fdc0cca.1530270904.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 4/5] block: Update bs->options if bdrv_reopen() succeeds 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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If bdrv_reopen() succeeds then bs->explicit_options is updated with the new values, but bs->options never changes. Here's an example: { "execute": "blockdev-add", "arguments": { "driver": "qcow2", "node-name": "hd0", "overlap-check": "all", "file": { "driver": "file", "filename": "hd0.qcow2" } } } After this, both bs->options and bs->explicit_options contain "overlap-check": "all". Now let's change that using qemu-io's reopen command: (qemu) qemu-io hd0 "reopen -o overlap-check=3Dnone" After this, bs->explicit_options contains the new value but bs->options still keeps the old one. This patch updates bs->options after a BDS has been successfully reopened. Signed-off-by: Alberto Garcia --- block.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 48e8f4814c..58c8e8e677 100644 --- a/block.c +++ b/block.c @@ -3065,8 +3065,8 @@ cleanup: bdrv_reopen_abort(&bs_entry->state); } qobject_unref(bs_entry->state.explicit_options); + qobject_unref(bs_entry->state.options); } - qobject_unref(bs_entry->state.options); g_free(bs_entry); } g_free(bs_queue); @@ -3166,6 +3166,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state= , BlockReopenQueue *queue, Error *local_err =3D NULL; BlockDriver *drv; QemuOpts *opts; + QDict *orig_reopen_opts; const char *value; bool read_only; =20 @@ -3173,6 +3174,11 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, assert(reopen_state->bs->drv !=3D NULL); drv =3D reopen_state->bs->drv; =20 + /* This function and each driver's bdrv_reopen_prepare() remove + * entries from reopen_state->options as they are processed, so + * we need to make a copy of the original QDict. */ + orig_reopen_opts =3D qdict_clone_shallow(reopen_state->options); + /* Process generic block layer options */ opts =3D qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, reopen_state->options, &local_err); @@ -3279,8 +3285,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, =20 ret =3D 0; =20 + /* Restore the original reopen_state->options QDict */ + qobject_unref(reopen_state->options); + reopen_state->options =3D qobject_ref(orig_reopen_opts); + error: qemu_opts_del(opts); + qobject_unref(orig_reopen_opts); return ret; } =20 @@ -3310,8 +3321,10 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_stat= e) =20 /* set BDS specific flags now */ qobject_unref(bs->explicit_options); + qobject_unref(bs->options); =20 bs->explicit_options =3D reopen_state->explicit_options; + bs->options =3D reopen_state->options; bs->open_flags =3D reopen_state->flags; bs->read_only =3D !(reopen_state->flags & BDRV_O_RDWR); =20 --=20 2.11.0