qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/2] qcow2: don't allow discard-no-unref when discard is n


From: Hanna Czenczek
Subject: Re: [PATCH v2 2/2] qcow2: don't allow discard-no-unref when discard is not enabled
Date: Wed, 10 Jul 2024 15:00:00 +0200
User-agent: Mozilla Thunderbird

On 05.06.24 15:25, Jean-Louis Dupond wrote:
When discard is not set to unmap/on, we should not allow setting
discard-no-unref.

Is this important?  Technically, it’s an incompatible change, and would require a deprecation warning first.

(I can imagine people setting this option indiscriminately on all image, whether discard actually plays a role or not.  It may make sense for them.)

Hanna

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
---
  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:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]