* [PULL 0/6] NBD patches for 2020-05-18
@ 2020-05-18 16:32 Eric Blake
2020-05-18 16:32 ` [PULL 1/6] qemu-nbd: Close inherited stderr Eric Blake
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel
The following changes since commit debe78ce14bf8f8940c2bdf3ef387505e9e035a9:
Merge remote-tracking branch 'remotes/rth/tags/pull-fpu-20200515' into staging (2020-05-15 19:51:16 +0100)
are available in the Git repository at:
https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-05-18
for you to fetch changes up to d8154b0945f795177511ea0e2212bd5c749fe84c:
iotests: Enhance 223 to cover qemu-img map improvements (2020-05-18 11:02:05 -0500)
We've got a couple of first-time contributors included in this one :)
----------------------------------------------------------------
nbd patches for 2020-05-20
- fix stranded fd in 'qemu-nbd -c /dev/nbd0'
- add 'qemu-img map --start-offset --max-length' options
----------------------------------------------------------------
Eric Blake (1):
iotests: Enhance 223 to cover qemu-img map improvements
Eyal Moscovici (4):
qemu_img: add cvtnum_full to print error reports
qemu-img: validate image length in img_map
qemu-img: refactor dump_map_entry JSON format output
qemu-img: Add --start-offset and --max-length to map
Raphael Pour (1):
qemu-nbd: Close inherited stderr
docs/tools/qemu-img.rst | 2 +-
qemu-img.c | 113 +++++++++++++++++++++++++++------------------
qemu-nbd.c | 6 ++-
qemu-img-cmds.hx | 4 +-
tests/qemu-iotests/049.out | 8 ++--
tests/qemu-iotests/223 | 6 ++-
tests/qemu-iotests/223.out | 3 +-
7 files changed, 85 insertions(+), 57 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PULL 1/6] qemu-nbd: Close inherited stderr
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-18 16:32 ` [PULL 2/6] qemu_img: add cvtnum_full to print error reports Eric Blake
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel; +Cc: open list:Network Block Dev..., Raphael Pour
From: Raphael Pour <raphael.pour@hetzner.com>
Close inherited stderr of the parent if fork_process is false.
Otherwise no one will close it. (introduced by e6df58a5)
This only affected 'qemu-nbd -c /dev/nbd0'.
Signed-off-by: Raphael Pour <raphael.pour@hetzner.com>
Message-Id: <d8ddc993-9816-836e-a3de-c6edab9d9c49@hetzner.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: Enhance commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-nbd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 4aa005004ebd..306e44fb0a4b 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -916,7 +916,11 @@ int main(int argc, char **argv)
} else if (pid == 0) {
close(stderr_fd[0]);
- old_stderr = dup(STDERR_FILENO);
+ /* Remember parent's stderr if we will be restoring it. */
+ if (fork_process) {
+ old_stderr = dup(STDERR_FILENO);
+ }
+
ret = qemu_daemon(1, 0);
/* Temporarily redirect stderr to the parent's pipe... */
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 2/6] qemu_img: add cvtnum_full to print error reports
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
2020-05-18 16:32 ` [PULL 1/6] qemu-nbd: Close inherited stderr Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-20 21:39 ` Eric Blake
2020-05-18 16:32 ` [PULL 3/6] qemu-img: validate image length in img_map Eric Blake
` (5 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Eyal Moscovici, open list:Block layer core, Max Reitz
From: Eyal Moscovici <eyal.moscovici@oracle.com>
All calls to cvtnum check the return value and print the same error
message more or less. And so error reporting moved to cvtnum_full to
reduce code duplication and provide a single error
message. Additionally, cvtnum now wraps cvtnum_full with the existing
default range of 0 to MAX_INT64.
Acked-by: Mark Kanda <mark.kanda@oracle.com>
Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Message-Id: <20200513133629.18508-2-eyal.moscovici@oracle.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: fix printf formatting, avoid trailing space, change error wording,
reformat commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-img.c | 74 +++++++++++++++++---------------------
tests/qemu-iotests/049.out | 8 ++---
2 files changed, 37 insertions(+), 45 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 6a4327aaba56..5d824fc15f39 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -470,19 +470,31 @@ static int add_old_style_options(const char *fmt, QemuOpts *opts,
return 0;
}
-static int64_t cvtnum(const char *s)
+static int64_t cvtnum_full(const char *name, const char *value, int64_t min,
+ int64_t max)
{
int err;
- uint64_t value;
+ uint64_t res;
- err = qemu_strtosz(s, NULL, &value);
- if (err < 0) {
+ err = qemu_strtosz(value, NULL, &res);
+ if (err < 0 && err != -ERANGE) {
+ error_report("Invalid %s specified. You may use "
+ "k, M, G, T, P or E suffixes for", name);
+ error_report("kilobytes, megabytes, gigabytes, terabytes, "
+ "petabytes and exabytes.");
return err;
}
- if (value > INT64_MAX) {
+ if (err == -ERANGE || res > max || res < min) {
+ error_report("Invalid %s specified. Must be between %" PRId64
+ " and %" PRId64 ".", name, min, max);
return -ERANGE;
}
- return value;
+ return res;
+}
+
+static int64_t cvtnum(const char *name, const char *value)
+{
+ return cvtnum_full(name, value, 0, INT64_MAX);
}
static int img_create(int argc, char **argv)
@@ -572,16 +584,8 @@ static int img_create(int argc, char **argv)
if (optind < argc) {
int64_t sval;
- sval = cvtnum(argv[optind++]);
+ sval = cvtnum("image size", argv[optind++]);
if (sval < 0) {
- if (sval == -ERANGE) {
- error_report("Image size must be less than 8 EiB!");
- } else {
- error_report("Invalid image size specified! You may use k, M, "
- "G, T, P or E suffixes for ");
- error_report("kilobytes, megabytes, gigabytes, terabytes, "
- "petabytes and exabytes.");
- }
goto fail;
}
img_size = (uint64_t)sval;
@@ -2187,8 +2191,10 @@ static int img_convert(int argc, char **argv)
{
int64_t sval;
- sval = cvtnum(optarg);
- if (sval < 0 || !QEMU_IS_ALIGNED(sval, BDRV_SECTOR_SIZE) ||
+ sval = cvtnum("buffer size for sparse output", optarg);
+ if (sval < 0) {
+ goto fail_getopt;
+ } else if (!QEMU_IS_ALIGNED(sval, BDRV_SECTOR_SIZE) ||
sval / BDRV_SECTOR_SIZE > MAX_BUF_SECTORS) {
error_report("Invalid buffer size for sparse output specified. "
"Valid sizes are multiples of %llu up to %llu. Select "
@@ -4291,9 +4297,8 @@ static int img_bench(int argc, char **argv)
break;
case 'o':
{
- offset = cvtnum(optarg);
+ offset = cvtnum("offset", optarg);
if (offset < 0) {
- error_report("Invalid offset specified");
return 1;
}
break;
@@ -4306,9 +4311,8 @@ static int img_bench(int argc, char **argv)
{
int64_t sval;
- sval = cvtnum(optarg);
- if (sval < 0 || sval > INT_MAX) {
- error_report("Invalid buffer size specified");
+ sval = cvtnum_full("buffer size", optarg, 0, INT_MAX);
+ if (sval < 0) {
return 1;
}
@@ -4319,9 +4323,8 @@ static int img_bench(int argc, char **argv)
{
int64_t sval;
- sval = cvtnum(optarg);
- if (sval < 0 || sval > INT_MAX) {
- error_report("Invalid step size specified");
+ sval = cvtnum_full("step_size", optarg, 0, INT_MAX);
+ if (sval < 0) {
return 1;
}
@@ -4491,10 +4494,9 @@ static int img_dd_bs(const char *arg,
{
int64_t res;
- res = cvtnum(arg);
+ res = cvtnum_full("bs", arg, 1, INT_MAX);
- if (res <= 0 || res > INT_MAX) {
- error_report("invalid number: '%s'", arg);
+ if (res < 0) {
return 1;
}
in->bsz = out->bsz = res;
@@ -4506,10 +4508,9 @@ static int img_dd_count(const char *arg,
struct DdIo *in, struct DdIo *out,
struct DdInfo *dd)
{
- dd->count = cvtnum(arg);
+ dd->count = cvtnum("count", arg);
if (dd->count < 0) {
- error_report("invalid number: '%s'", arg);
return 1;
}
@@ -4538,10 +4539,9 @@ static int img_dd_skip(const char *arg,
struct DdIo *in, struct DdIo *out,
struct DdInfo *dd)
{
- in->offset = cvtnum(arg);
+ in->offset = cvtnum("skip", arg);
if (in->offset < 0) {
- error_report("invalid number: '%s'", arg);
return 1;
}
@@ -4923,16 +4923,8 @@ static int img_measure(int argc, char **argv)
{
int64_t sval;
- sval = cvtnum(optarg);
+ sval = cvtnum("image size", optarg);
if (sval < 0) {
- if (sval == -ERANGE) {
- error_report("Image size must be less than 8 EiB!");
- } else {
- error_report("Invalid image size specified! You may use "
- "k, M, G, T, P or E suffixes for ");
- error_report("kilobytes, megabytes, gigabytes, terabytes, "
- "petabytes and exabytes.");
- }
goto out;
}
img_size = (uint64_t)sval;
diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out
index a5cfba175626..c54ae21b868a 100644
--- a/tests/qemu-iotests/049.out
+++ b/tests/qemu-iotests/049.out
@@ -92,19 +92,19 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1649267441664 cluster_size=65536 l
== 3. Invalid sizes ==
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1024
-qemu-img: Image size must be less than 8 EiB!
+qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
qemu-img create -f qcow2 -o size=-1024 TEST_DIR/t.qcow2
qemu-img: TEST_DIR/t.qcow2: Value '-1024' is out of range for parameter 'size'
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1k
-qemu-img: Image size must be less than 8 EiB!
+qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
qemu-img create -f qcow2 -o size=-1k TEST_DIR/t.qcow2
qemu-img: TEST_DIR/t.qcow2: Value '-1k' is out of range for parameter 'size'
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte
-qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for
+qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
qemu-img create -f qcow2 -o size=1kilobyte TEST_DIR/t.qcow2
@@ -113,7 +113,7 @@ Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta-
and exabytes, respectively.
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- foobar
-qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for
+qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 3/6] qemu-img: validate image length in img_map
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
2020-05-18 16:32 ` [PULL 1/6] qemu-nbd: Close inherited stderr Eric Blake
2020-05-18 16:32 ` [PULL 2/6] qemu_img: add cvtnum_full to print error reports Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-18 16:32 ` [PULL 4/6] qemu-img: refactor dump_map_entry JSON format output Eric Blake
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Eyal Moscovici, open list:Block layer core, Max Reitz
From: Eyal Moscovici <eyal.moscovici@oracle.com>
The code handles this case correctly: we merely skip the loop. However it
is probably best to return an explicit error.
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Mark Kanda <mark.kanda@oracle.com>
Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Message-Id: <20200513133629.18508-3-eyal.moscovici@oracle.com>
[eblake: commit message tweak]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-img.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/qemu-img.c b/qemu-img.c
index 5d824fc15f39..c88f412333ec 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3092,6 +3092,11 @@ static int img_map(int argc, char **argv)
}
length = blk_getlength(blk);
+ if (length < 0) {
+ error_report("Failed to get size for '%s'", filename);
+ return 1;
+ }
+
while (curr.start + curr.length < length) {
int64_t offset = curr.start + curr.length;
int64_t n;
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 4/6] qemu-img: refactor dump_map_entry JSON format output
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
` (2 preceding siblings ...)
2020-05-18 16:32 ` [PULL 3/6] qemu-img: validate image length in img_map Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-18 16:32 ` [PULL 5/6] qemu-img: Add --start-offset and --max-length to map Eric Blake
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Eyal Moscovici, open list:Block layer core, Max Reitz
From: Eyal Moscovici <eyal.moscovici@oracle.com>
Previously dump_map_entry identified whether we need to start a new JSON
array based on whether start address == 0. In this refactor we remove
this assumption as in following patches we will allow map to start from
an arbitrary position.
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Mark Kanda <mark.kanda@oracle.com>
Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Message-Id: <20200513133629.18508-4-eyal.moscovici@oracle.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-img.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index c88f412333ec..4aa9414aba6f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2902,9 +2902,8 @@ static int dump_map_entry(OutputFormat output_format, MapEntry *e,
}
break;
case OFORMAT_JSON:
- printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64","
+ printf("{ \"start\": %"PRId64", \"length\": %"PRId64","
" \"depth\": %"PRId64", \"zero\": %s, \"data\": %s",
- (e->start == 0 ? "[" : ",\n"),
e->start, e->length, e->depth,
e->zero ? "true" : "false",
e->data ? "true" : "false");
@@ -2913,8 +2912,8 @@ static int dump_map_entry(OutputFormat output_format, MapEntry *e,
}
putchar('}');
- if (!next) {
- printf("]\n");
+ if (next) {
+ puts(",");
}
break;
}
@@ -3089,6 +3088,8 @@ static int img_map(int argc, char **argv)
if (output_format == OFORMAT_HUMAN) {
printf("%-16s%-16s%-16s%s\n", "Offset", "Length", "Mapped to", "File");
+ } else if (output_format == OFORMAT_JSON) {
+ putchar('[');
}
length = blk_getlength(blk);
@@ -3125,6 +3126,9 @@ static int img_map(int argc, char **argv)
}
ret = dump_map_entry(output_format, &curr, NULL);
+ if (output_format == OFORMAT_JSON) {
+ puts("]");
+ }
out:
blk_unref(blk);
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 5/6] qemu-img: Add --start-offset and --max-length to map
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
` (3 preceding siblings ...)
2020-05-18 16:32 ` [PULL 4/6] qemu-img: refactor dump_map_entry JSON format output Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-18 16:32 ` [PULL 6/6] iotests: Enhance 223 to cover qemu-img map improvements Eric Blake
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Eyal Moscovici, open list:Block layer core,
Max Reitz, Yoav Elnekave
From: Eyal Moscovici <eyal.moscovici@oracle.com>
The mapping operation of large disks especially ones stored over a
long chain of QCOW2 files can take a long time to finish.
Additionally when mapping fails there was no way recover by
restarting the mapping from the failed location.
The new options, --start-offset and --max-length allows the user to
divide these type of map operations into shorter independent tasks.
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Mark Kanda <mark.kanda@oracle.com>
Co-developed-by: Yoav Elnekave <yoav.elnekave@oracle.com>
Signed-off-by: Yoav Elnekave <yoav.elnekave@oracle.com>
Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Message-Id: <20200513133629.18508-5-eyal.moscovici@oracle.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
docs/tools/qemu-img.rst | 2 +-
qemu-img.c | 22 +++++++++++++++++++++-
qemu-img-cmds.hx | 4 ++--
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index 0080f83a76c9..f4ffe528ea83 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -519,7 +519,7 @@ Command description:
``ImageInfoSpecific*`` QAPI object (e.g. ``ImageInfoSpecificQCow2``
for qcow2 images).
-.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [-U] FILENAME
+.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--start-offset=OFFSET] [--max-length=LEN] [--output=OFMT] [-U] FILENAME
Dump the metadata of image *FILENAME* and its backing file chain.
In particular, this commands dumps the allocation state of every sector
diff --git a/qemu-img.c b/qemu-img.c
index 4aa9414aba6f..947bf8b34b3d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3009,6 +3009,8 @@ static int img_map(int argc, char **argv)
int ret = 0;
bool image_opts = false;
bool force_share = false;
+ int64_t start_offset = 0;
+ int64_t max_length = -1;
fmt = NULL;
output = NULL;
@@ -3021,9 +3023,11 @@ static int img_map(int argc, char **argv)
{"object", required_argument, 0, OPTION_OBJECT},
{"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
{"force-share", no_argument, 0, 'U'},
+ {"start-offset", required_argument, 0, 's'},
+ {"max-length", required_argument, 0, 'l'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, ":f:hU",
+ c = getopt_long(argc, argv, ":f:s:l:hU",
long_options, &option_index);
if (c == -1) {
break;
@@ -3047,6 +3051,18 @@ static int img_map(int argc, char **argv)
case OPTION_OUTPUT:
output = optarg;
break;
+ case 's':
+ start_offset = cvtnum("start offset", optarg);
+ if (start_offset < 0) {
+ return 1;
+ }
+ break;
+ case 'l':
+ max_length = cvtnum("max length", optarg);
+ if (max_length < 0) {
+ return 1;
+ }
+ break;
case OPTION_OBJECT: {
QemuOpts *opts;
opts = qemu_opts_parse_noisily(&qemu_object_opts,
@@ -3097,7 +3113,11 @@ static int img_map(int argc, char **argv)
error_report("Failed to get size for '%s'", filename);
return 1;
}
+ if (max_length != -1) {
+ length = MIN(start_offset + max_length, length);
+ }
+ curr.start = start_offset;
while (curr.start + curr.length < length) {
int64_t offset = curr.start + curr.length;
int64_t n;
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index c9c54de1df40..35f832816f96 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -63,9 +63,9 @@ SRST
ERST
DEF("map", img_map,
- "map [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [-U] filename")
+ "map [--object objectdef] [--image-opts] [-f fmt] [--start-offset=offset] [--max-length=len] [--output=ofmt] [-U] filename")
SRST
-.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [-U] FILENAME
+.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--start-offset=OFFSET] [--max-length=LEN] [--output=OFMT] [-U] FILENAME
ERST
DEF("measure", img_measure,
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 6/6] iotests: Enhance 223 to cover qemu-img map improvements
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
` (4 preceding siblings ...)
2020-05-18 16:32 ` [PULL 5/6] qemu-img: Add --start-offset and --max-length to map Eric Blake
@ 2020-05-18 16:32 ` Eric Blake
2020-05-18 20:51 ` [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
2020-05-19 10:58 ` Peter Maydell
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 16:32 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, open list:Block layer core, Max Reitz
Since qemu-img map + x-dirty-bitmap remains the easiest way to read
persistent bitmaps at the moment, it makes a reasonable place to add
coverage to ensure we do not regress on the just-added parameters to
qemu-img map.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200513181455.295267-1-eblake@redhat.com>
---
tests/qemu-iotests/223 | 6 ++++--
tests/qemu-iotests/223.out | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
index 56fbc5fb09a0..d68bc3cb6f1a 100755
--- a/tests/qemu-iotests/223
+++ b/tests/qemu-iotests/223
@@ -2,7 +2,7 @@
#
# Test reading dirty bitmap over NBD
#
-# Copyright (C) 2018-2019 Red Hat, Inc.
+# Copyright (C) 2018-2020 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -206,7 +206,9 @@ $QEMU_IMG map --output=json --image-opts \
nbd_server_start_unix_socket -f $IMGFMT -B b2 "$TEST_IMG"
IMG="driver=nbd,server.type=unix,server.path=$nbd_unix_socket"
-$QEMU_IMG map --output=json --image-opts \
+$QEMU_IMG map --output=json --image-opts --max-length=12345 \
+ "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
+$QEMU_IMG map --output=json --image-opts --start-offset=12345 \
"$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
# success, all done
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
index 80c0cf65095b..e1eaaedb55b3 100644
--- a/tests/qemu-iotests/223.out
+++ b/tests/qemu-iotests/223.out
@@ -201,6 +201,7 @@ read 2097152/2097152 bytes at offset 2097152
{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": false}]
[{ "start": 0, "length": 512, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
{ "start": 512, "length": 512, "depth": 0, "zero": false, "data": false},
-{ "start": 1024, "length": 2096128, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
+{ "start": 1024, "length": 11321, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
+[{ "start": 12345, "length": 2084807, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": false}]
*** done
--
2.26.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PULL 0/6] NBD patches for 2020-05-18
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
` (5 preceding siblings ...)
2020-05-18 16:32 ` [PULL 6/6] iotests: Enhance 223 to cover qemu-img map improvements Eric Blake
@ 2020-05-18 20:51 ` Eric Blake
2020-05-19 10:58 ` Peter Maydell
7 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-18 20:51 UTC (permalink / raw)
To: qemu-devel, Peter Maydell
On 5/18/20 11:32 AM, Eric Blake wrote:
> The following changes since commit debe78ce14bf8f8940c2bdf3ef387505e9e035a9:
>
> Merge remote-tracking branch 'remotes/rth/tags/pull-fpu-20200515' into staging (2020-05-15 19:51:16 +0100)
> ----------------------------------------------------------------
> nbd patches for 2020-05-20
Typo in my signed tag (today is the 18th, not the 20th). Do you want me
to send a v2 pull request correcting just that, or shall we overlook it?
>
> - fix stranded fd in 'qemu-nbd -c /dev/nbd0'
> - add 'qemu-img map --start-offset --max-length' options
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PULL 0/6] NBD patches for 2020-05-18
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
` (6 preceding siblings ...)
2020-05-18 20:51 ` [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
@ 2020-05-19 10:58 ` Peter Maydell
7 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2020-05-19 10:58 UTC (permalink / raw)
To: Eric Blake; +Cc: QEMU Developers
On Mon, 18 May 2020 at 17:38, Eric Blake <eblake@redhat.com> wrote:
>
> The following changes since commit debe78ce14bf8f8940c2bdf3ef387505e9e035a9:
>
> Merge remote-tracking branch 'remotes/rth/tags/pull-fpu-20200515' into staging (2020-05-15 19:51:16 +0100)
>
> are available in the Git repository at:
>
> https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-05-18
>
> for you to fetch changes up to d8154b0945f795177511ea0e2212bd5c749fe84c:
>
> iotests: Enhance 223 to cover qemu-img map improvements (2020-05-18 11:02:05 -0500)
>
> We've got a couple of first-time contributors included in this one :)
>
> ----------------------------------------------------------------
> nbd patches for 2020-05-20
>
> - fix stranded fd in 'qemu-nbd -c /dev/nbd0'
> - add 'qemu-img map --start-offset --max-length' options
>
> ----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PULL 2/6] qemu_img: add cvtnum_full to print error reports
2020-05-18 16:32 ` [PULL 2/6] qemu_img: add cvtnum_full to print error reports Eric Blake
@ 2020-05-20 21:39 ` Eric Blake
0 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2020-05-20 21:39 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Eyal Moscovici, open list:Block layer core, Max Reitz
On 5/18/20 11:32 AM, Eric Blake wrote:
> From: Eyal Moscovici <eyal.moscovici@oracle.com>
>
> All calls to cvtnum check the return value and print the same error
> message more or less. And so error reporting moved to cvtnum_full to
> reduce code duplication and provide a single error
> message. Additionally, cvtnum now wraps cvtnum_full with the existing
> default range of 0 to MAX_INT64.
>
> Acked-by: Mark Kanda <mark.kanda@oracle.com>
> Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
> Message-Id: <20200513133629.18508-2-eyal.moscovici@oracle.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> [eblake: fix printf formatting, avoid trailing space, change error wording,
> reformat commit message]
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> @@ -572,16 +584,8 @@ static int img_create(int argc, char **argv)
> if (optind < argc) {
> int64_t sval;
>
> - sval = cvtnum(argv[optind++]);
> + sval = cvtnum("image size", argv[optind++]);
> if (sval < 0) {
> - if (sval == -ERANGE) {
> - error_report("Image size must be less than 8 EiB!");
This change broke iotest 178:
--- /home/eblake/qemu/tests/qemu-iotests/178.out.qcow2 2020-05-20
16:33:20.065710365 -0500
+++ /home/eblake/qemu/build/tests/qemu-iotests/178.out.bad 2020-05-20
16:35:28.924512423 -0500
@@ -13,7 +13,7 @@
qemu-img: Invalid parameter 'snapshot.foo'
qemu-img: Failed in parsing snapshot param 'snapshot.foo'
qemu-img: --output must be used with human or json as argument.
-qemu-img: Image size must be less than 8 EiB!
+qemu-img: Invalid image size specified. Must be between 0 and
9223372036854775807.
qemu-img: Unknown file format 'foo'
== Size calculation for a new file (human) ==
I'll post a followup patch shortly.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-05-20 21:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 16:32 [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
2020-05-18 16:32 ` [PULL 1/6] qemu-nbd: Close inherited stderr Eric Blake
2020-05-18 16:32 ` [PULL 2/6] qemu_img: add cvtnum_full to print error reports Eric Blake
2020-05-20 21:39 ` Eric Blake
2020-05-18 16:32 ` [PULL 3/6] qemu-img: validate image length in img_map Eric Blake
2020-05-18 16:32 ` [PULL 4/6] qemu-img: refactor dump_map_entry JSON format output Eric Blake
2020-05-18 16:32 ` [PULL 5/6] qemu-img: Add --start-offset and --max-length to map Eric Blake
2020-05-18 16:32 ` [PULL 6/6] iotests: Enhance 223 to cover qemu-img map improvements Eric Blake
2020-05-18 20:51 ` [PULL 0/6] NBD patches for 2020-05-18 Eric Blake
2020-05-19 10:58 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.