From nobody Mon Feb 9 23:01:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492674904613476.915020556306; Thu, 20 Apr 2017 00:55:04 -0700 (PDT) Received: from localhost ([::1]:52100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16vf-000071-1M for importer@patchew.org; Thu, 20 Apr 2017 03:55:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16to-000739-Fr for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tl-0003Jm-UA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tg-0003HE-86; Thu, 20 Apr 2017 03:53:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A1154AEBE; Thu, 20 Apr 2017 07:52:59 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 890E2183D6; Thu, 20 Apr 2017 07:52:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A1154AEBE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1A1154AEBE From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:21 +0800 Message-Id: <20170420075237.18219-5-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Apr 2017 07:52:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 04/20] qemu-img: Add --unsafe-read option to subcommands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- qemu-img.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 114 insertions(+), 34 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index b220cf7..b9dcd3e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -283,12 +283,15 @@ static int img_open_password(BlockBackend *blk, const= char *filename, =20 static BlockBackend *img_open_opts(const char *optstr, QemuOpts *opts, int flags, bool writeth= rough, - bool quiet) + bool quiet, bool unsafe) { QDict *options; Error *local_err =3D NULL; BlockBackend *blk; options =3D qemu_opts_to_qdict(opts, NULL); + if (unsafe) { + flags |=3D BDRV_O_UNSAFE_READ; + } blk =3D blk_new_open(NULL, NULL, options, flags, &local_err); if (!blk) { error_reportf_err(local_err, "Could not open '%s': ", optstr); @@ -305,7 +308,7 @@ static BlockBackend *img_open_opts(const char *optstr, =20 static BlockBackend *img_open_file(const char *filename, const char *fmt, int flags, - bool writethrough, bool quiet) + bool writethrough, bool quiet, bool uns= afe) { BlockBackend *blk; Error *local_err =3D NULL; @@ -316,6 +319,9 @@ static BlockBackend *img_open_file(const char *filename, qdict_put(options, "driver", qstring_from_str(fmt)); } =20 + if (unsafe) { + flags |=3D BDRV_O_UNSAFE_READ; + } blk =3D blk_new_open(filename, NULL, options, flags, &local_err); if (!blk) { error_reportf_err(local_err, "Could not open '%s': ", filename); @@ -334,7 +340,7 @@ static BlockBackend *img_open_file(const char *filename, static BlockBackend *img_open(bool image_opts, const char *filename, const char *fmt, int flags, bool writethroug= h, - bool quiet) + bool quiet, bool unsafe) { BlockBackend *blk; if (image_opts) { @@ -348,9 +354,9 @@ static BlockBackend *img_open(bool image_opts, if (!opts) { return NULL; } - blk =3D img_open_opts(filename, opts, flags, writethrough, quiet); + blk =3D img_open_opts(filename, opts, flags, writethrough, quiet, = unsafe); } else { - blk =3D img_open_file(filename, fmt, flags, writethrough, quiet); + blk =3D img_open_file(filename, fmt, flags, writethrough, quiet, u= nsafe); } return blk; } @@ -650,6 +656,7 @@ static int img_check(int argc, char **argv) ImageCheck *check; bool quiet =3D false; bool image_opts =3D false; + bool unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -664,9 +671,10 @@ static int img_check(int argc, char **argv) {"output", required_argument, 0, OPTION_OUTPUT}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:r:T:q", + c =3D getopt_long(argc, argv, ":hf:r:T:qU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -705,6 +713,9 @@ static int img_check(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -744,7 +755,8 @@ static int img_check(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + unsafe_read); if (!blk) { return 1; } @@ -864,6 +876,7 @@ static int img_commit(int argc, char **argv) CommonBlockJobCBInfo cbi; bool image_opts =3D false; AioContext *aio_context; + bool unsafe_read =3D false; =20 fmt =3D NULL; cache =3D BDRV_DEFAULT_CACHE; @@ -873,9 +886,10 @@ static int img_commit(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:ht:b:dpq", + c =3D getopt_long(argc, argv, ":f:ht:b:dpqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -910,6 +924,9 @@ static int img_commit(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -947,7 +964,8 @@ static int img_commit(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + unsafe_read); if (!blk) { return 1; } @@ -1206,6 +1224,7 @@ static int img_compare(int argc, char **argv) int c, pnum; uint64_t progress_base; bool image_opts =3D false; + bool unsafe_read =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -1213,9 +1232,10 @@ static int img_compare(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:F:T:pqs", + c =3D getopt_long(argc, argv, ":hf:F:T:pqsU", long_options, NULL); if (c =3D=3D -1) { break; @@ -1248,6 +1268,9 @@ static int img_compare(int argc, char **argv) case 's': strict =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -1293,13 +1316,15 @@ static int img_compare(int argc, char **argv) goto out3; } =20 - blk1 =3D img_open(image_opts, filename1, fmt1, flags, writethrough, qu= iet); + blk1 =3D img_open(image_opts, filename1, fmt1, flags, writethrough, qu= iet, + unsafe_read); if (!blk1) { ret =3D 2; goto out3; } =20 - blk2 =3D img_open(image_opts, filename2, fmt2, flags, writethrough, qu= iet); + blk2 =3D img_open(image_opts, filename2, fmt2, flags, writethrough, qu= iet, + unsafe_read); if (!blk2) { ret =3D 2; goto out2; @@ -1941,6 +1966,7 @@ static int img_convert(int argc, char **argv) bool image_opts =3D false; bool wr_in_order =3D true; long num_coroutines =3D 8; + bool unsafe_read =3D false; =20 fmt =3D NULL; out_fmt =3D "raw"; @@ -1954,9 +1980,10 @@ static int img_convert(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:O:B:ce6o:s:l:S:pt:T:qnm:W", + c =3D getopt_long(argc, argv, ":hf:O:B:ce6o:s:l:S:pt:T:qnm:WU", long_options, NULL); if (c =3D=3D -1) { break; @@ -2065,6 +2092,9 @@ static int img_convert(int argc, char **argv) case 'W': wr_in_order =3D false; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: opts =3D qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); @@ -2132,7 +2162,8 @@ static int img_convert(int argc, char **argv) total_sectors =3D 0; for (bs_i =3D 0; bs_i < bs_n; bs_i++) { blk[bs_i] =3D img_open(image_opts, argv[optind + bs_i], - fmt, src_flags, src_writethrough, quiet); + fmt, src_flags, src_writethrough, quiet, + unsafe_read); if (!blk[bs_i]) { ret =3D -1; goto out; @@ -2277,7 +2308,8 @@ static int img_convert(int argc, char **argv) * the bdrv_create() call which takes different params. * Not critical right now, so fix can wait... */ - out_blk =3D img_open_file(out_filename, out_fmt, flags, writethrough, = quiet); + out_blk =3D img_open_file(out_filename, out_fmt, flags, writethrough, = quiet, + unsafe_read); if (!out_blk) { ret =3D -1; goto out; @@ -2448,7 +2480,7 @@ static gboolean str_equal_func(gconstpointer a, gcons= tpointer b) static ImageInfoList *collect_image_info_list(bool image_opts, const char *filename, const char *fmt, - bool chain) + bool chain, bool unsafe) { ImageInfoList *head =3D NULL; ImageInfoList **last =3D &head; @@ -2471,7 +2503,8 @@ static ImageInfoList *collect_image_info_list(bool im= age_opts, g_hash_table_insert(filenames, (gpointer)filename, NULL); =20 blk =3D img_open(image_opts, filename, fmt, - BDRV_O_NO_BACKING | BDRV_O_NO_IO, false, false); + BDRV_O_NO_BACKING | BDRV_O_NO_IO, false, false, + unsafe); if (!blk) { goto err; } @@ -2523,6 +2556,7 @@ static int img_info(int argc, char **argv) const char *filename, *fmt, *output; ImageInfoList *list; bool image_opts =3D false; + bool unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2535,9 +2569,10 @@ static int img_info(int argc, char **argv) {"backing-chain", no_argument, 0, OPTION_BACKING_CHAIN}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:h", + c =3D getopt_long(argc, argv, ":f:hU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -2555,6 +2590,9 @@ static int img_info(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2594,7 +2632,8 @@ static int img_info(int argc, char **argv) return 1; } =20 - list =3D collect_image_info_list(image_opts, filename, fmt, chain); + list =3D collect_image_info_list(image_opts, filename, fmt, chain, + unsafe_read); if (!list) { return 1; } @@ -2740,6 +2779,7 @@ static int img_map(int argc, char **argv) MapEntry curr =3D { .length =3D 0 }, next; int ret =3D 0; bool image_opts =3D false; + bool unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2751,9 +2791,10 @@ static int img_map(int argc, char **argv) {"output", required_argument, 0, OPTION_OUTPUT}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:h", + c =3D getopt_long(argc, argv, ":f:hU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -2771,6 +2812,9 @@ static int img_map(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2807,7 +2851,7 @@ static int img_map(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, 0, false, false); + blk =3D img_open(image_opts, filename, fmt, 0, false, false, unsafe_re= ad); if (!blk) { return 1; } @@ -2870,6 +2914,7 @@ static int img_snapshot(int argc, char **argv) bool quiet =3D false; Error *err =3D NULL; bool image_opts =3D false; + bool unsafe_read =3D false; =20 bdrv_oflags =3D BDRV_O_RDWR; /* Parse commandline parameters */ @@ -2878,9 +2923,10 @@ static int img_snapshot(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":la:c:d:hq", + c =3D getopt_long(argc, argv, ":la:c:d:hqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -2930,6 +2976,9 @@ static int img_snapshot(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -2956,7 +3005,8 @@ static int img_snapshot(int argc, char **argv) } =20 /* Open the image */ - blk =3D img_open(image_opts, filename, NULL, bdrv_oflags, false, quiet= ); + blk =3D img_open(image_opts, filename, NULL, bdrv_oflags, false, quiet, + unsafe_read); if (!blk) { return 1; } @@ -3020,6 +3070,7 @@ static int img_rebase(int argc, char **argv) int c, flags, src_flags, ret; bool writethrough, src_writethrough; int unsafe =3D 0; + bool unsafe_read =3D 0; int progress =3D 0; bool quiet =3D false; Error *local_err =3D NULL; @@ -3036,9 +3087,10 @@ static int img_rebase(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:F:b:upt:T:q", + c =3D getopt_long(argc, argv, ":hf:F:b:upt:T:qU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3088,6 +3140,9 @@ static int img_rebase(int argc, char **argv) case OPTION_IMAGE_OPTS: image_opts =3D true; break; + case 'U': + unsafe_read =3D true; + break; } } =20 @@ -3136,7 +3191,8 @@ static int img_rebase(int argc, char **argv) * Ignore the old backing file for unsafe rebase in case we want to co= rrect * the reference to a renamed or moved backing file. */ - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3161,6 +3217,9 @@ static int img_rebase(int argc, char **argv) qdict_put(options, "driver", qstring_from_str(bs->backing_form= at)); } =20 + if (unsafe_read) { + src_flags |=3D BDRV_O_UNSAFE_READ; + } bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); blk_old_backing =3D blk_new_open(backing_name, NULL, options, src_flags, &local_err); @@ -3376,6 +3435,7 @@ static int img_resize(int argc, char **argv) bool quiet =3D false; BlockBackend *blk =3D NULL; QemuOpts *param; + bool unsafe_read =3D true; =20 static QemuOptsList resize_options =3D { .name =3D "resize_options", @@ -3408,9 +3468,10 @@ static int img_resize(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:hq", + c =3D getopt_long(argc, argv, ":f:hqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3431,6 +3492,9 @@ static int img_resize(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -3483,7 +3547,8 @@ static int img_resize(int argc, char **argv) qemu_opts_del(param); =20 blk =3D img_open(image_opts, filename, fmt, - BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); + BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3544,6 +3609,7 @@ static int img_amend(int argc, char **argv) BlockBackend *blk =3D NULL; BlockDriverState *bs =3D NULL; bool image_opts =3D false; + bool unsafe_read =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -3551,9 +3617,10 @@ static int img_amend(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":ho:f:t:pq", + c =3D getopt_long(argc, argv, ":ho:f:t:pqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3646,7 +3713,8 @@ static int img_amend(int argc, char **argv) goto out; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3814,6 +3882,7 @@ static int img_bench(int argc, char **argv) bool writethrough =3D false; struct timeval t1, t2; int i; + bool unsafe_read =3D false; =20 for (;;) { static const struct option long_options[] =3D { @@ -3822,9 +3891,10 @@ static int img_bench(int argc, char **argv) {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"pattern", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hc:d:f:no:qs:S:t:w", long_options,= NULL); + c =3D getopt_long(argc, argv, ":hc:d:f:no:qs:S:t:wU", long_options= , NULL); if (c =3D=3D -1) { break; } @@ -3918,6 +3988,9 @@ static int img_bench(int argc, char **argv) flags |=3D BDRV_O_RDWR; is_write =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_PATTERN: { unsigned long res; @@ -3965,7 +4038,8 @@ static int img_bench(int argc, char **argv) goto out; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -4132,6 +4206,7 @@ static int img_dd(int argc, char **argv) const char *fmt =3D NULL; int64_t size =3D 0; int64_t block_count =3D 0, out_pos, in_pos; + bool unsafe_read =3D false; struct DdInfo dd =3D { .flags =3D 0, .count =3D 0, @@ -4160,10 +4235,11 @@ static int img_dd(int argc, char **argv) const struct option long_options[] =3D { { "help", no_argument, 0, 'h'}, { "image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + { "unsafe-read", no_argument, 0, 'U'}, { 0, 0, 0, 0 } }; =20 - while ((c =3D getopt_long(argc, argv, ":hf:O:", long_options, NULL))) { + while ((c =3D getopt_long(argc, argv, ":hf:O:U", long_options, NULL)))= { if (c =3D=3D EOF) { break; } @@ -4183,6 +4259,9 @@ static int img_dd(int argc, char **argv) case 'h': help(); break; + case 'U': + unsafe_read =3D true; + break; case OPTION_IMAGE_OPTS: image_opts =3D true; break; @@ -4227,7 +4306,8 @@ static int img_dd(int argc, char **argv) ret =3D -1; goto out; } - blk1 =3D img_open(image_opts, in.filename, fmt, 0, false, false); + blk1 =3D img_open(image_opts, in.filename, fmt, 0, false, false, + unsafe_read); =20 if (!blk1) { ret =3D -1; @@ -4295,7 +4375,7 @@ static int img_dd(int argc, char **argv) } =20 blk2 =3D img_open(image_opts, out.filename, out_fmt, BDRV_O_RDWR, - false, false); + false, false, unsafe_read); =20 if (!blk2) { ret =3D -1; --=20 2.9.3