On 7/10/24 15:00, Hanna Czenczek wrote:
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.
No it doesn't hurt, but it's 'cleaner'.
But indeed, if its a hassle to get that resolved, we can leave it like
this.
(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.)
I don't think a lot of people use the discard-no-unref option (yet).
Hanna
Signed-off-by: Jean-Louis Dupond <jean-lo...@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: