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

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