|
|
ae23c9 |
From bdd2925eaebdbba0400da3ebef201f402c3cee90 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 18 Jun 2018 14:59:41 +0200
|
|
|
ae23c9 |
Subject: [PATCH 068/268] qemu-img: Recognize no creation support in -o help
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618145943.4489-6-mreitz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80759
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 5/7] qemu-img: Recognize no creation support in -o help
|
|
|
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 |
The only users of print_block_option_help() are qemu-img create and
|
|
|
ae23c9 |
qemu-img convert for the output image, so this function is always used
|
|
|
ae23c9 |
for image creation (it used to be used for amendment also, but that is
|
|
|
ae23c9 |
no longer the case).
|
|
|
ae23c9 |
|
|
|
ae23c9 |
So if image creation is not supported by either the format or the
|
|
|
ae23c9 |
protocol, there is no need to print any option description, because the
|
|
|
ae23c9 |
user cannot create an image like this anyway.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This also fixes an assertion failure:
|
|
|
ae23c9 |
|
|
|
ae23c9 |
$ qemu-img create -f bochs -o help
|
|
|
ae23c9 |
Supported options:
|
|
|
ae23c9 |
qemu-img: util/qemu-option.c:219:
|
|
|
ae23c9 |
qemu_opts_print_help: Assertion `list' failed.
|
|
|
ae23c9 |
[1] 24831 abort (core dumped) qemu-img create -f bochs -o help
|
|
|
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-6-mreitz@redhat.com
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit d402b6a21a825a5c07aac9251990860723d49f5d)
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
qemu-img.c | 10 ++++++++++
|
|
|
ae23c9 |
1 file changed, 10 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
ae23c9 |
index d4cbb63..4bcf157 100644
|
|
|
ae23c9 |
--- a/qemu-img.c
|
|
|
ae23c9 |
+++ b/qemu-img.c
|
|
|
ae23c9 |
@@ -250,6 +250,11 @@ static int print_block_option_help(const char *filename, const char *fmt)
|
|
|
ae23c9 |
return 1;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ if (!drv->create_opts) {
|
|
|
ae23c9 |
+ error_report("Format driver '%s' does not support image creation", fmt);
|
|
|
ae23c9 |
+ return 1;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
create_opts = qemu_opts_append(create_opts, drv->create_opts);
|
|
|
ae23c9 |
if (filename) {
|
|
|
ae23c9 |
proto_drv = bdrv_find_protocol(filename, true, &local_err);
|
|
|
ae23c9 |
@@ -258,6 +263,11 @@ static int print_block_option_help(const char *filename, const char *fmt)
|
|
|
ae23c9 |
qemu_opts_free(create_opts);
|
|
|
ae23c9 |
return 1;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
+ if (!proto_drv->create_opts) {
|
|
|
ae23c9 |
+ error_report("Protocal driver '%s' does not support image creation",
|
|
|
ae23c9 |
+ proto_drv->format_name);
|
|
|
ae23c9 |
+ return 1;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|