aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2017-05-15 17:47:09 +0100
committerMax Reitz <mreitz@redhat.com>2017-05-29 15:39:53 +0200
commit83d4bf943e09cbcb011e255c872724e95fe4856e (patch)
treec2001d220852ccdd8e7361715832ca9518199d58
parentcaa31bf28c0c3e2930540ad6a95935f92551b7eb (diff)
qemu-img: add support for --object with 'dd' command
The qemu-img dd command added --image-opts support, but missed the corresponding --object support. This prevented passing secrets (eg auth passwords) needed by certain disk images. Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 20170515164712.6643-2-berrange@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
-rw-r--r--qemu-img.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/qemu-img.c b/qemu-img.c
index b506839ef0..181f49956b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4158,6 +4158,7 @@ static int img_dd(int argc, char **argv)
};
const struct option long_options[] = {
{ "help", no_argument, 0, 'h'},
+ { "object", required_argument, 0, OPTION_OBJECT},
{ "image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
{ "force-share", no_argument, 0, 'U'},
{ 0, 0, 0, 0 }
@@ -4186,6 +4187,15 @@ static int img_dd(int argc, char **argv)
case 'U':
force_share = true;
break;
+ case OPTION_OBJECT: {
+ QemuOpts *opts;
+ opts = qemu_opts_parse_noisily(&qemu_object_opts,
+ optarg, true);
+ if (!opts) {
+ ret = -1;
+ goto out;
+ }
+ } break;
case OPTION_IMAGE_OPTS:
image_opts = true;
break;
@@ -4230,6 +4240,14 @@ static int img_dd(int argc, char **argv)
ret = -1;
goto out;
}
+
+ if (qemu_opts_foreach(&qemu_object_opts,
+ user_creatable_add_opts_foreach,
+ NULL, NULL)) {
+ ret = -1;
+ goto out;
+ }
+
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share);