yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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