From patchwork Wed Jun 5 13:25:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Louis Dupond X-Patchwork-Id: 13686898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 117FEC41513 for ; Wed, 5 Jun 2024 13:27:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEqes-0005nE-CJ; Wed, 05 Jun 2024 09:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEqer-0005mz-8V for qemu-devel@nongnu.org; Wed, 05 Jun 2024 09:26:29 -0400 Received: from apollo.dupie.be ([2001:bc8:3f2a:101::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEqep-00018B-F1 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 09:26:29 -0400 Received: from localhost.localdomain (unknown [IPv6:2a02:a03f:eaf7:ff01:ba43:94d2:9111:d35b]) by apollo.dupie.be (Postfix) with ESMTPSA id 9B1E91520F7E; Wed, 5 Jun 2024 15:26:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dupond.be; s=dkim; t=1717593983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RBkxwki7tUuoVBtRYWkiuRZfpRZcwCtLtLPtVTSPLlc=; b=OBMzrmZAMFU+4CDLqgq8+5Gi9FlLTQzgKERufeGJu4xo5nrIjHx9kp4m8bsYPdEMJKP1pj /uPMwvrEnkZ4FWx4uv+A9BTB5Ipxz6COCEsPj44jkaKpVeOR4n93V8EjBi4kiZjiDTmd/g ybAsOs3mEiJI5GtRmAKDSncSo4I68Jajge7rqm/XlMJkEtepU9hVsuaGR2fCbVx7kOiNLD 392EQ+3dE5+d/WZRFZLy2frmNA7dV8ZKMoE39NH+ELIt/0eeCvLyYk6Uk1Wtbb8wf6uLBN m9XCHtfdMp3aCweqXIniLU8XYQPHknISzsHTJ2fxBMfqWcwkoyh35ndLRhIQlw== From: Jean-Louis Dupond To: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, andrey.drobyshev@virtuozzo.com Cc: Jean-Louis Dupond Subject: [PATCH v2 2/2] qcow2: don't allow discard-no-unref when discard is not enabled Date: Wed, 5 Jun 2024 15:25:40 +0200 Message-ID: <20240605132539.3668497-3-jean-louis@dupond.be> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240605132539.3668497-2-jean-louis@dupond.be> References: <20240605132539.3668497-2-jean-louis@dupond.be> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:bc8:3f2a:101::1; envelope-from=jean-louis@dupond.be; helo=apollo.dupie.be X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org When discard is not set to unmap/on, we should not allow setting discard-no-unref. Signed-off-by: Jean-Louis Dupond --- block/qcow2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 50354e5b98..cead5479e4 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1156,6 +1156,12 @@ qcow2_update_options_prepare(BlockDriverState *bs, Qcow2ReopenState *r, ret = -EINVAL; goto fail; } + if (r->discard_no_unref && !(flags & BDRV_O_UNMAP)) { + error_setg(errp, + "discard-no-unref is only valid with discard=unmap/on"); + ret = -EINVAL; + goto fail; + } switch (s->crypt_method_header) { case QCOW_CRYPT_NONE: