From nobody Wed Nov 5 16:41:00 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535293138981899.5933503460376; Sun, 26 Aug 2018 07:18:58 -0700 (PDT) Received: from localhost ([::1]:49253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftvsJ-0005Y8-3z for importer@patchew.org; Sun, 26 Aug 2018 10:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftvl9-00082p-HB for qemu-devel@nongnu.org; Sun, 26 Aug 2018 10:11:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ftvl6-0006zQ-Dd for qemu-devel@nongnu.org; Sun, 26 Aug 2018 10:11:19 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:59579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ftvl4-0006U3-25; Sun, 26 Aug 2018 10:11:16 -0400 Received: from 85-76-74-234-nat.elisa-mobile.fi ([85.76.74.234] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ftvkQ-0004AP-KJ; Sun, 26 Aug 2018 16:10:34 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ftvkB-0004mS-9m; Sun, 26 Aug 2018 17:10:19 +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=tFTB5aaXEOoQMgFhqrQ4rRS35bmTLQMrc/03UdDRavU=; b=pTiwqsyQe2uGXEvKjycLU58JZL4ReamES1EJGiNOagoIbOG5KZIKfLpGcDxqwa9WKTPSiY1Wtfn+0vtPvziHDRq36ZMMUzCKDWJGNkKY9808fRfYd+aK9Qv+ssxet/C+4NJfuqDOOpTq5QcWcFJtszMdp1WFSZRuA0W1UxTLOySiwcFq0hmDb8PQAiVwofqI4Mswq6BDfm51Aj6m5wzg53rfOzKyZWkzVkT+d0YuhtCD34ZOjozLhid2IhwcTMaH/KIzg4vHCb2pIlW2eXB6yC+LBrIWpgINJn/cTnl3SWQ65JLjahwr6oN8UtYTmIODicDLgsPFcfSAHNs+yNnBuQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Sun, 26 Aug 2018 17:09:38 +0300 Message-Id: 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 7/9] block: Allow changing 'discard' on reopen 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" 'discard' is one of the basic BlockdevOptions available for all drivers, but it's silently ignored by bdrv_reopen_prepare/commit(), so the user cannot change it and doesn't get an error explaining that it can't be changed. This should update the discard setting, but does nothing: (qemu) qemu-io virtio0 "reopen -o discard=3Don" Since there's no reason why we shouldn't allow changing it and the implementation is simple let's just do it. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block.c b/block.c index 804d557608..21f1eb9cd1 100644 --- a/block.c +++ b/block.c @@ -3178,6 +3178,15 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, =20 update_flags_from_options(&reopen_state->flags, opts); =20 + value =3D qemu_opt_get(opts, "discard"); + if (value !=3D NULL) { + if (bdrv_parse_discard_flags(value, &reopen_state->flags) !=3D 0) { + error_setg(errp, "Invalid discard option"); + ret =3D -EINVAL; + goto error; + } + } + /* node-name and driver must be unchanged. Put them back into the QDic= t, so * that they are checked at the end of this function. */ value =3D qemu_opt_get(opts, "node-name"); --=20 2.11.0