qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH 4/7] qemu-img: Add print_amend_opti


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 4/7] qemu-img: Add print_amend_option_help()
Date: Wed, 2 May 2018 13:13:08 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 04/21/2018 11:54 AM, Max Reitz wrote:
The more generic print_block_option_help() function is not really
suitable for qemu-img amend, for a couple of reasons:
(1) We do not need to append the protocol-level options, as amendment
     happens only on one node and does not descend downwards to its
     children.
(2) print_block_option_help() says those options are "supported".  For
     option amendment, we do not really know that.  So this new function
     explicitly says that those options are the creation options, and not
     all of them may be supported.
(3) If the driver does not support option amendment, we should not print
     anything (except for an error message that amendment is not
     supported).

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1537956
Signed-off-by: Max Reitz <address@hidden>
---
  qemu-img.c                 | 30 ++++++++++++++++++++++++++++--
  tests/qemu-iotests/082.out | 44 +++++++++++++++++++++++++++-----------------
  2 files changed, 55 insertions(+), 19 deletions(-)


diff --git a/qemu-img.c b/qemu-img.c
index 6dd8e95bb2..45e243cc80 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3578,6 +3578,32 @@ static void amend_status_cb(BlockDriverState *bs,
      qemu_progress_print(100.f * offset / total_work_size, 0);
  }
+static int print_amend_option_help(const char *format)
+{
+    BlockDriver *drv;
+
+    /* Find driver and parse its options */
+    drv = bdrv_find_format(format);
+    if (!drv) {
+        error_report("Unknown file format '%s'", format);
+        return 1;
+    }

Not your fault; I'd love it if this file consistently used EXIT_FAILURE instead of 1 (since that's a bit more obvious why we are returning a positive value instead of our more usual negative-on-error - we expect the caller to feed our return value to exit()), but that's a separate cleanup.

But the new output is definitely nicer.

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]