Blame SOURCES/kvm-qemu-img-Amendment-support-implies-create_opts.patch

ae23c9
From 73102ec1ec9d6f19758734652b4872b9abb249c5 Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 14:59:37 +0200
ae23c9
Subject: [PATCH 064/268] qemu-img: Amendment support implies create_opts
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618145943.4489-2-mreitz@redhat.com>
ae23c9
Patchwork-id: 80758
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/7] qemu-img: Amendment support implies create_opts
ae23c9
Bugzilla: 1537956
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
Instead of checking whether a driver has a non-NULL create_opts we
ae23c9
should check whether it supports image amendment in the first place.  If
ae23c9
it does, it must have create_opts.
ae23c9
ae23c9
On the other hand, if it does not have create_opts (so it does not
ae23c9
support amendment either), the error message "does not support any
ae23c9
options" is a bit useless.  Stating clearly that the driver has no
ae23c9
amendment support whatsoever is probably better.
ae23c9
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Reviewed-by: John Snow <jsnow@redhat.com>
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Message-id: 20180509210023.20283-2-mreitz@redhat.com
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit 1f996683ad908fd41c572221a63d9fc31ce04d07)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 qemu-img.c | 7 +++++--
ae23c9
 1 file changed, 5 insertions(+), 2 deletions(-)
ae23c9
ae23c9
diff --git a/qemu-img.c b/qemu-img.c
ae23c9
index 60e45ec..2f7c491 100644
ae23c9
--- a/qemu-img.c
ae23c9
+++ b/qemu-img.c
ae23c9
@@ -3740,13 +3740,16 @@ static int img_amend(int argc, char **argv)
ae23c9
         goto out;
ae23c9
     }
ae23c9
 
ae23c9
-    if (!bs->drv->create_opts) {
ae23c9
-        error_report("Format driver '%s' does not support any options to amend",
ae23c9
+    if (!bs->drv->bdrv_amend_options) {
ae23c9
+        error_report("Format driver '%s' does not support option amendment",
ae23c9
                      fmt);
ae23c9
         ret = -1;
ae23c9
         goto out;
ae23c9
     }
ae23c9
 
ae23c9
+    /* Every driver supporting amendment must have create_opts */
ae23c9
+    assert(bs->drv->create_opts);
ae23c9
+
ae23c9
     create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
ae23c9
     opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
ae23c9
     qemu_opts_do_parse(opts, options, NULL, &err;;
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9