提交 83d4bf94 编写于 作者: D Daniel P. Berrange 提交者: Max Reitz

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: NFam Zheng <famz@redhat.com>
Reviewed-by: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
Message-id: 20170515164712.6643-2-berrange@redhat.com
Signed-off-by: NMax Reitz <mreitz@redhat.com>
上级 caa31bf2
...@@ -4158,6 +4158,7 @@ static int img_dd(int argc, char **argv) ...@@ -4158,6 +4158,7 @@ static int img_dd(int argc, char **argv)
}; };
const struct option long_options[] = { const struct option long_options[] = {
{ "help", no_argument, 0, 'h'}, { "help", no_argument, 0, 'h'},
{ "object", required_argument, 0, OPTION_OBJECT},
{ "image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, { "image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
{ "force-share", no_argument, 0, 'U'}, { "force-share", no_argument, 0, 'U'},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
...@@ -4186,6 +4187,15 @@ static int img_dd(int argc, char **argv) ...@@ -4186,6 +4187,15 @@ static int img_dd(int argc, char **argv)
case 'U': case 'U':
force_share = true; force_share = true;
break; 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: case OPTION_IMAGE_OPTS:
image_opts = true; image_opts = true;
break; break;
...@@ -4230,6 +4240,14 @@ static int img_dd(int argc, char **argv) ...@@ -4230,6 +4240,14 @@ static int img_dd(int argc, char **argv)
ret = -1; ret = -1;
goto out; 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, blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share); force_share);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册