aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-12-02 18:32:47 +0100
committerKevin Wolf <kwolf@redhat.com>2014-12-10 10:31:20 +0100
commitb2439d26f078c826e5e06b34d978a6f6d5c7c56f (patch)
treeecec50e0e8f301ed865f9c1e40d8a9fd030f532a /qemu-img.c
parentf75613cf2488a37fb8019bc32a06ddbcd477d0ce (diff)
qemu-img: Check create_opts before image amendment
The image options which can be amended are described by the .create_opts field for every driver. This field must therefore be non-NULL so that anything can be amended in the first place. Check that this holds true before going into qemu_opts_create() (because if .create_opts is NULL, the create_opts pointer in img_amend() will be NULL after qemu_opts_append()). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 8c4edf37a9..7876258fa9 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2986,6 +2986,13 @@ static int img_amend(int argc, char **argv)
goto out;
}
+ if (!bs->drv->create_opts) {
+ error_report("Format driver '%s' does not support any options to amend",
+ fmt);
+ ret = -1;
+ goto out;
+ }
+
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (options && qemu_opts_do_parse(opts, options, NULL)) {