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

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