All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
@ 2020-01-27 10:36 Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
                   ` (14 more replies)
  0 siblings, 15 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

This patch series is bunch of cleanups
to the hmp monitor code.

This series only touched blockdev related hmp handlers.

No functional changes expected other that
light error message changes by the last patch.

This was inspired by this bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1719169

Basically some users still parse hmp error messages,
and they would like to have them prefixed with 'Error:'

In commit 66363e9a43f649360a3f74d2805c9f864da027eb we added
the hmp_handle_error which does exactl that but some hmp handlers
don't use it.

In this patch series, I moved all the block related hmp handlers
into blockdev-hmp-cmds.c, and then made them use this function
to report the errors.

I hope I didn't change too much code, I just felt that if
I touch this code, I can also make it easier to find these
handlers, that were scattered over 3 different files.

Changes from V1:
   * move the handlers to block/monitor/block-hmp-cmds.c
   * tiny cleanup for the commit messages

Changes from V2:
   * Moved all the function prototypes to new header (blockdev-hmp-cmds.h)
   * Set the license of blockdev-hmp-cmds.c to GPLv2+
   * Moved hmp_snapshot_* functions to blockdev-hmp-cmds.c
   * Moved hmp_drive_add_node to blockdev-hmp-cmds.c
     (this change needed some new exports, thus in separate new patch)
   * Moved hmp_qemu_io and hmp_eject to blockdev-hmp-cmds.c
   * Added 'error:' prefix to vreport, and updated the iotests
     This is invasive change, but really feels like the right one
   * Added minor refactoring patch that drops an unused #include

Best regards,
	Maxim Levitsky

Maxim Levitsky (13):
  usb/dev-storage: remove unused include
  monitor/hmp: uninline add_init_drive
  monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
  monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to
    block-hmp-cmds.c
  monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
  monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
  monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
  monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
  monitor/hmp: move hmp_info_block* to block-hmp-cmds.c
  monitor: Move hmp_drive_add_node to block-hmp-cmds.c
  add 'error' prefix to vreport
  monitor/hmp: Prefer to use hmp_handle_error for error reporting in
    block hmp commands

 MAINTAINERS                        |   1 +
 Makefile.objs                      |   2 +-
 block/Makefile.objs                |   1 +
 block/monitor/Makefile.objs        |   1 +
 block/monitor/block-hmp-cmds.c     | 980 +++++++++++++++++++++++++++++
 blockdev.c                         | 137 +---
 device-hotplug.c                   |  91 ---
 hw/usb/dev-storage.c               |   1 -
 include/block/block-hmp-commands.h |  42 ++
 include/block/block_int.h          |   5 +-
 include/monitor/hmp.h              |  24 -
 include/sysemu/blockdev.h          |   4 -
 include/sysemu/sysemu.h            |   3 -
 monitor/hmp-cmds.c                 | 771 +----------------------
 monitor/misc.c                     |   1 +
 tests/qemu-iotests/020.out         |   2 +-
 tests/qemu-iotests/026.out         | 260 ++++----
 tests/qemu-iotests/036.out         |  16 +-
 tests/qemu-iotests/043.out         |   6 +-
 tests/qemu-iotests/049.out         |  30 +-
 tests/qemu-iotests/051.pc.out      | 150 ++---
 tests/qemu-iotests/054.out         |   4 +-
 tests/qemu-iotests/060.out         |  20 +-
 tests/qemu-iotests/061.out         |  26 +-
 tests/qemu-iotests/069.out         |   2 +-
 tests/qemu-iotests/071.out         |   4 +-
 tests/qemu-iotests/074.out         |   4 +-
 tests/qemu-iotests/079.out         |   2 +-
 tests/qemu-iotests/080.out         |  72 +--
 tests/qemu-iotests/081.out         |   2 +-
 tests/qemu-iotests/082.out         |  38 +-
 tests/qemu-iotests/083.out         |  68 +-
 tests/qemu-iotests/098.out         |   8 +-
 tests/qemu-iotests/103.out         |  14 +-
 tests/qemu-iotests/106.out         |   4 +-
 tests/qemu-iotests/111.out         |   2 +-
 tests/qemu-iotests/112.out         |  24 +-
 tests/qemu-iotests/113.out         |   6 +-
 tests/qemu-iotests/114.out         |   2 +-
 tests/qemu-iotests/122.out         |   4 +-
 tests/qemu-iotests/133.out         |  30 +-
 tests/qemu-iotests/137.out         |  28 +-
 tests/qemu-iotests/140.out         |   2 +-
 tests/qemu-iotests/142.out         |  38 +-
 tests/qemu-iotests/143.out         |   2 +-
 tests/qemu-iotests/153.out         | 118 ++--
 tests/qemu-iotests/162.out         |  10 +-
 tests/qemu-iotests/172.out         |  16 +-
 tests/qemu-iotests/178.out.qcow2   |  30 +-
 tests/qemu-iotests/178.out.raw     |  26 +-
 tests/qemu-iotests/182.out         |   2 +-
 tests/qemu-iotests/187.out         |   6 +-
 tests/qemu-iotests/188.out         |   2 +-
 tests/qemu-iotests/197.out         |   2 +-
 tests/qemu-iotests/205             |   2 +-
 tests/qemu-iotests/215.out         |   2 +-
 tests/qemu-iotests/217.out         |   2 +-
 tests/qemu-iotests/226.out         |  12 +-
 tests/qemu-iotests/232.out         |  12 +-
 tests/qemu-iotests/233.out         |  24 +-
 tests/qemu-iotests/242.out         |   2 +-
 tests/qemu-iotests/244.out         |  14 +-
 tests/qemu-iotests/249.out         |   6 +-
 tests/qemu-iotests/261.out         |  24 +-
 tests/qemu-iotests/267.out         |  16 +-
 tests/qemu-iotests/common.filter   |   2 +-
 util/qemu-error.c                  |   1 +
 67 files changed, 1640 insertions(+), 1625 deletions(-)
 create mode 100644 block/monitor/Makefile.objs
 create mode 100644 block/monitor/block-hmp-cmds.c
 delete mode 100644 device-hotplug.c
 create mode 100644 include/block/block-hmp-commands.h

-- 
2.17.2



^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH v3 01/13] usb/dev-storage: remove unused include
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-27 10:49   ` Philippe Mathieu-Daudé
  2020-01-27 10:36 ` [PATCH v3 02/13] monitor/hmp: uninline add_init_drive Maxim Levitsky
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 hw/usb/dev-storage.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 8545193488..50d12244ab 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -19,7 +19,6 @@
 #include "hw/scsi/scsi.h"
 #include "ui/console.h"
 #include "migration/vmstate.h"
-#include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/block-backend.h"
 #include "qapi/visitor.h"
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 02/13] monitor/hmp: uninline add_init_drive
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

This is only used by hmp_drive_add.
The code is just a bit shorter this way.

No functional changes

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 device-hotplug.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/device-hotplug.c b/device-hotplug.c
index f01d53774b..554e4d98db 100644
--- a/device-hotplug.c
+++ b/device-hotplug.c
@@ -34,42 +34,35 @@
 #include "monitor/monitor.h"
 #include "block/block_int.h"
 
-static DriveInfo *add_init_drive(const char *optstr)
+
+void hmp_drive_add(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
     DriveInfo *dinfo;
     QemuOpts *opts;
     MachineClass *mc;
+    const char *optstr = qdict_get_str(qdict, "opts");
+    bool node = qdict_get_try_bool(qdict, "node", false);
+
+    if (node) {
+        hmp_drive_add_node(mon, optstr);
+        return;
+    }
 
     opts = drive_def(optstr);
     if (!opts)
-        return NULL;
+        return;
 
     mc = MACHINE_GET_CLASS(current_machine);
     dinfo = drive_new(opts, mc->block_default_type, &err);
     if (err) {
         error_report_err(err);
         qemu_opts_del(opts);
-        return NULL;
-    }
-
-    return dinfo;
-}
-
-void hmp_drive_add(Monitor *mon, const QDict *qdict)
-{
-    DriveInfo *dinfo = NULL;
-    const char *opts = qdict_get_str(qdict, "opts");
-    bool node = qdict_get_try_bool(qdict, "node", false);
-
-    if (node) {
-        hmp_drive_add_node(mon, opts);
-        return;
+        goto err;
     }
 
-    dinfo = add_init_drive(opts);
     if (!dinfo) {
-        goto err;
+        return;
     }
 
     switch (dinfo->type) {
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 02/13] monitor/hmp: uninline add_init_drive Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 16:56   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

These days device-hotplug.c only contains the hmp_drive_add
In the next patch, rest of hmp_drive* functions will be moved
there.

Also change the license of that file to GPL2+ since most
of the code that will be moved there is under that license

Also add block-hmp-commands.h to contain prototypes of these
functions

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 MAINTAINERS                                   |  1 +
 Makefile.objs                                 |  2 +-
 block/Makefile.objs                           |  1 +
 block/monitor/Makefile.objs                   |  1 +
 .../monitor/block-hmp-cmds.c                  | 23 ++++---------------
 include/block/block-hmp-commands.h            |  8 +++++++
 include/sysemu/sysemu.h                       |  3 ---
 monitor/misc.c                                |  1 +
 8 files changed, 18 insertions(+), 22 deletions(-)
 create mode 100644 block/monitor/Makefile.objs
 rename device-hotplug.c => block/monitor/block-hmp-cmds.c (55%)
 create mode 100644 include/block/block-hmp-commands.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f6511d5120..5d50d09ad8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1882,6 +1882,7 @@ Block QAPI, monitor, command line
 M: Markus Armbruster <armbru@redhat.com>
 S: Supported
 F: blockdev.c
+F: blockdev-hmp-cmds.c
 F: block/qapi.c
 F: qapi/block*.json
 F: qapi/transaction.json
diff --git a/Makefile.objs b/Makefile.objs
index ff396b9209..15209eb6b5 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -48,7 +48,7 @@ common-obj-y += dump/
 common-obj-y += job-qmp.o
 common-obj-y += monitor/
 common-obj-y += net/
-common-obj-y += qdev-monitor.o device-hotplug.o
+common-obj-y += qdev-monitor.o
 common-obj-$(CONFIG_WIN32) += os-win32.o
 common-obj-$(CONFIG_POSIX) += os-posix.o
 
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 330529b0b7..3f65544a6b 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -44,6 +44,7 @@ block-obj-y += crypto.o
 block-obj-y += aio_task.o
 block-obj-y += backup-top.o
 block-obj-y += filter-compress.o
+common-obj-y += monitor/
 
 common-obj-y += stream.o
 
diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs
new file mode 100644
index 0000000000..0a74f9a8b5
--- /dev/null
+++ b/block/monitor/Makefile.objs
@@ -0,0 +1 @@
+common-obj-y += block-hmp-cmds.o
diff --git a/device-hotplug.c b/block/monitor/block-hmp-cmds.c
similarity index 55%
rename from device-hotplug.c
rename to block/monitor/block-hmp-cmds.c
index 554e4d98db..c65aaa86ea 100644
--- a/device-hotplug.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1,25 +1,11 @@
 /*
- * QEMU device hotplug helpers
+ * Blockdev HMP commands
  *
  * Copyright (c) 2004 Fabrice Bellard
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ * or (at your option) any later version.
+ * See the COPYING file in the top-level directory.
  */
 
 #include "qemu/osdep.h"
@@ -33,6 +19,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "block/block_int.h"
+#include "block/block-hmp-commands.h"
 
 
 void hmp_drive_add(Monitor *mon, const QDict *qdict)
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
new file mode 100644
index 0000000000..4f9033a8a6
--- /dev/null
+++ b/include/block/block-hmp-commands.h
@@ -0,0 +1,8 @@
+#ifndef BLOCK_HMP_COMMANDS_H
+#define BLOCK_HMP_COMMANDS_H
+
+/* HMP commands related to the block layer*/
+
+void hmp_drive_add(Monitor *mon, const QDict *qdict);
+
+#endif
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 80c57fdc4e..c48635666d 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -68,9 +68,6 @@ extern int nb_option_roms;
 extern const char *prom_envs[MAX_PROM_ENVS];
 extern unsigned int nb_prom_envs;
 
-/* generic hotplug */
-void hmp_drive_add(Monitor *mon, const QDict *qdict);
-
 /* pcie aer error injection */
 void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
 
diff --git a/monitor/misc.c b/monitor/misc.c
index de1ca4d114..0466c00830 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -79,6 +79,7 @@
 #include "sysemu/cpus.h"
 #include "qemu/cutils.h"
 #include "tcg/tcg.h"
+#include "block/block-hmp-commands.h"
 
 #if defined(TARGET_S390X)
 #include "hw/s390x/storage-keys.h"
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (2 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 17:51   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup " Maxim Levitsky
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 97 +++++++++++++++++++++++++++++-
 blockdev.c                         | 95 -----------------------------
 include/block/block-hmp-commands.h |  3 +
 include/sysemu/blockdev.h          |  4 --
 4 files changed, 99 insertions(+), 100 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index c65aaa86ea..9614c67e77 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -12,6 +12,7 @@
 #include "hw/boards.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
+#include "qapi/qapi-commands-block.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/error.h"
 #include "qemu/config-file.h"
@@ -21,7 +22,6 @@
 #include "block/block_int.h"
 #include "block/block-hmp-commands.h"
 
-
 void hmp_drive_add(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
@@ -69,3 +69,98 @@ err:
         blk_unref(blk);
     }
 }
+
+void hmp_drive_del(Monitor *mon, const QDict *qdict)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    BlockBackend *blk;
+    BlockDriverState *bs;
+    AioContext *aio_context;
+    Error *local_err = NULL;
+
+    bs = bdrv_find_node(id);
+    if (bs) {
+        qmp_blockdev_del(id, &local_err);
+        if (local_err) {
+            error_report_err(local_err);
+        }
+        return;
+    }
+
+    blk = blk_by_name(id);
+    if (!blk) {
+        error_report("Device '%s' not found", id);
+        return;
+    }
+
+    if (!blk_legacy_dinfo(blk)) {
+        error_report("Deleting device added with blockdev-add"
+                     " is not supported");
+        return;
+    }
+
+    aio_context = blk_get_aio_context(blk);
+    aio_context_acquire(aio_context);
+
+    bs = blk_bs(blk);
+    if (bs) {
+        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
+            error_report_err(local_err);
+            aio_context_release(aio_context);
+            return;
+        }
+
+        blk_remove_bs(blk);
+    }
+
+    /* Make the BlockBackend and the attached BlockDriverState anonymous */
+    monitor_remove_blk(blk);
+
+    /* If this BlockBackend has a device attached to it, its refcount will be
+     * decremented when the device is removed; otherwise we have to do so here.
+     */
+    if (blk_get_attached_dev(blk)) {
+        /* Further I/O must not pause the guest */
+        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
+                         BLOCKDEV_ON_ERROR_REPORT);
+    } else {
+        blk_unref(blk);
+    }
+
+    aio_context_release(aio_context);
+}
+
+void hmp_commit(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    BlockBackend *blk;
+    int ret;
+
+    if (!strcmp(device, "all")) {
+        ret = blk_commit_all();
+    } else {
+        BlockDriverState *bs;
+        AioContext *aio_context;
+
+        blk = blk_by_name(device);
+        if (!blk) {
+            error_report("Device '%s' not found", device);
+            return;
+        }
+        if (!blk_is_available(blk)) {
+            error_report("Device '%s' has no medium", device);
+            return;
+        }
+
+        bs = blk_bs(blk);
+        aio_context = bdrv_get_aio_context(bs);
+        aio_context_acquire(aio_context);
+
+        ret = bdrv_commit(bs);
+
+        aio_context_release(aio_context);
+    }
+    if (ret < 0) {
+        error_report("'commit' error for '%s': %s", device, strerror(-ret));
+    }
+}
diff --git a/blockdev.c b/blockdev.c
index 8e029e9c01..df43e0aaef 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1074,41 +1074,6 @@ static BlockBackend *qmp_get_blk(const char *blk_name, const char *qdev_id,
     return blk;
 }
 
-void hmp_commit(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    BlockBackend *blk;
-    int ret;
-
-    if (!strcmp(device, "all")) {
-        ret = blk_commit_all();
-    } else {
-        BlockDriverState *bs;
-        AioContext *aio_context;
-
-        blk = blk_by_name(device);
-        if (!blk) {
-            error_report("Device '%s' not found", device);
-            return;
-        }
-        if (!blk_is_available(blk)) {
-            error_report("Device '%s' has no medium", device);
-            return;
-        }
-
-        bs = blk_bs(blk);
-        aio_context = bdrv_get_aio_context(bs);
-        aio_context_acquire(aio_context);
-
-        ret = bdrv_commit(bs);
-
-        aio_context_release(aio_context);
-    }
-    if (ret < 0) {
-        error_report("'commit' error for '%s': %s", device, strerror(-ret));
-    }
-}
-
 static void blockdev_do_action(TransactionAction *action, Error **errp)
 {
     TransactionActionList list;
@@ -3101,66 +3066,6 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
     return ret;
 }
 
-void hmp_drive_del(Monitor *mon, const QDict *qdict)
-{
-    const char *id = qdict_get_str(qdict, "id");
-    BlockBackend *blk;
-    BlockDriverState *bs;
-    AioContext *aio_context;
-    Error *local_err = NULL;
-
-    bs = bdrv_find_node(id);
-    if (bs) {
-        qmp_blockdev_del(id, &local_err);
-        if (local_err) {
-            error_report_err(local_err);
-        }
-        return;
-    }
-
-    blk = blk_by_name(id);
-    if (!blk) {
-        error_report("Device '%s' not found", id);
-        return;
-    }
-
-    if (!blk_legacy_dinfo(blk)) {
-        error_report("Deleting device added with blockdev-add"
-                     " is not supported");
-        return;
-    }
-
-    aio_context = blk_get_aio_context(blk);
-    aio_context_acquire(aio_context);
-
-    bs = blk_bs(blk);
-    if (bs) {
-        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
-            error_report_err(local_err);
-            aio_context_release(aio_context);
-            return;
-        }
-
-        blk_remove_bs(blk);
-    }
-
-    /* Make the BlockBackend and the attached BlockDriverState anonymous */
-    monitor_remove_blk(blk);
-
-    /* If this BlockBackend has a device attached to it, its refcount will be
-     * decremented when the device is removed; otherwise we have to do so here.
-     */
-    if (blk_get_attached_dev(blk)) {
-        /* Further I/O must not pause the guest */
-        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
-                         BLOCKDEV_ON_ERROR_REPORT);
-    } else {
-        blk_unref(blk);
-    }
-
-    aio_context_release(aio_context);
-}
-
 void qmp_block_resize(bool has_device, const char *device,
                       bool has_node_name, const char *node_name,
                       int64_t size, Error **errp)
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index 4f9033a8a6..c5e394c0fc 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -5,4 +5,7 @@
 
 void hmp_drive_add(Monitor *mon, const QDict *qdict);
 
+void hmp_commit(Monitor *mon, const QDict *qdict);
+void hmp_drive_del(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index d34c4920dc..a86d99b3d8 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -57,8 +57,4 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
 DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
                      Error **errp);
 
-/* device-hotplug */
-
-void hmp_commit(Monitor *mon, const QDict *qdict);
-void hmp_drive_del(Monitor *mon, const QDict *qdict);
 #endif
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (3 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 17:59   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 64 ++++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |  3 ++
 include/monitor/hmp.h              |  2 -
 monitor/hmp-cmds.c                 | 58 ---------------------------
 4 files changed, 67 insertions(+), 60 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 9614c67e77..ae3890aaab 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -2,6 +2,10 @@
  * Blockdev HMP commands
  *
  * Copyright (c) 2004 Fabrice Bellard
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
  *
  * This work is licensed under the terms of the GNU GPL, version 2.
  * or (at your option) any later version.
@@ -15,12 +19,14 @@
 #include "qapi/qapi-commands-block.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "block/block_int.h"
 #include "block/block-hmp-commands.h"
+#include "monitor/hmp.h"
 
 void hmp_drive_add(Monitor *mon, const QDict *qdict)
 {
@@ -164,3 +170,61 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
         error_report("'commit' error for '%s': %s", device, strerror(-ret));
     }
 }
+
+void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
+{
+    const char *filename = qdict_get_str(qdict, "target");
+    const char *format = qdict_get_try_str(qdict, "format");
+    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+    bool full = qdict_get_try_bool(qdict, "full", false);
+    Error *err = NULL;
+    DriveMirror mirror = {
+        .device = (char *)qdict_get_str(qdict, "device"),
+        .target = (char *)filename,
+        .has_format = !!format,
+        .format = (char *)format,
+        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
+        .has_mode = true,
+        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
+        .unmap = true,
+    };
+
+    if (!filename) {
+        error_setg(&err, QERR_MISSING_PARAMETER, "target");
+        hmp_handle_error(mon, err);
+        return;
+    }
+    qmp_drive_mirror(&mirror, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_drive_backup(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *filename = qdict_get_str(qdict, "target");
+    const char *format = qdict_get_try_str(qdict, "format");
+    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+    bool full = qdict_get_try_bool(qdict, "full", false);
+    bool compress = qdict_get_try_bool(qdict, "compress", false);
+    Error *err = NULL;
+    DriveBackup backup = {
+        .device = (char *)device,
+        .target = (char *)filename,
+        .has_format = !!format,
+        .format = (char *)format,
+        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
+        .has_mode = true,
+        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
+        .has_compress = !!compress,
+        .compress = compress,
+    };
+
+    if (!filename) {
+        error_setg(&err, QERR_MISSING_PARAMETER, "target");
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    qmp_drive_backup(&backup, &err);
+    hmp_handle_error(mon, err);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index c5e394c0fc..fcaf753118 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -8,4 +8,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict);
 void hmp_commit(Monitor *mon, const QDict *qdict);
 void hmp_drive_del(Monitor *mon, const QDict *qdict);
 
+void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
+void hmp_drive_backup(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 3d329853b2..c1b363ee57 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -64,8 +64,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict);
 void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
 void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
-void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
-void hmp_drive_backup(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index d0e0af893a..a70bcb1d16 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1337,64 +1337,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
-{
-    const char *filename = qdict_get_str(qdict, "target");
-    const char *format = qdict_get_try_str(qdict, "format");
-    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
-    bool full = qdict_get_try_bool(qdict, "full", false);
-    Error *err = NULL;
-    DriveMirror mirror = {
-        .device = (char *)qdict_get_str(qdict, "device"),
-        .target = (char *)filename,
-        .has_format = !!format,
-        .format = (char *)format,
-        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
-        .has_mode = true,
-        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
-        .unmap = true,
-    };
-
-    if (!filename) {
-        error_setg(&err, QERR_MISSING_PARAMETER, "target");
-        hmp_handle_error(mon, err);
-        return;
-    }
-    qmp_drive_mirror(&mirror, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_drive_backup(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *filename = qdict_get_str(qdict, "target");
-    const char *format = qdict_get_try_str(qdict, "format");
-    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
-    bool full = qdict_get_try_bool(qdict, "full", false);
-    bool compress = qdict_get_try_bool(qdict, "compress", false);
-    Error *err = NULL;
-    DriveBackup backup = {
-        .device = (char *)device,
-        .target = (char *)filename,
-        .has_format = !!format,
-        .format = (char *)format,
-        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
-        .has_mode = true,
-        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
-        .has_compress = !!compress,
-        .compress = compress,
-    };
-
-    if (!filename) {
-        error_setg(&err, QERR_MISSING_PARAMETER, "target");
-        hmp_handle_error(mon, err);
-        return;
-    }
-
-    qmp_drive_backup(&backup, &err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 06/13] monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (4 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 18:11   ` Dr. David Alan Gilbert
  2020-01-28 18:15   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* " Maxim Levitsky
                   ` (8 subsequent siblings)
  14 siblings, 2 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 52 ++++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |  6 ++++
 include/monitor/hmp.h              |  5 ---
 monitor/hmp-cmds.c                 | 52 ------------------------------
 4 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index ae3890aaab..ed3c350143 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -228,3 +228,55 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
     qmp_drive_backup(&backup, &err);
     hmp_handle_error(mon, err);
 }
+
+void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+    int64_t value = qdict_get_int(qdict, "speed");
+
+    qmp_block_job_set_speed(device, value, &error);
+
+    hmp_handle_error(mon, error);
+}
+
+void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+    bool force = qdict_get_try_bool(qdict, "force", false);
+
+    qmp_block_job_cancel(device, true, force, &error);
+
+    hmp_handle_error(mon, error);
+}
+
+void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+
+    qmp_block_job_pause(device, &error);
+
+    hmp_handle_error(mon, error);
+}
+
+void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+
+    qmp_block_job_resume(device, &error);
+
+    hmp_handle_error(mon, error);
+}
+
+void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+
+    qmp_block_job_complete(device, &error);
+
+    hmp_handle_error(mon, error);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index fcaf753118..ea6578a5f6 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -11,4 +11,10 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict);
 void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
 void hmp_drive_backup(Monitor *mon, const QDict *qdict);
 
+void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
+void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
+void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
+void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
+void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index c1b363ee57..592ce0ccfe 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -87,11 +87,6 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
 void hmp_change(Monitor *mon, const QDict *qdict);
 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
 void hmp_block_stream(Monitor *mon, const QDict *qdict);
-void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
-void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
-void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
-void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
-void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
 void hmp_migrate(Monitor *mon, const QDict *qdict);
 void hmp_device_add(Monitor *mon, const QDict *qdict);
 void hmp_device_del(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index a70bcb1d16..996ce96430 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1975,58 +1975,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, error);
 }
 
-void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-    int64_t value = qdict_get_int(qdict, "speed");
-
-    qmp_block_job_set_speed(device, value, &error);
-
-    hmp_handle_error(mon, error);
-}
-
-void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-    bool force = qdict_get_try_bool(qdict, "force", false);
-
-    qmp_block_job_cancel(device, true, force, &error);
-
-    hmp_handle_error(mon, error);
-}
-
-void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-
-    qmp_block_job_pause(device, &error);
-
-    hmp_handle_error(mon, error);
-}
-
-void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-
-    qmp_block_job_resume(device, &error);
-
-    hmp_handle_error(mon, error);
-}
-
-void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-
-    qmp_block_job_complete(device, &error);
-
-    hmp_handle_error(mon, error);
-}
-
 typedef struct HMPMigrationStatus
 {
     QEMUTimer *timer;
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (5 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 18:53   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* " Maxim Levitsky
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 47 ++++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |  4 +++
 include/monitor/hmp.h              |  3 --
 monitor/hmp-cmds.c                 | 47 ------------------------------
 4 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index ed3c350143..9aa94ea6e0 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -280,3 +280,50 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
 
     hmp_handle_error(mon, error);
 }
+
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+    const char *format = qdict_get_try_str(qdict, "format");
+    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+    enum NewImageMode mode;
+    Error *err = NULL;
+
+    if (!filename) {
+        /* In the future, if 'snapshot-file' is not specified, the snapshot
+           will be taken internally. Today it's actually required. */
+        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
+    qmp_blockdev_snapshot_sync(true, device, false, NULL,
+                               filename, false, NULL,
+                               !!format, format,
+                               true, mode, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *name = qdict_get_str(qdict, "name");
+    Error *err = NULL;
+
+    qmp_blockdev_snapshot_internal_sync(device, name, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *name = qdict_get_str(qdict, "name");
+    const char *id = qdict_get_try_str(qdict, "id");
+    Error *err = NULL;
+
+    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
+                                               true, name, &err);
+    hmp_handle_error(mon, err);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index ea6578a5f6..3fc2daf3a9 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -17,4 +17,8 @@ void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
 void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
 void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
 
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
+void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
+void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 592ce0ccfe..6d34e29bb6 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -61,9 +61,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict);
 void hmp_block_passwd(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_block_resize(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 996ce96430..46b46b6dd7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1337,53 +1337,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
-    const char *format = qdict_get_try_str(qdict, "format");
-    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
-    enum NewImageMode mode;
-    Error *err = NULL;
-
-    if (!filename) {
-        /* In the future, if 'snapshot-file' is not specified, the snapshot
-           will be taken internally. Today it's actually required. */
-        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
-        hmp_handle_error(mon, err);
-        return;
-    }
-
-    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
-    qmp_blockdev_snapshot_sync(true, device, false, NULL,
-                               filename, false, NULL,
-                               !!format, format,
-                               true, mode, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *name = qdict_get_str(qdict, "name");
-    Error *err = NULL;
-
-    qmp_blockdev_snapshot_internal_sync(device, name, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *name = qdict_get_str(qdict, "name");
-    const char *id = qdict_get_try_str(qdict, "id");
-    Error *err = NULL;
-
-    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
-                                               true, name, &err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (6 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 18:56   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 88 ++++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |  5 ++
 include/monitor/hmp.h              |  4 --
 monitor/hmp-cmds.c                 | 87 -----------------------------
 4 files changed, 93 insertions(+), 91 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 9aa94ea6e0..df0178d0f9 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -22,8 +22,10 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/config-file.h"
 #include "qemu/option.h"
+#include "qemu/sockets.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
+#include "block/nbd.h"
 #include "block/block_int.h"
 #include "block/block-hmp-commands.h"
 #include "monitor/hmp.h"
@@ -327,3 +329,89 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
                                                true, name, &err);
     hmp_handle_error(mon, err);
 }
+
+void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
+{
+    const char *uri = qdict_get_str(qdict, "uri");
+    bool writable = qdict_get_try_bool(qdict, "writable", false);
+    bool all = qdict_get_try_bool(qdict, "all", false);
+    Error *local_err = NULL;
+    BlockInfoList *block_list, *info;
+    SocketAddress *addr;
+
+    if (writable && !all) {
+        error_setg(&local_err, "-w only valid together with -a");
+        goto exit;
+    }
+
+    /* First check if the address is valid and start the server.  */
+    addr = socket_parse(uri, &local_err);
+    if (local_err != NULL) {
+        goto exit;
+    }
+
+    nbd_server_start(addr, NULL, NULL, &local_err);
+    qapi_free_SocketAddress(addr);
+    if (local_err != NULL) {
+        goto exit;
+    }
+
+    if (!all) {
+        return;
+    }
+
+    /* Then try adding all block devices.  If one fails, close all and
+     * exit.
+     */
+    block_list = qmp_query_block(NULL);
+
+    for (info = block_list; info; info = info->next) {
+        if (!info->value->has_inserted) {
+            continue;
+        }
+
+        qmp_nbd_server_add(info->value->device, false, NULL,
+                           true, writable, false, NULL, &local_err);
+
+        if (local_err != NULL) {
+            qmp_nbd_server_stop(NULL);
+            break;
+        }
+    }
+
+    qapi_free_BlockInfoList(block_list);
+
+exit:
+    hmp_handle_error(mon, local_err);
+}
+
+void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *name = qdict_get_try_str(qdict, "name");
+    bool writable = qdict_get_try_bool(qdict, "writable", false);
+    Error *local_err = NULL;
+
+    qmp_nbd_server_add(device, !!name, name, true, writable,
+                       false, NULL, &local_err);
+    hmp_handle_error(mon, local_err);
+}
+
+void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
+{
+    const char *name = qdict_get_str(qdict, "name");
+    bool force = qdict_get_try_bool(qdict, "force", false);
+    Error *err = NULL;
+
+    /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
+    qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+
+    qmp_nbd_server_stop(&err);
+    hmp_handle_error(mon, err);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index 3fc2daf3a9..721b9a1978 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -21,4 +21,9 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
 void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
 
+void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
+void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
+void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
+void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 6d34e29bb6..736a969131 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -94,10 +94,6 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);
 void hmp_closefd(Monitor *mon, const QDict *qdict);
 void hmp_sendkey(Monitor *mon, const QDict *qdict);
 void hmp_screendump(Monitor *mon, const QDict *qdict);
-void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
-void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
-void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
-void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_change(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 46b46b6dd7..67d2ca8a4c 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -45,7 +45,6 @@
 #include "qapi/string-output-visitor.h"
 #include "qom/object_interfaces.h"
 #include "ui/console.h"
-#include "block/nbd.h"
 #include "block/qapi.h"
 #include "qemu-io.h"
 #include "qemu/cutils.h"
@@ -2154,92 +2153,6 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
-{
-    const char *uri = qdict_get_str(qdict, "uri");
-    bool writable = qdict_get_try_bool(qdict, "writable", false);
-    bool all = qdict_get_try_bool(qdict, "all", false);
-    Error *local_err = NULL;
-    BlockInfoList *block_list, *info;
-    SocketAddress *addr;
-
-    if (writable && !all) {
-        error_setg(&local_err, "-w only valid together with -a");
-        goto exit;
-    }
-
-    /* First check if the address is valid and start the server.  */
-    addr = socket_parse(uri, &local_err);
-    if (local_err != NULL) {
-        goto exit;
-    }
-
-    nbd_server_start(addr, NULL, NULL, &local_err);
-    qapi_free_SocketAddress(addr);
-    if (local_err != NULL) {
-        goto exit;
-    }
-
-    if (!all) {
-        return;
-    }
-
-    /* Then try adding all block devices.  If one fails, close all and
-     * exit.
-     */
-    block_list = qmp_query_block(NULL);
-
-    for (info = block_list; info; info = info->next) {
-        if (!info->value->has_inserted) {
-            continue;
-        }
-
-        qmp_nbd_server_add(info->value->device, false, NULL,
-                           true, writable, false, NULL, &local_err);
-
-        if (local_err != NULL) {
-            qmp_nbd_server_stop(NULL);
-            break;
-        }
-    }
-
-    qapi_free_BlockInfoList(block_list);
-
-exit:
-    hmp_handle_error(mon, local_err);
-}
-
-void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *name = qdict_get_try_str(qdict, "name");
-    bool writable = qdict_get_try_bool(qdict, "writable", false);
-    Error *local_err = NULL;
-
-    qmp_nbd_server_add(device, !!name, name, true, writable,
-                       false, NULL, &local_err);
-    hmp_handle_error(mon, local_err);
-}
-
-void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
-{
-    const char *name = qdict_get_str(qdict, "name");
-    bool force = qdict_get_try_bool(qdict, "force", false);
-    Error *err = NULL;
-
-    /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
-    qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
-{
-    Error *err = NULL;
-
-    qmp_nbd_server_stop(&err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
 {
     const char *args = qdict_get_str(qdict, "args");
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (7 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 18:45   ` Dr. David Alan Gilbert
  2020-01-28 18:51   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 10/13] monitor/hmp: move hmp_info_block* " Maxim Levitsky
                   ` (5 subsequent siblings)
  14 siblings, 2 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 138 +++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |   9 ++
 include/monitor/hmp.h              |   6 --
 monitor/hmp-cmds.c                 | 137 ----------------------------
 4 files changed, 147 insertions(+), 143 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index df0178d0f9..60d63bfe18 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -29,6 +29,7 @@
 #include "block/block_int.h"
 #include "block/block-hmp-commands.h"
 #include "monitor/hmp.h"
+#include "qemu-io.h"
 
 void hmp_drive_add(Monitor *mon, const QDict *qdict)
 {
@@ -415,3 +416,140 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
     qmp_nbd_server_stop(&err);
     hmp_handle_error(mon, err);
 }
+
+void hmp_block_resize(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    int64_t size = qdict_get_int(qdict, "size");
+    Error *err = NULL;
+
+    qmp_block_resize(true, device, false, NULL, size, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_block_stream(Monitor *mon, const QDict *qdict)
+{
+    Error *error = NULL;
+    const char *device = qdict_get_str(qdict, "device");
+    const char *base = qdict_get_try_str(qdict, "base");
+    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
+
+    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
+                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
+                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
+                     &error);
+
+    hmp_handle_error(mon, error);
+}
+
+void hmp_block_passwd(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *password = qdict_get_str(qdict, "password");
+    Error *err = NULL;
+
+    qmp_block_passwd(true, device, false, NULL, password, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    char *device = (char *) qdict_get_str(qdict, "device");
+    BlockIOThrottle throttle = {
+        .bps = qdict_get_int(qdict, "bps"),
+        .bps_rd = qdict_get_int(qdict, "bps_rd"),
+        .bps_wr = qdict_get_int(qdict, "bps_wr"),
+        .iops = qdict_get_int(qdict, "iops"),
+        .iops_rd = qdict_get_int(qdict, "iops_rd"),
+        .iops_wr = qdict_get_int(qdict, "iops_wr"),
+    };
+
+    /* qmp_block_set_io_throttle has separate parameters for the
+     * (deprecated) block device name and the qdev ID but the HMP
+     * version has only one, so we must decide which one to pass. */
+    if (blk_by_name(device)) {
+        throttle.has_device = true;
+        throttle.device = device;
+    } else {
+        throttle.has_id = true;
+        throttle.id = device;
+    }
+
+    qmp_block_set_io_throttle(&throttle, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_eject(Monitor *mon, const QDict *qdict)
+{
+    bool force = qdict_get_try_bool(qdict, "force", false);
+    const char *device = qdict_get_str(qdict, "device");
+    Error *err = NULL;
+
+    qmp_eject(true, device, false, NULL, true, force, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_qemu_io(Monitor *mon, const QDict *qdict)
+{
+    BlockBackend *blk;
+    BlockBackend *local_blk = NULL;
+    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
+    const char* device = qdict_get_str(qdict, "device");
+    const char* command = qdict_get_str(qdict, "command");
+    Error *err = NULL;
+    int ret;
+
+    if (qdev) {
+        blk = blk_by_qdev_id(device, &err);
+        if (!blk) {
+            goto fail;
+        }
+    } else {
+        blk = blk_by_name(device);
+        if (!blk) {
+            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
+            if (bs) {
+                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
+                                          0, BLK_PERM_ALL);
+                ret = blk_insert_bs(blk, bs, &err);
+                if (ret < 0) {
+                    goto fail;
+                }
+            } else {
+                goto fail;
+            }
+        }
+    }
+
+    /*
+     * Notably absent: Proper permission management. This is sad, but it seems
+     * almost impossible to achieve without changing the semantics and thereby
+     * limiting the use cases of the qemu-io HMP command.
+     *
+     * In an ideal world we would unconditionally create a new BlockBackend for
+     * qemuio_command(), but we have commands like 'reopen' and want them to
+     * take effect on the exact BlockBackend whose name the user passed instead
+     * of just on a temporary copy of it.
+     *
+     * Another problem is that deleting the temporary BlockBackend involves
+     * draining all requests on it first, but some qemu-iotests cases want to
+     * issue multiple aio_read/write requests and expect them to complete in
+     * the background while the monitor has already returned.
+     *
+     * This is also what prevents us from saving the original permissions and
+     * restoring them later: We can't revoke permissions until all requests
+     * have completed, and we don't know when that is nor can we really let
+     * anything else run before we have revoken them to avoid race conditions.
+     *
+     * What happens now is that command() in qemu-io-cmds.c can extend the
+     * permissions if necessary for the qemu-io command. And they simply stay
+     * extended, possibly resulting in a read-only guest device keeping write
+     * permissions. Ugly, but it appears to be the lesser evil.
+     */
+    qemuio_command(blk, command);
+
+fail:
+    blk_unref(local_blk);
+    hmp_handle_error(mon, err);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index 721b9a1978..99145c8fcf 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -26,4 +26,13 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 
+void hmp_block_resize(Monitor *mon, const QDict *qdict);
+void hmp_block_stream(Monitor *mon, const QDict *qdict);
+void hmp_block_passwd(Monitor *mon, const QDict *qdict);
+void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
+void hmp_eject(Monitor *mon, const QDict *qdict);
+
+void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 736a969131..47a7cad734 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -58,9 +58,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
 void hmp_nmi(Monitor *mon, const QDict *qdict);
 void hmp_set_link(Monitor *mon, const QDict *qdict);
-void hmp_block_passwd(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
-void hmp_block_resize(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
@@ -80,10 +78,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict);
 void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
 void hmp_set_password(Monitor *mon, const QDict *qdict);
 void hmp_expire_password(Monitor *mon, const QDict *qdict);
-void hmp_eject(Monitor *mon, const QDict *qdict);
 void hmp_change(Monitor *mon, const QDict *qdict);
-void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
-void hmp_block_stream(Monitor *mon, const QDict *qdict);
 void hmp_migrate(Monitor *mon, const QDict *qdict);
 void hmp_device_add(Monitor *mon, const QDict *qdict);
 void hmp_device_del(Monitor *mon, const QDict *qdict);
@@ -98,7 +93,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_change(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
 void hmp_chardev_send_break(Monitor *mon, const QDict *qdict);
-void hmp_qemu_io(Monitor *mon, const QDict *qdict);
 void hmp_cpu_add(Monitor *mon, const QDict *qdict);
 void hmp_object_add(Monitor *mon, const QDict *qdict);
 void hmp_object_del(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 67d2ca8a4c..c224e0f338 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -46,7 +46,6 @@
 #include "qom/object_interfaces.h"
 #include "ui/console.h"
 #include "block/qapi.h"
-#include "qemu-io.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "exec/ramlist.h"
@@ -1307,16 +1306,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_block_passwd(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *password = qdict_get_str(qdict, "password");
-    Error *err = NULL;
-
-    qmp_block_passwd(true, device, false, NULL, password, &err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_balloon(Monitor *mon, const QDict *qdict)
 {
     int64_t value = qdict_get_int(qdict, "value");
@@ -1326,16 +1315,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_block_resize(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    int64_t size = qdict_get_int(qdict, "size");
-    Error *err = NULL;
-
-    qmp_block_resize(true, device, false, NULL, size, &err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
@@ -1818,15 +1797,6 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_eject(Monitor *mon, const QDict *qdict)
-{
-    bool force = qdict_get_try_bool(qdict, "force", false);
-    const char *device = qdict_get_str(qdict, "device");
-    Error *err = NULL;
-
-    qmp_eject(true, device, false, NULL, true, force, &err);
-    hmp_handle_error(mon, err);
-}
 
 #ifdef CONFIG_VNC
 static void hmp_change_read_arg(void *opaque, const char *password,
@@ -1884,49 +1854,6 @@ void hmp_change(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
-{
-    Error *err = NULL;
-    char *device = (char *) qdict_get_str(qdict, "device");
-    BlockIOThrottle throttle = {
-        .bps = qdict_get_int(qdict, "bps"),
-        .bps_rd = qdict_get_int(qdict, "bps_rd"),
-        .bps_wr = qdict_get_int(qdict, "bps_wr"),
-        .iops = qdict_get_int(qdict, "iops"),
-        .iops_rd = qdict_get_int(qdict, "iops_rd"),
-        .iops_wr = qdict_get_int(qdict, "iops_wr"),
-    };
-
-    /* qmp_block_set_io_throttle has separate parameters for the
-     * (deprecated) block device name and the qdev ID but the HMP
-     * version has only one, so we must decide which one to pass. */
-    if (blk_by_name(device)) {
-        throttle.has_device = true;
-        throttle.device = device;
-    } else {
-        throttle.has_id = true;
-        throttle.id = device;
-    }
-
-    qmp_block_set_io_throttle(&throttle, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_block_stream(Monitor *mon, const QDict *qdict)
-{
-    Error *error = NULL;
-    const char *device = qdict_get_str(qdict, "device");
-    const char *base = qdict_get_try_str(qdict, "base");
-    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
-
-    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
-                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
-                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
-                     &error);
-
-    hmp_handle_error(mon, error);
-}
-
 typedef struct HMPMigrationStatus
 {
     QEMUTimer *timer;
@@ -2219,70 +2146,6 @@ void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, local_err);
 }
 
-void hmp_qemu_io(Monitor *mon, const QDict *qdict)
-{
-    BlockBackend *blk;
-    BlockBackend *local_blk = NULL;
-    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
-    const char* device = qdict_get_str(qdict, "device");
-    const char* command = qdict_get_str(qdict, "command");
-    Error *err = NULL;
-    int ret;
-
-    if (qdev) {
-        blk = blk_by_qdev_id(device, &err);
-        if (!blk) {
-            goto fail;
-        }
-    } else {
-        blk = blk_by_name(device);
-        if (!blk) {
-            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
-            if (bs) {
-                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
-                                          0, BLK_PERM_ALL);
-                ret = blk_insert_bs(blk, bs, &err);
-                if (ret < 0) {
-                    goto fail;
-                }
-            } else {
-                goto fail;
-            }
-        }
-    }
-
-    /*
-     * Notably absent: Proper permission management. This is sad, but it seems
-     * almost impossible to achieve without changing the semantics and thereby
-     * limiting the use cases of the qemu-io HMP command.
-     *
-     * In an ideal world we would unconditionally create a new BlockBackend for
-     * qemuio_command(), but we have commands like 'reopen' and want them to
-     * take effect on the exact BlockBackend whose name the user passed instead
-     * of just on a temporary copy of it.
-     *
-     * Another problem is that deleting the temporary BlockBackend involves
-     * draining all requests on it first, but some qemu-iotests cases want to
-     * issue multiple aio_read/write requests and expect them to complete in
-     * the background while the monitor has already returned.
-     *
-     * This is also what prevents us from saving the original permissions and
-     * restoring them later: We can't revoke permissions until all requests
-     * have completed, and we don't know when that is nor can we really let
-     * anything else run before we have revoken them to avoid race conditions.
-     *
-     * What happens now is that command() in qemu-io-cmds.c can extend the
-     * permissions if necessary for the qemu-io command. And they simply stay
-     * extended, possibly resulting in a read-only guest device keeping write
-     * permissions. Ugly, but it appears to be the lesser evil.
-     */
-    qemuio_command(blk, command);
-
-fail:
-    blk_unref(local_blk);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_object_del(Monitor *mon, const QDict *qdict)
 {
     const char *id = qdict_get_str(qdict, "id");
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 10/13] monitor/hmp: move hmp_info_block* to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (8 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 19:00   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 11/13] monitor: Move hmp_drive_add_node " Maxim Levitsky
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 388 +++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |   4 +
 include/monitor/hmp.h              |   4 -
 monitor/hmp-cmds.c                 | 388 -----------------------------
 4 files changed, 392 insertions(+), 392 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 60d63bfe18..a4b1604aee 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -23,11 +23,13 @@
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/sockets.h"
+#include "qemu/cutils.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "block/nbd.h"
 #include "block/block_int.h"
 #include "block/block-hmp-commands.h"
+#include "block/qapi.h"
 #include "monitor/hmp.h"
 #include "qemu-io.h"
 
@@ -553,3 +555,389 @@ fail:
     blk_unref(local_blk);
     hmp_handle_error(mon, err);
 }
+
+static void print_block_info(Monitor *mon, BlockInfo *info,
+                             BlockDeviceInfo *inserted, bool verbose)
+{
+    ImageInfo *image_info;
+
+    assert(!info || !info->has_inserted || info->inserted == inserted);
+
+    if (info && *info->device) {
+        monitor_printf(mon, "%s", info->device);
+        if (inserted && inserted->has_node_name) {
+            monitor_printf(mon, " (%s)", inserted->node_name);
+        }
+    } else {
+        assert(info || inserted);
+        monitor_printf(mon, "%s",
+                       inserted && inserted->has_node_name ? inserted->node_name
+                       : info && info->has_qdev ? info->qdev
+                       : "<anonymous>");
+    }
+
+    if (inserted) {
+        monitor_printf(mon, ": %s (%s%s%s)\n",
+                       inserted->file,
+                       inserted->drv,
+                       inserted->ro ? ", read-only" : "",
+                       inserted->encrypted ? ", encrypted" : "");
+    } else {
+        monitor_printf(mon, ": [not inserted]\n");
+    }
+
+    if (info) {
+        if (info->has_qdev) {
+            monitor_printf(mon, "    Attached to:      %s\n", info->qdev);
+        }
+        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
+            monitor_printf(mon, "    I/O status:       %s\n",
+                           BlockDeviceIoStatus_str(info->io_status));
+        }
+
+        if (info->removable) {
+            monitor_printf(mon, "    Removable device: %slocked, tray %s\n",
+                           info->locked ? "" : "not ",
+                           info->tray_open ? "open" : "closed");
+        }
+    }
+
+
+    if (!inserted) {
+        return;
+    }
+
+    monitor_printf(mon, "    Cache mode:       %s%s%s\n",
+                   inserted->cache->writeback ? "writeback" : "writethrough",
+                   inserted->cache->direct ? ", direct" : "",
+                   inserted->cache->no_flush ? ", ignore flushes" : "");
+
+    if (inserted->has_backing_file) {
+        monitor_printf(mon,
+                       "    Backing file:     %s "
+                       "(chain depth: %" PRId64 ")\n",
+                       inserted->backing_file,
+                       inserted->backing_file_depth);
+    }
+
+    if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
+        monitor_printf(mon, "    Detect zeroes:    %s\n",
+                BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
+    }
+
+    if (inserted->bps  || inserted->bps_rd  || inserted->bps_wr  ||
+        inserted->iops || inserted->iops_rd || inserted->iops_wr)
+    {
+        monitor_printf(mon, "    I/O throttling:   bps=%" PRId64
+                        " bps_rd=%" PRId64  " bps_wr=%" PRId64
+                        " bps_max=%" PRId64
+                        " bps_rd_max=%" PRId64
+                        " bps_wr_max=%" PRId64
+                        " iops=%" PRId64 " iops_rd=%" PRId64
+                        " iops_wr=%" PRId64
+                        " iops_max=%" PRId64
+                        " iops_rd_max=%" PRId64
+                        " iops_wr_max=%" PRId64
+                        " iops_size=%" PRId64
+                        " group=%s\n",
+                        inserted->bps,
+                        inserted->bps_rd,
+                        inserted->bps_wr,
+                        inserted->bps_max,
+                        inserted->bps_rd_max,
+                        inserted->bps_wr_max,
+                        inserted->iops,
+                        inserted->iops_rd,
+                        inserted->iops_wr,
+                        inserted->iops_max,
+                        inserted->iops_rd_max,
+                        inserted->iops_wr_max,
+                        inserted->iops_size,
+                        inserted->group);
+    }
+
+    if (verbose) {
+        monitor_printf(mon, "\nImages:\n");
+        image_info = inserted->image;
+        while (1) {
+                bdrv_image_info_dump(image_info);
+            if (image_info->has_backing_image) {
+                image_info = image_info->backing_image;
+            } else {
+                break;
+            }
+        }
+    }
+}
+
+void hmp_info_block(Monitor *mon, const QDict *qdict)
+{
+    BlockInfoList *block_list, *info;
+    BlockDeviceInfoList *blockdev_list, *blockdev;
+    const char *device = qdict_get_try_str(qdict, "device");
+    bool verbose = qdict_get_try_bool(qdict, "verbose", false);
+    bool nodes = qdict_get_try_bool(qdict, "nodes", false);
+    bool printed = false;
+
+    /* Print BlockBackend information */
+    if (!nodes) {
+        block_list = qmp_query_block(NULL);
+    } else {
+        block_list = NULL;
+    }
+
+    for (info = block_list; info; info = info->next) {
+        if (device && strcmp(device, info->value->device)) {
+            continue;
+        }
+
+        if (info != block_list) {
+            monitor_printf(mon, "\n");
+        }
+
+        print_block_info(mon, info->value, info->value->has_inserted
+                                           ? info->value->inserted : NULL,
+                         verbose);
+        printed = true;
+    }
+
+    qapi_free_BlockInfoList(block_list);
+
+    if ((!device && !nodes) || printed) {
+        return;
+    }
+
+    /* Print node information */
+    blockdev_list = qmp_query_named_block_nodes(NULL);
+    for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
+        assert(blockdev->value->has_node_name);
+        if (device && strcmp(device, blockdev->value->node_name)) {
+            continue;
+        }
+
+        if (blockdev != blockdev_list) {
+            monitor_printf(mon, "\n");
+        }
+
+        print_block_info(mon, NULL, blockdev->value, verbose);
+    }
+    qapi_free_BlockDeviceInfoList(blockdev_list);
+}
+
+void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
+{
+    BlockStatsList *stats_list, *stats;
+
+    stats_list = qmp_query_blockstats(false, false, NULL);
+
+    for (stats = stats_list; stats; stats = stats->next) {
+        if (!stats->value->has_device) {
+            continue;
+        }
+
+        monitor_printf(mon, "%s:", stats->value->device);
+        monitor_printf(mon, " rd_bytes=%" PRId64
+                       " wr_bytes=%" PRId64
+                       " rd_operations=%" PRId64
+                       " wr_operations=%" PRId64
+                       " flush_operations=%" PRId64
+                       " wr_total_time_ns=%" PRId64
+                       " rd_total_time_ns=%" PRId64
+                       " flush_total_time_ns=%" PRId64
+                       " rd_merged=%" PRId64
+                       " wr_merged=%" PRId64
+                       " idle_time_ns=%" PRId64
+                       "\n",
+                       stats->value->stats->rd_bytes,
+                       stats->value->stats->wr_bytes,
+                       stats->value->stats->rd_operations,
+                       stats->value->stats->wr_operations,
+                       stats->value->stats->flush_operations,
+                       stats->value->stats->wr_total_time_ns,
+                       stats->value->stats->rd_total_time_ns,
+                       stats->value->stats->flush_total_time_ns,
+                       stats->value->stats->rd_merged,
+                       stats->value->stats->wr_merged,
+                       stats->value->stats->idle_time_ns);
+    }
+
+    qapi_free_BlockStatsList(stats_list);
+}
+
+void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
+{
+    BlockJobInfoList *list;
+    Error *err = NULL;
+
+    list = qmp_query_block_jobs(&err);
+    assert(!err);
+
+    if (!list) {
+        monitor_printf(mon, "No active jobs\n");
+        return;
+    }
+
+    while (list) {
+        if (strcmp(list->value->type, "stream") == 0) {
+            monitor_printf(mon, "Streaming device %s: Completed %" PRId64
+                           " of %" PRId64 " bytes, speed limit %" PRId64
+                           " bytes/s\n",
+                           list->value->device,
+                           list->value->offset,
+                           list->value->len,
+                           list->value->speed);
+        } else {
+            monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
+                           " of %" PRId64 " bytes, speed limit %" PRId64
+                           " bytes/s\n",
+                           list->value->type,
+                           list->value->device,
+                           list->value->offset,
+                           list->value->len,
+                           list->value->speed);
+        }
+        list = list->next;
+    }
+
+    qapi_free_BlockJobInfoList(list);
+}
+
+void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
+{
+    BlockDriverState *bs, *bs1;
+    BdrvNextIterator it1;
+    QEMUSnapshotInfo *sn_tab, *sn;
+    bool no_snapshot = true;
+    int nb_sns, i;
+    int total;
+    int *global_snapshots;
+    AioContext *aio_context;
+
+    typedef struct SnapshotEntry {
+        QEMUSnapshotInfo sn;
+        QTAILQ_ENTRY(SnapshotEntry) next;
+    } SnapshotEntry;
+
+    typedef struct ImageEntry {
+        const char *imagename;
+        QTAILQ_ENTRY(ImageEntry) next;
+        QTAILQ_HEAD(, SnapshotEntry) snapshots;
+    } ImageEntry;
+
+    QTAILQ_HEAD(, ImageEntry) image_list =
+        QTAILQ_HEAD_INITIALIZER(image_list);
+
+    ImageEntry *image_entry, *next_ie;
+    SnapshotEntry *snapshot_entry;
+
+    bs = bdrv_all_find_vmstate_bs();
+    if (!bs) {
+        monitor_printf(mon, "No available block device supports snapshots\n");
+        return;
+    }
+    aio_context = bdrv_get_aio_context(bs);
+
+    aio_context_acquire(aio_context);
+    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
+    aio_context_release(aio_context);
+
+    if (nb_sns < 0) {
+        monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
+        return;
+    }
+
+    for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) {
+        int bs1_nb_sns = 0;
+        ImageEntry *ie;
+        SnapshotEntry *se;
+        AioContext *ctx = bdrv_get_aio_context(bs1);
+
+        aio_context_acquire(ctx);
+        if (bdrv_can_snapshot(bs1)) {
+            sn = NULL;
+            bs1_nb_sns = bdrv_snapshot_list(bs1, &sn);
+            if (bs1_nb_sns > 0) {
+                no_snapshot = false;
+                ie = g_new0(ImageEntry, 1);
+                ie->imagename = bdrv_get_device_name(bs1);
+                QTAILQ_INIT(&ie->snapshots);
+                QTAILQ_INSERT_TAIL(&image_list, ie, next);
+                for (i = 0; i < bs1_nb_sns; i++) {
+                    se = g_new0(SnapshotEntry, 1);
+                    se->sn = sn[i];
+                    QTAILQ_INSERT_TAIL(&ie->snapshots, se, next);
+                }
+            }
+            g_free(sn);
+        }
+        aio_context_release(ctx);
+    }
+
+    if (no_snapshot) {
+        monitor_printf(mon, "There is no snapshot available.\n");
+        return;
+    }
+
+    global_snapshots = g_new0(int, nb_sns);
+    total = 0;
+    for (i = 0; i < nb_sns; i++) {
+        SnapshotEntry *next_sn;
+        if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) {
+            global_snapshots[total] = i;
+            total++;
+            QTAILQ_FOREACH(image_entry, &image_list, next) {
+                QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots,
+                                    next, next_sn) {
+                    if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) {
+                        QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry,
+                                      next);
+                        g_free(snapshot_entry);
+                    }
+                }
+            }
+        }
+    }
+    monitor_printf(mon, "List of snapshots present on all disks:\n");
+
+    if (total > 0) {
+        bdrv_snapshot_dump(NULL);
+        monitor_printf(mon, "\n");
+        for (i = 0; i < total; i++) {
+            sn = &sn_tab[global_snapshots[i]];
+            /* The ID is not guaranteed to be the same on all images, so
+             * overwrite it.
+             */
+            pstrcpy(sn->id_str, sizeof(sn->id_str), "--");
+            bdrv_snapshot_dump(sn);
+            monitor_printf(mon, "\n");
+        }
+    } else {
+        monitor_printf(mon, "None\n");
+    }
+
+    QTAILQ_FOREACH(image_entry, &image_list, next) {
+        if (QTAILQ_EMPTY(&image_entry->snapshots)) {
+            continue;
+        }
+        monitor_printf(mon,
+                       "\nList of partial (non-loadable) snapshots on '%s':\n",
+                       image_entry->imagename);
+        bdrv_snapshot_dump(NULL);
+        monitor_printf(mon, "\n");
+        QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) {
+            bdrv_snapshot_dump(&snapshot_entry->sn);
+            monitor_printf(mon, "\n");
+        }
+    }
+
+    QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) {
+        SnapshotEntry *next_sn;
+        QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next,
+                            next_sn) {
+            g_free(snapshot_entry);
+        }
+        g_free(image_entry);
+    }
+    g_free(sn_tab);
+    g_free(global_snapshots);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index 99145c8fcf..206635ffed 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -34,5 +34,9 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
 
 void hmp_qemu_io(Monitor *mon, const QDict *qdict);
 
+void hmp_info_block(Monitor *mon, const QDict *qdict);
+void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
+void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
+void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 47a7cad734..e33ca5a911 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -30,8 +30,6 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
 void hmp_info_cpus(Monitor *mon, const QDict *qdict);
-void hmp_info_block(Monitor *mon, const QDict *qdict);
-void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
 void hmp_info_vnc(Monitor *mon, const QDict *qdict);
 void hmp_info_spice(Monitor *mon, const QDict *qdict);
 void hmp_info_balloon(Monitor *mon, const QDict *qdict);
@@ -39,7 +37,6 @@ void hmp_info_irq(Monitor *mon, const QDict *qdict);
 void hmp_info_pic(Monitor *mon, const QDict *qdict);
 void hmp_info_rdma(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
-void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
 void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
@@ -62,7 +59,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
-void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
 void hmp_migrate_continue(Monitor *mon, const QDict *qdict);
 void hmp_migrate_incoming(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index c224e0f338..1ddfe2fceb 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -45,7 +45,6 @@
 #include "qapi/string-output-visitor.h"
 #include "qom/object_interfaces.h"
 #include "ui/console.h"
-#include "block/qapi.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "exec/ramlist.h"
@@ -465,213 +464,6 @@ void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict)
                    qmp_query_migrate_cache_size(NULL) >> 10);
 }
 
-static void print_block_info(Monitor *mon, BlockInfo *info,
-                             BlockDeviceInfo *inserted, bool verbose)
-{
-    ImageInfo *image_info;
-
-    assert(!info || !info->has_inserted || info->inserted == inserted);
-
-    if (info && *info->device) {
-        monitor_printf(mon, "%s", info->device);
-        if (inserted && inserted->has_node_name) {
-            monitor_printf(mon, " (%s)", inserted->node_name);
-        }
-    } else {
-        assert(info || inserted);
-        monitor_printf(mon, "%s",
-                       inserted && inserted->has_node_name ? inserted->node_name
-                       : info && info->has_qdev ? info->qdev
-                       : "<anonymous>");
-    }
-
-    if (inserted) {
-        monitor_printf(mon, ": %s (%s%s%s)\n",
-                       inserted->file,
-                       inserted->drv,
-                       inserted->ro ? ", read-only" : "",
-                       inserted->encrypted ? ", encrypted" : "");
-    } else {
-        monitor_printf(mon, ": [not inserted]\n");
-    }
-
-    if (info) {
-        if (info->has_qdev) {
-            monitor_printf(mon, "    Attached to:      %s\n", info->qdev);
-        }
-        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
-            monitor_printf(mon, "    I/O status:       %s\n",
-                           BlockDeviceIoStatus_str(info->io_status));
-        }
-
-        if (info->removable) {
-            monitor_printf(mon, "    Removable device: %slocked, tray %s\n",
-                           info->locked ? "" : "not ",
-                           info->tray_open ? "open" : "closed");
-        }
-    }
-
-
-    if (!inserted) {
-        return;
-    }
-
-    monitor_printf(mon, "    Cache mode:       %s%s%s\n",
-                   inserted->cache->writeback ? "writeback" : "writethrough",
-                   inserted->cache->direct ? ", direct" : "",
-                   inserted->cache->no_flush ? ", ignore flushes" : "");
-
-    if (inserted->has_backing_file) {
-        monitor_printf(mon,
-                       "    Backing file:     %s "
-                       "(chain depth: %" PRId64 ")\n",
-                       inserted->backing_file,
-                       inserted->backing_file_depth);
-    }
-
-    if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
-        monitor_printf(mon, "    Detect zeroes:    %s\n",
-                BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
-    }
-
-    if (inserted->bps  || inserted->bps_rd  || inserted->bps_wr  ||
-        inserted->iops || inserted->iops_rd || inserted->iops_wr)
-    {
-        monitor_printf(mon, "    I/O throttling:   bps=%" PRId64
-                        " bps_rd=%" PRId64  " bps_wr=%" PRId64
-                        " bps_max=%" PRId64
-                        " bps_rd_max=%" PRId64
-                        " bps_wr_max=%" PRId64
-                        " iops=%" PRId64 " iops_rd=%" PRId64
-                        " iops_wr=%" PRId64
-                        " iops_max=%" PRId64
-                        " iops_rd_max=%" PRId64
-                        " iops_wr_max=%" PRId64
-                        " iops_size=%" PRId64
-                        " group=%s\n",
-                        inserted->bps,
-                        inserted->bps_rd,
-                        inserted->bps_wr,
-                        inserted->bps_max,
-                        inserted->bps_rd_max,
-                        inserted->bps_wr_max,
-                        inserted->iops,
-                        inserted->iops_rd,
-                        inserted->iops_wr,
-                        inserted->iops_max,
-                        inserted->iops_rd_max,
-                        inserted->iops_wr_max,
-                        inserted->iops_size,
-                        inserted->group);
-    }
-
-    if (verbose) {
-        monitor_printf(mon, "\nImages:\n");
-        image_info = inserted->image;
-        while (1) {
-                bdrv_image_info_dump(image_info);
-            if (image_info->has_backing_image) {
-                image_info = image_info->backing_image;
-            } else {
-                break;
-            }
-        }
-    }
-}
-
-void hmp_info_block(Monitor *mon, const QDict *qdict)
-{
-    BlockInfoList *block_list, *info;
-    BlockDeviceInfoList *blockdev_list, *blockdev;
-    const char *device = qdict_get_try_str(qdict, "device");
-    bool verbose = qdict_get_try_bool(qdict, "verbose", false);
-    bool nodes = qdict_get_try_bool(qdict, "nodes", false);
-    bool printed = false;
-
-    /* Print BlockBackend information */
-    if (!nodes) {
-        block_list = qmp_query_block(NULL);
-    } else {
-        block_list = NULL;
-    }
-
-    for (info = block_list; info; info = info->next) {
-        if (device && strcmp(device, info->value->device)) {
-            continue;
-        }
-
-        if (info != block_list) {
-            monitor_printf(mon, "\n");
-        }
-
-        print_block_info(mon, info->value, info->value->has_inserted
-                                           ? info->value->inserted : NULL,
-                         verbose);
-        printed = true;
-    }
-
-    qapi_free_BlockInfoList(block_list);
-
-    if ((!device && !nodes) || printed) {
-        return;
-    }
-
-    /* Print node information */
-    blockdev_list = qmp_query_named_block_nodes(NULL);
-    for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
-        assert(blockdev->value->has_node_name);
-        if (device && strcmp(device, blockdev->value->node_name)) {
-            continue;
-        }
-
-        if (blockdev != blockdev_list) {
-            monitor_printf(mon, "\n");
-        }
-
-        print_block_info(mon, NULL, blockdev->value, verbose);
-    }
-    qapi_free_BlockDeviceInfoList(blockdev_list);
-}
-
-void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
-{
-    BlockStatsList *stats_list, *stats;
-
-    stats_list = qmp_query_blockstats(false, false, NULL);
-
-    for (stats = stats_list; stats; stats = stats->next) {
-        if (!stats->value->has_device) {
-            continue;
-        }
-
-        monitor_printf(mon, "%s:", stats->value->device);
-        monitor_printf(mon, " rd_bytes=%" PRId64
-                       " wr_bytes=%" PRId64
-                       " rd_operations=%" PRId64
-                       " wr_operations=%" PRId64
-                       " flush_operations=%" PRId64
-                       " wr_total_time_ns=%" PRId64
-                       " rd_total_time_ns=%" PRId64
-                       " flush_total_time_ns=%" PRId64
-                       " rd_merged=%" PRId64
-                       " wr_merged=%" PRId64
-                       " idle_time_ns=%" PRId64
-                       "\n",
-                       stats->value->stats->rd_bytes,
-                       stats->value->stats->wr_bytes,
-                       stats->value->stats->rd_operations,
-                       stats->value->stats->wr_operations,
-                       stats->value->stats->flush_operations,
-                       stats->value->stats->wr_total_time_ns,
-                       stats->value->stats->rd_total_time_ns,
-                       stats->value->stats->flush_total_time_ns,
-                       stats->value->stats->rd_merged,
-                       stats->value->stats->wr_merged,
-                       stats->value->stats->idle_time_ns);
-    }
-
-    qapi_free_BlockStatsList(stats_list);
-}
 
 #ifdef CONFIG_VNC
 /* Helper for hmp_info_vnc_clients, _servers */
@@ -1051,44 +843,6 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict)
     qapi_free_PciInfoList(info_list);
 }
 
-void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
-{
-    BlockJobInfoList *list;
-    Error *err = NULL;
-
-    list = qmp_query_block_jobs(&err);
-    assert(!err);
-
-    if (!list) {
-        monitor_printf(mon, "No active jobs\n");
-        return;
-    }
-
-    while (list) {
-        if (strcmp(list->value->type, "stream") == 0) {
-            monitor_printf(mon, "Streaming device %s: Completed %" PRId64
-                           " of %" PRId64 " bytes, speed limit %" PRId64
-                           " bytes/s\n",
-                           list->value->device,
-                           list->value->offset,
-                           list->value->len,
-                           list->value->speed);
-        } else {
-            monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
-                           " of %" PRId64 " bytes, speed limit %" PRId64
-                           " bytes/s\n",
-                           list->value->type,
-                           list->value->device,
-                           list->value->offset,
-                           list->value->len,
-                           list->value->speed);
-        }
-        list = list->next;
-    }
-
-    qapi_free_BlockJobInfoList(list);
-}
-
 void hmp_info_tpm(Monitor *mon, const QDict *qdict)
 {
     TPMInfoList *info_list, *info;
@@ -1351,148 +1105,6 @@ void hmp_delvm(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
-{
-    BlockDriverState *bs, *bs1;
-    BdrvNextIterator it1;
-    QEMUSnapshotInfo *sn_tab, *sn;
-    bool no_snapshot = true;
-    int nb_sns, i;
-    int total;
-    int *global_snapshots;
-    AioContext *aio_context;
-
-    typedef struct SnapshotEntry {
-        QEMUSnapshotInfo sn;
-        QTAILQ_ENTRY(SnapshotEntry) next;
-    } SnapshotEntry;
-
-    typedef struct ImageEntry {
-        const char *imagename;
-        QTAILQ_ENTRY(ImageEntry) next;
-        QTAILQ_HEAD(, SnapshotEntry) snapshots;
-    } ImageEntry;
-
-    QTAILQ_HEAD(, ImageEntry) image_list =
-        QTAILQ_HEAD_INITIALIZER(image_list);
-
-    ImageEntry *image_entry, *next_ie;
-    SnapshotEntry *snapshot_entry;
-
-    bs = bdrv_all_find_vmstate_bs();
-    if (!bs) {
-        monitor_printf(mon, "No available block device supports snapshots\n");
-        return;
-    }
-    aio_context = bdrv_get_aio_context(bs);
-
-    aio_context_acquire(aio_context);
-    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
-    aio_context_release(aio_context);
-
-    if (nb_sns < 0) {
-        monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
-        return;
-    }
-
-    for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) {
-        int bs1_nb_sns = 0;
-        ImageEntry *ie;
-        SnapshotEntry *se;
-        AioContext *ctx = bdrv_get_aio_context(bs1);
-
-        aio_context_acquire(ctx);
-        if (bdrv_can_snapshot(bs1)) {
-            sn = NULL;
-            bs1_nb_sns = bdrv_snapshot_list(bs1, &sn);
-            if (bs1_nb_sns > 0) {
-                no_snapshot = false;
-                ie = g_new0(ImageEntry, 1);
-                ie->imagename = bdrv_get_device_name(bs1);
-                QTAILQ_INIT(&ie->snapshots);
-                QTAILQ_INSERT_TAIL(&image_list, ie, next);
-                for (i = 0; i < bs1_nb_sns; i++) {
-                    se = g_new0(SnapshotEntry, 1);
-                    se->sn = sn[i];
-                    QTAILQ_INSERT_TAIL(&ie->snapshots, se, next);
-                }
-            }
-            g_free(sn);
-        }
-        aio_context_release(ctx);
-    }
-
-    if (no_snapshot) {
-        monitor_printf(mon, "There is no snapshot available.\n");
-        return;
-    }
-
-    global_snapshots = g_new0(int, nb_sns);
-    total = 0;
-    for (i = 0; i < nb_sns; i++) {
-        SnapshotEntry *next_sn;
-        if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) {
-            global_snapshots[total] = i;
-            total++;
-            QTAILQ_FOREACH(image_entry, &image_list, next) {
-                QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots,
-                                    next, next_sn) {
-                    if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) {
-                        QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry,
-                                      next);
-                        g_free(snapshot_entry);
-                    }
-                }
-            }
-        }
-    }
-
-    monitor_printf(mon, "List of snapshots present on all disks:\n");
-
-    if (total > 0) {
-        bdrv_snapshot_dump(NULL);
-        monitor_printf(mon, "\n");
-        for (i = 0; i < total; i++) {
-            sn = &sn_tab[global_snapshots[i]];
-            /* The ID is not guaranteed to be the same on all images, so
-             * overwrite it.
-             */
-            pstrcpy(sn->id_str, sizeof(sn->id_str), "--");
-            bdrv_snapshot_dump(sn);
-            monitor_printf(mon, "\n");
-        }
-    } else {
-        monitor_printf(mon, "None\n");
-    }
-
-    QTAILQ_FOREACH(image_entry, &image_list, next) {
-        if (QTAILQ_EMPTY(&image_entry->snapshots)) {
-            continue;
-        }
-        monitor_printf(mon,
-                       "\nList of partial (non-loadable) snapshots on '%s':\n",
-                       image_entry->imagename);
-        bdrv_snapshot_dump(NULL);
-        monitor_printf(mon, "\n");
-        QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) {
-            bdrv_snapshot_dump(&snapshot_entry->sn);
-            monitor_printf(mon, "\n");
-        }
-    }
-
-    QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) {
-        SnapshotEntry *next_sn;
-        QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next,
-                            next_sn) {
-            g_free(snapshot_entry);
-        }
-        g_free(image_entry);
-    }
-    g_free(sn_tab);
-    g_free(global_snapshots);
-
-}
-
 void hmp_announce_self(Monitor *mon, const QDict *qdict)
 {
     const char *interfaces_str = qdict_get_try_str(qdict, "interfaces");
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 11/13] monitor: Move hmp_drive_add_node to block-hmp-cmds.c
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (9 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 10/13] monitor/hmp: move hmp_info_block* " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 19:03   ` Dr. David Alan Gilbert
  2020-01-27 10:36 ` [PATCH v3 12/13] add 'error' prefix to vreport Maxim Levitsky
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c | 30 ++++++++++++++++++++++++
 blockdev.c                     | 42 +++++++---------------------------
 include/block/block_int.h      |  5 ++--
 3 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index a4b1604aee..7bbe4e3814 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -33,6 +33,36 @@
 #include "monitor/hmp.h"
 #include "qemu-io.h"
 
+static void hmp_drive_add_node(Monitor *mon, const char *optstr)
+{
+    QemuOpts *opts;
+    QDict *qdict;
+    Error *local_err = NULL;
+
+    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
+    if (!opts) {
+        return;
+    }
+
+    qdict = qemu_opts_to_qdict(opts, NULL);
+
+    if (!qdict_get_try_str(qdict, "node-name")) {
+        qobject_unref(qdict);
+        error_report("'node-name' needs to be specified");
+        goto out;
+    }
+
+    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
+    if (!bs) {
+        error_report_err(local_err);
+        goto out;
+    }
+
+    bdrv_set_monitor_owned(bs);
+out:
+    qemu_opts_del(opts);
+}
+
 void hmp_drive_add(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
diff --git a/blockdev.c b/blockdev.c
index df43e0aaef..63805f34b5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -64,7 +64,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/throttle-options.h"
 
-static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
+QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
     QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
 
 static int do_open_tray(const char *blk_name, const char *qdev_id,
@@ -75,6 +75,11 @@ static void blockdev_insert_medium(bool has_device, const char *device,
                                    bool has_id, const char *id,
                                    const char *node_name, Error **errp);
 
+void bdrv_set_monitor_owned(BlockDriverState *bs)
+{
+    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
+}
+
 static const char *const if_name[IF_COUNT] = {
     [IF_NONE] = "none",
     [IF_IDE] = "ide",
@@ -652,7 +657,7 @@ err_no_opts:
 }
 
 /* Takes the ownership of bs_opts */
-static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
+BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
 {
     int bdrv_flags = 0;
 
@@ -4201,37 +4206,6 @@ out:
     aio_context_release(aio_context);
 }
 
-void hmp_drive_add_node(Monitor *mon, const char *optstr)
-{
-    QemuOpts *opts;
-    QDict *qdict;
-    Error *local_err = NULL;
-
-    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
-    if (!opts) {
-        return;
-    }
-
-    qdict = qemu_opts_to_qdict(opts, NULL);
-
-    if (!qdict_get_try_str(qdict, "node-name")) {
-        qobject_unref(qdict);
-        error_report("'node-name' needs to be specified");
-        goto out;
-    }
-
-    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
-    if (!bs) {
-        error_report_err(local_err);
-        goto out;
-    }
-
-    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
-
-out:
-    qemu_opts_del(opts);
-}
-
 void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
 {
     BlockDriverState *bs;
@@ -4261,7 +4235,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
         goto fail;
     }
 
-    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
+    bdrv_set_monitor_owned(bs);
 
 fail:
     visit_free(v);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index dd033d0b37..10df257a61 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1217,8 +1217,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
                             BlockCompletionFunc *cb, void *opaque,
                             JobTxn *txn, Error **errp);
 
-void hmp_drive_add_node(Monitor *mon, const char *optstr);
-
 BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
                                   const char *child_name,
                                   const BdrvChildRole *child_role,
@@ -1320,4 +1318,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
 
 int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
 
+void bdrv_set_monitor_owned(BlockDriverState *bs);
+BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp);
+
 #endif /* BLOCK_INT_H */
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 12/13] add 'error' prefix to vreport
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (10 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 11/13] monitor: Move hmp_drive_add_node " Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 19:30   ` Maxim Levitsky
  2020-01-27 10:36 ` [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands Maxim Levitsky
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

This changes most of qemu's error messages,
but it feels like the right thing to do.

This is WIP patch, since I updated most of iotests but not all of them,
and will be updated if this patch is accepeted in the review.
Also few error message already have 'error' prefix, which should be removed.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
---
 monitor/hmp-cmds.c               |   2 +-
 tests/qemu-iotests/020.out       |   2 +-
 tests/qemu-iotests/026.out       | 260 +++++++++++++++----------------
 tests/qemu-iotests/036.out       |  16 +-
 tests/qemu-iotests/043.out       |   6 +-
 tests/qemu-iotests/049.out       |  30 ++--
 tests/qemu-iotests/051.pc.out    | 150 +++++++++---------
 tests/qemu-iotests/054.out       |   4 +-
 tests/qemu-iotests/060.out       |  20 +--
 tests/qemu-iotests/061.out       |  26 ++--
 tests/qemu-iotests/069.out       |   2 +-
 tests/qemu-iotests/071.out       |   4 +-
 tests/qemu-iotests/074.out       |   4 +-
 tests/qemu-iotests/079.out       |   2 +-
 tests/qemu-iotests/080.out       |  72 ++++-----
 tests/qemu-iotests/081.out       |   2 +-
 tests/qemu-iotests/082.out       |  38 ++---
 tests/qemu-iotests/083.out       |  68 ++++----
 tests/qemu-iotests/098.out       |   8 +-
 tests/qemu-iotests/103.out       |  14 +-
 tests/qemu-iotests/106.out       |   4 +-
 tests/qemu-iotests/111.out       |   2 +-
 tests/qemu-iotests/112.out       |  24 +--
 tests/qemu-iotests/113.out       |   6 +-
 tests/qemu-iotests/114.out       |   2 +-
 tests/qemu-iotests/122.out       |   4 +-
 tests/qemu-iotests/133.out       |  30 ++--
 tests/qemu-iotests/137.out       |  28 ++--
 tests/qemu-iotests/140.out       |   2 +-
 tests/qemu-iotests/142.out       |  38 ++---
 tests/qemu-iotests/143.out       |   2 +-
 tests/qemu-iotests/153.out       | 118 +++++++-------
 tests/qemu-iotests/162.out       |  10 +-
 tests/qemu-iotests/172.out       |  16 +-
 tests/qemu-iotests/178.out.qcow2 |  30 ++--
 tests/qemu-iotests/178.out.raw   |  26 ++--
 tests/qemu-iotests/182.out       |   2 +-
 tests/qemu-iotests/187.out       |   6 +-
 tests/qemu-iotests/188.out       |   2 +-
 tests/qemu-iotests/197.out       |   2 +-
 tests/qemu-iotests/205           |   2 +-
 tests/qemu-iotests/215.out       |   2 +-
 tests/qemu-iotests/217.out       |   2 +-
 tests/qemu-iotests/226.out       |  12 +-
 tests/qemu-iotests/232.out       |  12 +-
 tests/qemu-iotests/233.out       |  24 +--
 tests/qemu-iotests/242.out       |   2 +-
 tests/qemu-iotests/244.out       |  14 +-
 tests/qemu-iotests/249.out       |   6 +-
 tests/qemu-iotests/261.out       |  24 +--
 tests/qemu-iotests/267.out       |  16 +-
 tests/qemu-iotests/common.filter |   2 +-
 util/qemu-error.c                |   1 +
 53 files changed, 602 insertions(+), 601 deletions(-)

diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 1ddfe2fceb..6214e6ed57 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -60,7 +60,7 @@
 void hmp_handle_error(Monitor *mon, Error *err)
 {
     if (err) {
-        error_reportf_err(err, "Error: ");
+        error_report_err(err);
     }
 }
 
diff --git a/tests/qemu-iotests/020.out b/tests/qemu-iotests/020.out
index 4b722b2dd0..41171a3795 100644
--- a/tests/qemu-iotests/020.out
+++ b/tests/qemu-iotests/020.out
@@ -1093,5 +1093,5 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=json:{'driv
                              }}}
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Block job failed: No space left on device
+qemu-img: error: Block job failed: No space left on device
 *** done
diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out
index ff0817b6f2..554eb0005b 100644
--- a/tests/qemu-iotests/026.out
+++ b/tests/qemu-iotests/026.out
@@ -3,7 +3,7 @@ Errors while writing 128 kB
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l1_update; errno: 5; imm: off; once: on; write
+Event: l1_update; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -13,21 +13,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l1_update; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: l1_update; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_update; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l1_update; errno: 28; imm: off; once: on; write
+Event: l1_update; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -37,21 +37,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l1_update; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: l1_update; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_update; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_load; errno: 5; imm: off; once: on; write
+Event: l2_load; errno: 5; imm: off; once: on; write 
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 write failed: Input/output error
@@ -67,7 +67,7 @@ read failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_load; errno: 5; imm: off; once: off; write
+Event: l2_load; errno: 5; imm: off; once: off; write 
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 write failed: Input/output error
@@ -83,7 +83,7 @@ read failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_load; errno: 28; imm: off; once: on; write
+Event: l2_load; errno: 28; imm: off; once: on; write 
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 write failed: No space left on device
@@ -99,7 +99,7 @@ read failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_load; errno: 28; imm: off; once: off; write
+Event: l2_load; errno: 28; imm: off; once: off; write 
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 write failed: No space left on device
@@ -115,7 +115,7 @@ read failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_update; errno: 5; imm: off; once: on; write
+Event: l2_update; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -125,21 +125,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_update; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: l2_update; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_update; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_update; errno: 28; imm: off; once: on; write
+Event: l2_update; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -149,21 +149,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_update; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: l2_update; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_update; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_alloc_write; errno: 5; imm: off; once: on; write
+Event: l2_alloc_write; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -173,21 +173,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_alloc_write; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: l2_alloc_write; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_alloc_write; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_alloc_write; errno: 28; imm: off; once: on; write
+Event: l2_alloc_write; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -197,21 +197,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: l2_alloc_write; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: l2_alloc_write; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_alloc_write; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: write_aio; errno: 5; imm: off; once: on; write
+Event: write_aio; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -221,21 +221,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: write_aio; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: write_aio; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: write_aio; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: write_aio; errno: 28; imm: off; once: on; write
+Event: write_aio; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -245,21 +245,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: write_aio; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: write_aio; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: write_aio; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_load; errno: 5; imm: off; once: on; write
+Event: refblock_load; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -269,21 +269,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_load; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: refblock_load; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_load; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_load; errno: 28; imm: off; once: on; write
+Event: refblock_load; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -293,21 +293,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_load; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_load; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_load; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_update_part; errno: 5; imm: off; once: on; write
+Event: refblock_update_part; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -317,21 +317,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_update_part; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: refblock_update_part; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_update_part; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_update_part; errno: 28; imm: off; once: on; write
+Event: refblock_update_part; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -341,21 +341,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_update_part; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_update_part; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_update_part; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc; errno: 5; imm: off; once: on; write
+Event: refblock_alloc; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -365,21 +365,21 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc; errno: 5; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+Event: refblock_alloc; errno: 5; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc; errno: 5; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc; errno: 28; imm: off; once: on; write
+Event: refblock_alloc; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -389,21 +389,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: cluster_alloc; errno: 5; imm: off; once: on; write
+Event: cluster_alloc; errno: 5; imm: off; once: on; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -413,7 +413,7 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: cluster_alloc; errno: 5; imm: off; once: off; write
+Event: cluster_alloc; errno: 5; imm: off; once: off; write 
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -423,7 +423,7 @@ write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: cluster_alloc; errno: 28; imm: off; once: on; write
+Event: cluster_alloc; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -433,7 +433,7 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: cluster_alloc; errno: 28; imm: off; once: off; write
+Event: cluster_alloc; errno: 28; imm: off; once: off; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -446,7 +446,7 @@ No errors were found on the image.
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_hookup; errno: 28; imm: off; once: on; write
+Event: refblock_alloc_hookup; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -456,21 +456,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write; errno: 28; imm: off; once: on; write
+Event: refblock_alloc_write; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -480,21 +480,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc_write; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc_write; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: on; write
+Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -504,21 +504,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write_table; errno: 28; imm: off; once: on; write
+Event: refblock_alloc_write_table; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -528,21 +528,21 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_switch_table; errno: 28; imm: off; once: on; write
+Event: refblock_alloc_switch_table; errno: 28; imm: off; once: on; write 
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -552,16 +552,16 @@ write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
-Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write 
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write -b
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 
@@ -595,8 +595,8 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_grow_write_table; errno: 5; imm: off; once: off
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -607,8 +607,8 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_grow_write_table; errno: 28; imm: off; once: off
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -619,8 +619,8 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_grow_activate_table; errno: 5; imm: off; once: off
-qemu-io: Failed to flush the L2 table cache: Input/output error
-qemu-io: Failed to flush the refcount block cache: Input/output error
+qemu-io: error: Failed to flush the L2 table cache: Input/output error
+qemu-io: error: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
 No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
@@ -631,8 +631,8 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_grow_activate_table; errno: 28; imm: off; once: off
-qemu-io: Failed to flush the L2 table cache: No space left on device
-qemu-io: Failed to flush the refcount block cache: No space left on device
+qemu-io: error: Failed to flush the L2 table cache: No space left on device
+qemu-io: error: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
 No errors were found on the image.
 
diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out
index 0b52b934e1..b08e7c1cc6 100644
--- a/tests/qemu-iotests/036.out
+++ b/tests/qemu-iotests/036.out
@@ -6,18 +6,18 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 incompatible_features     [63]
 compatible_features       []
 autoclear_features        []
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature
 
 === Image with multiple incompatible feature bits ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: e000000000000000
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: 6000000000000000
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: c000000000000000
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, Unknown incompatible feature: 8000000000000000
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, test3
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test2, Unknown incompatible feature: a000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: e000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: 6000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: c000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, Unknown incompatible feature: 8000000000000000
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, test3
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test2, Unknown incompatible feature: a000000000000000
 === Create image with unknown autoclear feature bit ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
diff --git a/tests/qemu-iotests/043.out b/tests/qemu-iotests/043.out
index 0280f999ce..a6f307ceeb 100644
--- a/tests/qemu-iotests/043.out
+++ b/tests/qemu-iotests/043.out
@@ -2,19 +2,19 @@ QA output created by 043
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 
 == backing file references self ==
-qemu-img: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
+qemu-img: error: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base
 
 == parent references self ==
-qemu-img: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
+qemu-img: error: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.1.base
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.2.base
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.3.base
 
 == ancestor references another ancestor ==
-qemu-img: Backing file 'TEST_DIR/t.IMGFMT.2.base' creates an infinite loop.
+qemu-img: error: Backing file 'TEST_DIR/t.IMGFMT.2.base' creates an infinite loop.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.1.base
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.2.base
diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out
index affa55b341..60d75f0290 100644
--- a/tests/qemu-iotests/049.out
+++ b/tests/qemu-iotests/049.out
@@ -92,39 +92,39 @@ 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: error: Image size must be less than 8 EiB!
 
 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: error: 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: error: Image size must be less than 8 EiB!
 
 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: error: 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: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
+qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for 
+qemu-img: error: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
 
 qemu-img create -f qcow2 -o size=1kilobyte TEST_DIR/t.qcow2
-qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below 2^64
+qemu-img: error: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below 2^64
 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: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
+qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for 
+qemu-img: error: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
 
 qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2
-qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below 2^64
+qemu-img: error: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below 2^64
 Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta-
 and exabytes, respectively.
 
 == 4. Specify size twice (-o and traditional parameter) ==
 
 qemu-img create -f qcow2 -o size=10M TEST_DIR/t.qcow2 20M
-qemu-img: TEST_DIR/t.qcow2: The image size must be specified only once
+qemu-img: error: TEST_DIR/t.qcow2: The image size must be specified only once
 
 == Check correct interpretation of suffixes for cluster size ==
 
@@ -167,11 +167,11 @@ qemu-img create -f qcow2 -o compat=1.1 TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=1.1 cluster_size=65536 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o compat=0.42 TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42'
+qemu-img: error: TEST_DIR/t.qcow2: Invalid parameter '0.42'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.42 cluster_size=65536 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o compat=foobar TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar'
+qemu-img: error: TEST_DIR/t.qcow2: Invalid parameter 'foobar'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=foobar cluster_size=65536 lazy_refcounts=off refcount_bits=16
 
 == Check preallocation option ==
@@ -183,7 +183,7 @@ qemu-img create -f qcow2 -o preallocation=metadata TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o preallocation=1234 TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234'
+qemu-img: error: TEST_DIR/t.qcow2: Invalid parameter '1234'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=1234 lazy_refcounts=off refcount_bits=16
 
 == Check encryption option ==
@@ -206,7 +206,7 @@ qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=off TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.10 cluster_size=65536 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=on TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
+qemu-img: error: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.10 cluster_size=65536 lazy_refcounts=on refcount_bits=16
 
 *** done
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index 0ea80d35f0..ddb035cf10 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -5,46 +5,46 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/
 === Unknown option ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: error: Block format 'qcow2' does not support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: error: Block format 'qcow2' does not support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: error: Block format 'qcow2' does not support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: error: Block format 'qcow2' does not support the option 'unknown_opt'
 
 
 === Unknown protocol option ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=: Block protocol 'file' doesn't support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=: error: Block protocol 'file' doesn't support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=on
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=on: Block protocol 'file' doesn't support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=on: error: Block protocol 'file' doesn't support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=1234
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=1234: Block protocol 'file' doesn't support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=1234: error: Block protocol 'file' doesn't support the option 'unknown_opt'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=foo: Block protocol 'file' doesn't support the option 'unknown_opt'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=foo: error: Block protocol 'file' doesn't support the option 'unknown_opt'
 
 
 === Invalid format ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=foo: Unknown driver 'foo'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=foo: error: Unknown driver 'foo'
 
 Testing: -drive file=TEST_DIR/t.qcow2,driver=foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=foo: Unknown driver 'foo'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=foo: error: Unknown driver 'foo'
 
 Testing: -drive file=TEST_DIR/t.qcow2,driver=raw,format=qcow2
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=raw,format=qcow2: Cannot specify both 'driver' and 'format'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=raw,format=qcow2: error: Cannot specify both 'driver' and 'format'
 
 Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specify both 'driver' and 'format'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: error: Cannot specify both 'driver' and 'format'
 
 
 === Node names ===
@@ -54,27 +54,27 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: Node name too long
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: error: Node name too long
 
 Testing: -drive file=TEST_DIR/t.qcow2,node-name=All-Types.of_all0wed_chars
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,node-name=123foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: Invalid node name
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: error: Invalid node name
 
 Testing: -drive file=TEST_DIR/t.qcow2,node-name=_foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: Invalid node name
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: error: Invalid node name
 
 Testing: -drive file=TEST_DIR/t.qcow2,node-name=foo#12
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: Invalid node name
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: error: Invalid node name
 
 
 === Device without drive ===
 
 Testing: -device VIRTIO_SCSI -device scsi-hd
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device scsi-hd: drive property not set
+(qemu) QEMU_PROG: -device scsi-hd: error: drive property not set
 
 
 === Overriding backing file ===
@@ -89,13 +89,13 @@ drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver": "fil
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,driver=raw,backing.file.filename=TEST_DIR/t.qcow2.orig
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=raw,backing.file.filename=TEST_DIR/t.qcow2.orig: Driver doesn't support backing files
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=raw,backing.file.filename=TEST_DIR/t.qcow2.orig: error: Driver doesn't support backing files
 
 Testing: -drive file=TEST_DIR/t.qcow2,file.backing.driver=file,file.backing.filename=TEST_DIR/t.qcow2.orig
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.backing.driver=file,file.backing.filename=TEST_DIR/t.qcow2.orig: Driver doesn't support backing files
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.backing.driver=file,file.backing.filename=TEST_DIR/t.qcow2.orig: error: Driver doesn't support backing files
 
 Testing: -drive file=TEST_DIR/t.qcow2,file.backing.driver=qcow2,file.backing.file.filename=TEST_DIR/t.qcow2.orig
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.backing.driver=qcow2,file.backing.file.filename=TEST_DIR/t.qcow2.orig: Driver doesn't support backing files
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.backing.driver=qcow2,file.backing.file.filename=TEST_DIR/t.qcow2.orig: error: Driver doesn't support backing files
 
 
 === Enable and disable lazy refcounting on the command line, plus some invalid values ===
@@ -110,20 +110,20 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=: Parameter 'lazy-refcounts' expects 'on' or 'off'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=: error: Parameter 'lazy-refcounts' expects 'on' or 'off'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=42
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=42: Parameter 'lazy-refcounts' expects 'on' or 'off'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=42: error: Parameter 'lazy-refcounts' expects 'on' or 'off'
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=foo
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=foo: Parameter 'lazy-refcounts' expects 'on' or 'off'
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=foo: error: Parameter 'lazy-refcounts' expects 'on' or 'off'
 
 
 === With version 2 images enabling lazy refcounts must fail ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on: Lazy refcounts require a qcow2 image with at least qemu 1.1 compatibility level
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on: error: Lazy refcounts require a qcow2 image with at least qemu 1.1 compatibility level
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=off
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -142,11 +142,11 @@ QEMU X.Y.Z monitor - type 'help' for more information
 
 Testing: -drive if=ide
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
+(qemu) QEMU_PROG: error: Initialization of device ide-hd failed: Device needs media, but drive is empty
 
 Testing: -drive if=virtio
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -drive if=virtio: Device needs media, but drive is empty
+(qemu) QEMU_PROG: -drive if=virtio: error: Device needs media, but drive is empty
 
 Testing: -drive if=none,id=disk -device ide-cd,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -159,43 +159,43 @@ QEMU X.Y.Z monitor - type 'help' for more information
 Testing: -drive if=none,id=disk -device ide-drive,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: -device ide-drive,drive=disk: warning: 'ide-drive' is deprecated, please use 'ide-hd' or 'ide-cd' instead
-QEMU_PROG: -device ide-drive,drive=disk: Device needs media, but drive is empty
+QEMU_PROG: -device ide-drive,drive=disk: error: Device needs media, but drive is empty
 
 Testing: -drive if=none,id=disk -device ide-hd,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device ide-hd,drive=disk: Device needs media, but drive is empty
+(qemu) QEMU_PROG: -device ide-hd,drive=disk: error: Device needs media, but drive is empty
 
 Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: -device scsi-disk,drive=disk: warning: 'scsi-disk' is deprecated, please use 'scsi-hd' or 'scsi-cd' instead
-QEMU_PROG: -device scsi-disk,drive=disk: Device needs media, but drive is empty
+QEMU_PROG: -device scsi-disk,drive=disk: error: Device needs media, but drive is empty
 
 Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device scsi-hd,drive=disk: Device needs media, but drive is empty
+(qemu) QEMU_PROG: -device scsi-hd,drive=disk: error: Device needs media, but drive is empty
 
 
 === Attach to node in non-default iothread ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device ide-hd,drive=disk,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device ide-hd,drive=disk,share-rw=on: Cannot change iothread of active block backend
+(qemu) QEMU_PROG: -device ide-hd,drive=disk,share-rw=on: error: Cannot change iothread of active block backend
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device virtio-blk-pci,drive=disk,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device virtio-blk-pci,drive=disk,share-rw=on: Cannot change iothread of active block backend
+(qemu) QEMU_PROG: -device virtio-blk-pci,drive=disk,share-rw=on: error: Cannot change iothread of active block backend
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device lsi53c895a,id=lsi0 -device scsi-hd,bus=lsi0.0,drive=disk,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device scsi-hd,bus=lsi0.0,drive=disk,share-rw=on: HBA does not support iothreads
+(qemu) QEMU_PROG: -device scsi-hd,bus=lsi0.0,drive=disk,share-rw=on: error: HBA does not support iothreads
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device virtio-scsi,id=virtio-scsi1 -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on: Cannot change iothread of active block backend
+(qemu) QEMU_PROG: -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on: error: Cannot change iothread of active block backend
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device virtio-blk-pci,drive=disk,iohtread=iothread0,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device virtio-blk-pci,drive=disk,iohtread=iothread0,share-rw=on: Cannot change iothread of active block backend
+(qemu) QEMU_PROG: -device virtio-blk-pci,drive=disk,iohtread=iothread0,share-rw=on: error: Cannot change iothread of active block backend
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on -device virtio-scsi,id=virtio-scsi1,iothread=thread0 -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -214,7 +214,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
+(qemu) QEMU_PROG: error: Initialization of device ide-hd failed: Block node is read-only
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -231,11 +231,11 @@ QEMU X.Y.Z monitor - type 'help' for more information
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-drive,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: -device ide-drive,drive=disk: warning: 'ide-drive' is deprecated, please use 'ide-hd' or 'ide-cd' instead
-QEMU_PROG: -device ide-drive,drive=disk: Block node is read-only
+QEMU_PROG: -device ide-drive,drive=disk: error: Block node is read-only
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-hd,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: -device ide-hd,drive=disk: Block node is read-only
+(qemu) QEMU_PROG: -device ide-hd,drive=disk: error: Block node is read-only
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -270,7 +270,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive driver=null-co,cache=invalid_value
-QEMU_PROG: -drive driver=null-co,cache=invalid_value: invalid cache option
+QEMU_PROG: -drive driver=null-co,cache=invalid_value: error: invalid cache option
 
 Testing: -drive file=TEST_DIR/t.qcow2,cache=writeback,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -333,7 +333,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0: invalid cache option
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0: error: invalid cache option
 
 
 === Specifying the protocol layer ===
@@ -346,94 +346,94 @@ QEMU X.Y.Z monitor - type 'help' for more information
 === Leaving out required options ===
 
 Testing: -drive driver=file
-QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name
+QEMU_PROG: -drive driver=file: error: The 'file' block driver requires a file name
 
 Testing: -drive driver=file,filename=
-QEMU_PROG: -drive driver=file,filename=: The 'file' block driver requires a file name
+QEMU_PROG: -drive driver=file,filename=: error: The 'file' block driver requires a file name
 
 Testing: -drive driver=nbd
-QEMU_PROG: -drive driver=nbd: NBD server address missing
+QEMU_PROG: -drive driver=nbd: error: NBD server address missing
 
 Testing: -drive driver=raw
-QEMU_PROG: -drive driver=raw: A block device must be specified for "file"
+QEMU_PROG: -drive driver=raw: error: A block device must be specified for "file"
 
 Testing: -drive file.driver=file
-QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name
+QEMU_PROG: -drive file.driver=file: error: The 'file' block driver requires a file name
 
 Testing: -drive file.driver=nbd
-QEMU_PROG: -drive file.driver=nbd: NBD server address missing
+QEMU_PROG: -drive file.driver=nbd: error: NBD server address missing
 
 Testing: -drive file.driver=raw
-QEMU_PROG: -drive file.driver=raw: A block device must be specified for "file"
+QEMU_PROG: -drive file.driver=raw: error: A block device must be specified for "file"
 
 Testing: -drive foo=bar
-QEMU_PROG: -drive foo=bar: Must specify either driver or file
+QEMU_PROG: -drive foo=bar: error: Must specify either driver or file
 
 
 === Specifying both an option and its legacy alias ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops=1234,throttling.iops-total=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops=1234,throttling.iops-total=5678: 'throttling.iops-total' and its alias 'iops' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops=1234,throttling.iops-total=5678: error: 'throttling.iops-total' and its alias 'iops' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_rd=1234,throttling.iops-read=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_rd=1234,throttling.iops-read=5678: 'throttling.iops-read' and its alias 'iops_rd' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_rd=1234,throttling.iops-read=5678: error: 'throttling.iops-read' and its alias 'iops_rd' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_wr=1234,throttling.iops-write=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_wr=1234,throttling.iops-write=5678: 'throttling.iops-write' and its alias 'iops_wr' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_wr=1234,throttling.iops-write=5678: error: 'throttling.iops-write' and its alias 'iops_wr' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps=1234,throttling.bps-total=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=1234,throttling.bps-total=5678: 'throttling.bps-total' and its alias 'bps' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=1234,throttling.bps-total=5678: error: 'throttling.bps-total' and its alias 'bps' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_rd=1234,throttling.bps-read=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd=1234,throttling.bps-read=5678: 'throttling.bps-read' and its alias 'bps_rd' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd=1234,throttling.bps-read=5678: error: 'throttling.bps-read' and its alias 'bps_rd' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_wr=1234,throttling.bps-write=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_wr=1234,throttling.bps-write=5678: 'throttling.bps-write' and its alias 'bps_wr' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_wr=1234,throttling.bps-write=5678: error: 'throttling.bps-write' and its alias 'bps_wr' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_max=1234,throttling.iops-total-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_max=1234,throttling.iops-total-max=5678: 'throttling.iops-total-max' and its alias 'iops_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_max=1234,throttling.iops-total-max=5678: error: 'throttling.iops-total-max' and its alias 'iops_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_rd_max=1234,throttling.iops-read-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_rd_max=1234,throttling.iops-read-max=5678: 'throttling.iops-read-max' and its alias 'iops_rd_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_rd_max=1234,throttling.iops-read-max=5678: error: 'throttling.iops-read-max' and its alias 'iops_rd_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_wr_max=1234,throttling.iops-write-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_wr_max=1234,throttling.iops-write-max=5678: 'throttling.iops-write-max' and its alias 'iops_wr_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_wr_max=1234,throttling.iops-write-max=5678: error: 'throttling.iops-write-max' and its alias 'iops_wr_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_max=1234,throttling.bps-total-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_max=1234,throttling.bps-total-max=5678: 'throttling.bps-total-max' and its alias 'bps_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_max=1234,throttling.bps-total-max=5678: error: 'throttling.bps-total-max' and its alias 'bps_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_rd_max=1234,throttling.bps-read-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd_max=1234,throttling.bps-read-max=5678: 'throttling.bps-read-max' and its alias 'bps_rd_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd_max=1234,throttling.bps-read-max=5678: error: 'throttling.bps-read-max' and its alias 'bps_rd_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_wr_max=1234,throttling.bps-write-max=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_wr_max=1234,throttling.bps-write-max=5678: 'throttling.bps-write-max' and its alias 'bps_wr_max' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_wr_max=1234,throttling.bps-write-max=5678: error: 'throttling.bps-write-max' and its alias 'bps_wr_max' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops_size=1234,throttling.iops-size=5678
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_size=1234,throttling.iops-size=5678: 'throttling.iops-size' and its alias 'iops_size' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops_size=1234,throttling.iops-size=5678: error: 'throttling.iops-size' and its alias 'iops_size' can't be used at the same time
 
 Testing: -drive file=TEST_DIR/t.qcow2,readonly=on,read-only=off
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,readonly=on,read-only=off: 'read-only' and its alias 'readonly' can't be used at the same time
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,readonly=on,read-only=off: error: 'read-only' and its alias 'readonly' can't be used at the same time
 
 
 === Catching negative/large throttling values ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,iops=-1
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops=-1: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,iops=-1: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps=-2
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=-2: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=-2: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_rd=-3
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd=-3: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd=-3: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps_rd_max=-3
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd_max=-3: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps_rd_max=-3: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,throttling.iops-total=-4
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,throttling.iops-total=-4: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,throttling.iops-total=-4: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,throttling.bps-total=-5
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,throttling.bps-total=-5: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,throttling.bps-total=-5: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps=0
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -448,22 +448,22 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps=1000000000000001
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=1000000000000001: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=1000000000000001: error: bps/iops/max values must be within [0, 1000000000000000]
 
 Testing: -drive file=TEST_DIR/t.qcow2,bps=9999999999999999
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=9999999999999999: bps/iops/max values must be within [0, 1000000000000000]
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,bps=9999999999999999: error: bps/iops/max values must be within [0, 1000000000000000]
 
 
 === Parsing protocol from file name ===
 
 Testing: -hda foo:bar
-QEMU_PROG: -hda foo:bar: Unknown protocol 'foo'
+QEMU_PROG: -hda foo:bar: error: Unknown protocol 'foo'
 
 Testing: -drive file=foo:bar
-QEMU_PROG: -drive file=foo:bar: Unknown protocol 'foo'
+QEMU_PROG: -drive file=foo:bar: error: Unknown protocol 'foo'
 
 Testing: -drive file.filename=foo:bar
-QEMU_PROG: -drive file.filename=foo:bar: Could not open 'foo:bar': No such file or directory
+QEMU_PROG: -drive file.filename=foo:bar: error: Could not open 'foo:bar': No such file or directory
 
 Testing: -hda file:TEST_DIR/t.qcow2
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -474,7 +474,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file.filename=file:TEST_DIR/t.qcow2
-QEMU_PROG: -drive file.filename=file:TEST_DIR/t.qcow2: Could not open 'file:TEST_DIR/t.qcow2': No such file or directory
+QEMU_PROG: -drive file.filename=file:TEST_DIR/t.qcow2: error: Could not open 'file:TEST_DIR/t.qcow2': No such file or directory
 
 
 === Snapshot mode ===
@@ -559,7 +559,7 @@ wrote 4096/4096 bytes at offset 0
 read 4096/4096 bytes at offset 0
 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 Testing: -drive driver=null-co,snapshot=on
-QEMU_PROG: -drive driver=null-co,snapshot=on: Could not get temporary filename: No such file or directory
+QEMU_PROG: -drive driver=null-co,snapshot=on: error: Could not get temporary filename: No such file or directory
 
 Testing: -drive file=TEST_DIR/t.qcow2,snapshot=on,read-only=on,if=none,id=drive0
 QEMU X.Y.Z monitor - type 'help' for more information
diff --git a/tests/qemu-iotests/054.out b/tests/qemu-iotests/054.out
index e6ec430edd..7cddf38bc0 100644
--- a/tests/qemu-iotests/054.out
+++ b/tests/qemu-iotests/054.out
@@ -1,10 +1,10 @@
 QA output created by 054
 
 creating too large image (1 EB)
-qemu-img: TEST_DIR/t.IMGFMT: The image size is too large for file format 'IMGFMT' (try using a larger cluster size)
+qemu-img: error: TEST_DIR/t.IMGFMT: The image size is too large for file format 'IMGFMT' (try using a larger cluster size)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1152921504606846976
 
 creating too large image (1 EB) using qcow2.py
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Image is too big
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Image is too big
 *** done
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
index d27692a33c..1162a9372e 100644
--- a/tests/qemu-iotests/060.out
+++ b/tests/qemu-iotests/060.out
@@ -20,7 +20,7 @@ Format specific information:
     lazy refcounts: false
     refcount bits: 16
     corrupt: true
-qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
 no file open, try 'help open'
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -132,7 +132,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 qcow2: Marking image as corrupt: L2 table offset 0x42a00 unaligned (L1 index: 0); further corruption events will be suppressed
-qemu-img: Failed to turn zero into data clusters: Input/output error
+qemu-img: error: Failed to turn zero into data clusters: Input/output error
 
 === Testing unaligned L2 entry ===
 
@@ -148,7 +148,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 qcow2: Marking image as corrupt: Cluster allocation offset 0x52a00 unaligned (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
-qemu-img: Failed to turn zero into data clusters: Input/output error
+qemu-img: error: Failed to turn zero into data clusters: Input/output error
 
 === Testing unaligned reftable entry ===
 
@@ -270,7 +270,7 @@ No errors were found on the image.
 === Testing zero refcount table size ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.IMGFMT: Image does not contain a reference count table
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: Image does not contain a reference count table
 ERROR cluster 0 refcount=0 reference=1
 ERROR cluster 3 refcount=0 reference=1
 Rebuilding refcount structure
@@ -299,7 +299,7 @@ Can't get refcount for cluster 2: Input/output error
 Can't get refcount for cluster 3: Input/output error
 Rebuilding refcount structure
 Repairing cluster 1 refcount=1 reference=0
-qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not repair dirty image: Input/output error
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: Could not repair dirty image: Input/output error
 --- Repairing ---
 Leaked cluster 1 refcount=1 reference=0
 Repairing cluster 1 refcount=1 reference=0
@@ -350,7 +350,7 @@ Can't get refcount for cluster 5: Input/output error
 Can't get refcount for cluster 6: Input/output error
 Rebuilding refcount structure
 Repairing cluster 1 refcount=1 reference=0
-qemu-img: Check failed: No medium found
+qemu-img: error: Check failed: No medium found
 Leaked cluster 1 refcount=1 reference=0
 Repairing cluster 1 refcount=1 reference=0
 The following inconsistencies were found and repaired:
@@ -365,7 +365,7 @@ No errors were found on the image.
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qcow2: Marking image as corrupt: Refblock at 0xffffff00000000 is not covered by the refcount structures; further corruption events will be suppressed
-qemu-img: Failed to discard unused refblocks: Input/output error
+qemu-img: error: Failed to discard unused refblocks: Input/output error
 --- Checking and retrying ---
 virtual size: 64 MiB (67108864 bytes)
 No errors were found on the image.
@@ -376,7 +376,7 @@ virtual size: 32 MiB (33554432 bytes)
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qcow2: Marking image as corrupt: Refblock at 0x1000000000 is not covered by the refcount structures; further corruption events will be suppressed
-qemu-img: Failed to discard unused refblocks: Input/output error
+qemu-img: error: Failed to discard unused refblocks: Input/output error
 --- Checking and retrying ---
 virtual size: 64 MiB (67108864 bytes)
 No errors were found on the image.
@@ -387,7 +387,7 @@ virtual size: 32 MiB (33554432 bytes)
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qcow2: Marking image as corrupt: Cannot get entry from refcount block cache: Offset 0x200 is unaligned; further corruption events will be suppressed
-qemu-img: Failed to discard unused refblocks: Input/output error
+qemu-img: error: Failed to discard unused refblocks: Input/output error
 --- Repairing ---
 Repairing refcount block 1 is outside image
 ERROR refcount block 2 is not cluster aligned; refcount table entry corrupted
@@ -397,7 +397,7 @@ Rebuilding refcount structure
 Repairing cluster 1 refcount=1 reference=0
 Repairing cluster 2 refcount=1 reference=0
 Repairing cluster 1048576 refcount=1 reference=0
-qemu-img: Check failed: No medium found
+qemu-img: error: Check failed: No medium found
 Leaked cluster 1 refcount=1 reference=0
 Leaked cluster 2 refcount=1 reference=0
 Leaked cluster 1048576 refcount=1 reference=0
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
index 8b3091a412..06245c0f99 100644
--- a/tests/qemu-iotests/061.out
+++ b/tests/qemu-iotests/061.out
@@ -349,20 +349,20 @@ No errors were found on the image.
 === Testing invalid configurations ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
-qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
-qemu-img: Unknown compatibility level 0.42
-qemu-img: Invalid parameter 'foo'
-qemu-img: Changing the cluster size is not supported
-qemu-img: Changing the encryption flag is not supported
-qemu-img: Cannot change preallocation mode
+qemu-img: error: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
+qemu-img: error: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
+qemu-img: error: Unknown compatibility level 0.42
+qemu-img: error: Invalid parameter 'foo'
+qemu-img: error: Changing the cluster size is not supported
+qemu-img: error: Changing the encryption flag is not supported
+qemu-img: error: Cannot change preallocation mode
 
 === Testing correct handling of unset value ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 Should work:
 Should not work:
-qemu-img: Changing the cluster size is not supported
+qemu-img: error: Changing the cluster size is not supported
 
 === Testing zero expansion on inactive clusters ===
 
@@ -484,7 +484,7 @@ No errors were found on the image.
 === Testing version downgrade with external data file ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
-qemu-img: Cannot downgrade an image with a data file
+qemu-img: error: Cannot downgrade an image with a data file
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
@@ -501,10 +501,10 @@ No errors were found on the image.
 === Try changing the external data file ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: data-file can only be set for images that use an external data file
+qemu-img: error: data-file can only be set for images that use an external data file
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'foo': No such file or directory
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'foo': No such file or directory
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
@@ -517,7 +517,7 @@ Format specific information:
     data file raw: false
     corrupt: false
 
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'data-file' is required for this image
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': 'data-file' is required for this image
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
@@ -556,7 +556,7 @@ Format specific information:
     data file raw: false
     corrupt: false
 No errors were found on the image.
-qemu-img: data-file-raw cannot be set on existing images
+qemu-img: error: data-file-raw cannot be set on existing images
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
diff --git a/tests/qemu-iotests/069.out b/tests/qemu-iotests/069.out
index c78e8c2b72..96e3ff2dd6 100644
--- a/tests/qemu-iotests/069.out
+++ b/tests/qemu-iotests/069.out
@@ -4,5 +4,5 @@ QA output created by 069
 
 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=131072
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 backing_file=TEST_DIR/t.IMGFMT.base
-qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open backing file: Could not open 'TEST_DIR/t.IMGFMT.base': No such file or directory
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: Could not open backing file: Could not open 'TEST_DIR/t.IMGFMT.base': No such file or directory
 *** done
diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out
index bca0c02f5c..30e5266583 100644
--- a/tests/qemu-iotests/071.out
+++ b/tests/qemu-iotests/071.out
@@ -86,7 +86,7 @@ read failed: Input/output error
 {"return": ""}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
-QEMU_PROG: Failed to flush the L2 table cache: Input/output error
-QEMU_PROG: Failed to flush the refcount block cache: Input/output error
+QEMU_PROG: error: Failed to flush the L2 table cache: Input/output error
+QEMU_PROG: error: Failed to flush the refcount block cache: Input/output error
 
 *** done
diff --git a/tests/qemu-iotests/074.out b/tests/qemu-iotests/074.out
index ede66c3f81..cd8bcb3b67 100644
--- a/tests/qemu-iotests/074.out
+++ b/tests/qemu-iotests/074.out
@@ -3,14 +3,14 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 === IO: pattern 102
 wrote 512/512 bytes at offset 512
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 4
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0
 === IO: pattern 102
 wrote 512/512 bytes at offset 512
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 Warning: Image size mismatch!
 4
 Cleanup
diff --git a/tests/qemu-iotests/079.out b/tests/qemu-iotests/079.out
index aab922fb36..e3b2cf0ba1 100644
--- a/tests/qemu-iotests/079.out
+++ b/tests/qemu-iotests/079.out
@@ -9,6 +9,6 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadat
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
-qemu-img: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 512 and 2048k
+qemu-img: error: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 512 and 2048k
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
 *** done
diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out
index 45ab01db8e..b9f32f27d4 100644
--- a/tests/qemu-iotests/080.out
+++ b/tests/qemu-iotests/080.out
@@ -2,75 +2,75 @@ QA output created by 080
 
 == Huge header size ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
-qemu-io: can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
+qemu-io: error: can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
+qemu-io: error: can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
 
 == Huge unknown header extension ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Invalid backing file offset
-qemu-io: can't open device TEST_DIR/t.qcow2: Header extension too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Header extension too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Invalid backing file offset
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Header extension too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Header extension too large
 
 == Huge refcount table size ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Reference count table too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Reference count table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Reference count table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Reference count table too large
 
 == Misaligned refcount table ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
 
 == Huge refcount offset ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Reference count table offset invalid
 
 == Invalid snapshot table ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Snapshot table too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Snapshot table too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
-qemu-io: can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Snapshot table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Snapshot table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Snapshot table offset invalid
 
 == Hitting snapshot table size limit ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Could not create snapshot 'test': -27 (File too large)
+qemu-img: error: Could not create snapshot 'test': -27 (File too large)
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == Invalid L1 table ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Active L1 table too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Active L1 table too large
-qemu-io: can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
-qemu-io: can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Active L1 table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Active L1 table too large
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Active L1 table offset invalid
 
 == Invalid L1 table (with internal snapshot in the image) ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small
 
 == Invalid backing file size ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: Backing file name too long
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Backing file name too long
 
 == Invalid L2 entry (huge physical offset) ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not create snapshot 'test': -27 (File too large)
-qemu-img: Could not create snapshot 'test': -11 (Resource temporarily unavailable)
+qemu-img: error: Could not create snapshot 'test': -27 (File too large)
+qemu-img: error: Could not create snapshot 'test': -11 (Resource temporarily unavailable)
 
 == Invalid snapshot L1 table offset ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Failed to load snapshot: Snapshot L1 table offset invalid
-qemu-img: Snapshot L1 table offset invalid
-qemu-img: Failed to turn zero into data clusters: Invalid argument
-qemu-io: Failed to flush the refcount block cache: Invalid argument
+qemu-img: error: Failed to load snapshot: Snapshot L1 table offset invalid
+qemu-img: error: Snapshot L1 table offset invalid
+qemu-img: error: Failed to turn zero into data clusters: Invalid argument
+qemu-io: error: Failed to flush the refcount block cache: Invalid argument
 write failed: Invalid argument
-qemu-img: Snapshot L1 table offset invalid
-qemu-img: Could not apply snapshot 'test': Failed to load snapshot: Invalid argument
-qemu-img: Could not delete snapshot 'test': Snapshot L1 table offset invalid
+qemu-img: error: Snapshot L1 table offset invalid
+qemu-img: error: Could not apply snapshot 'test': Failed to load snapshot: Invalid argument
+qemu-img: error: Could not delete snapshot 'test': Snapshot L1 table offset invalid
 ERROR snapshot 1 (test) l1_offset=0x400200: L1 table is not cluster aligned; snapshot table entry corrupted
 Leaked cluster 4 refcount=2 reference=1
 Leaked cluster 5 refcount=2 reference=1
@@ -86,14 +86,14 @@ This means waste of disk space, but no harm to data.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Failed to load snapshot: Snapshot L1 table too large
-qemu-img: Snapshot L1 table too large
-qemu-img: Failed to turn zero into data clusters: File too large
-qemu-io: Failed to flush the refcount block cache: File too large
+qemu-img: error: Failed to load snapshot: Snapshot L1 table too large
+qemu-img: error: Snapshot L1 table too large
+qemu-img: error: Failed to turn zero into data clusters: File too large
+qemu-io: error: Failed to flush the refcount block cache: File too large
 write failed: File too large
-qemu-img: Snapshot L1 table too large
-qemu-img: Could not apply snapshot 'test': Failed to load snapshot: File too large
-qemu-img: Could not delete snapshot 'test': Snapshot L1 table too large
+qemu-img: error: Snapshot L1 table too large
+qemu-img: error: Could not apply snapshot 'test': Failed to load snapshot: File too large
+qemu-img: error: Could not delete snapshot 'test': Snapshot L1 table too large
 ERROR snapshot 1 (test) l1_size=0x10000000: L1 table is too large; snapshot table entry corrupted
 Leaked cluster 4 refcount=2 reference=1
 Leaked cluster 5 refcount=2 reference=1
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index 04091b64e5..129a628f87 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -70,7 +70,7 @@ read 10485760/10485760 bytes at offset 0
 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == checking the blkverify mode with invalid settings ==
-qemu-io: can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
+qemu-io: error: can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
 
 == dynamically adding a child to a quorum ==
 Testing:
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
index 9d4ed4dc9d..8391e485da 100644
--- a/tests/qemu-iotests/082.out
+++ b/tests/qemu-iotests/082.out
@@ -233,13 +233,13 @@ Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,? cluster_size=65536 lazy_refcounts=off refcount_bits=16
 
 Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M
-qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2,
+qemu-img: error: Invalid option list: backing_file=TEST_DIR/t.qcow2,
 
 Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2 128M
-qemu-img: Invalid option list: ,help
+qemu-img: error: Invalid option list: ,help
 
 Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2 128M
-qemu-img: Invalid option list: ,,
+qemu-img: error: Invalid option list: ,,
 
 Testing: create -f qcow2 -o help
 Supported qcow2 options:
@@ -274,7 +274,7 @@ The protocol level may support further options.
 Specify the target filename to include those options.
 
 Testing: create -f bochs -o help
-qemu-img: Format driver 'bochs' does not support image creation
+qemu-img: error: Format driver 'bochs' does not support image creation
 
 === convert: Options specified more than once ===
 
@@ -507,19 +507,19 @@ Supported options:
   size=<size>            - Virtual disk size
 
 Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory
 
 Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,?': No such file or directory
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,?': No such file or directory
 
 Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
-qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2,
+qemu-img: error: Invalid option list: backing_file=TEST_DIR/t.qcow2,
 
 Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
-qemu-img: Invalid option list: ,help
+qemu-img: error: Invalid option list: ,help
 
 Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
-qemu-img: Invalid option list: ,,
+qemu-img: error: Invalid option list: ,,
 
 Testing: convert -O qcow2 -o help
 Supported qcow2 options:
@@ -554,21 +554,21 @@ The protocol level may support further options.
 Specify the target filename to include those options.
 
 Testing: convert -O bochs -o help
-qemu-img: Format driver 'bochs' does not support image creation
+qemu-img: error: Format driver 'bochs' does not support image creation
 
 === convert: -C and other options ===
 
 Testing: convert -C -S 4k -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target
-qemu-img: Cannot enable copy offloading when -S is used
+qemu-img: error: Cannot enable copy offloading when -S is used
 
 Testing: convert -C -S 8k -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target
-qemu-img: Cannot enable copy offloading when -S is used
+qemu-img: error: Cannot enable copy offloading when -S is used
 
 Testing: convert -C -c -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target
-qemu-img: Cannot enable copy offloading when -c is used
+qemu-img: error: Cannot enable copy offloading when -c is used
 
 Testing: convert -C --salvage -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target
-qemu-img: Cannot use copy offloading in salvaging mode
+qemu-img: error: Cannot use copy offloading in salvaging mode
 
 === amend: Options specified more than once ===
 
@@ -814,13 +814,13 @@ Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2
 Testing: rebase -u -b  -f qcow2 TEST_DIR/t.qcow2
 
 Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2
-qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2,
+qemu-img: error: Invalid option list: backing_file=TEST_DIR/t.qcow2,
 
 Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2
-qemu-img: Invalid option list: ,help
+qemu-img: error: Invalid option list: ,help
 
 Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2
-qemu-img: Invalid option list: ,,
+qemu-img: error: Invalid option list: ,,
 
 Testing: amend -f qcow2 -o help
 Creation options for 'qcow2':
@@ -847,8 +847,8 @@ Creation options for 'qcow2':
 Note that not all of these options may be amendable.
 
 Testing: amend -o help
-qemu-img: Expecting one image file name
+qemu-img: error: Expecting one image file name
 
 Testing: amend -f bochs -o help
-qemu-img: Format driver 'bochs' does not support option amendment
+qemu-img: error: Format driver 'bochs' does not support option amendment
 *** done
diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out
index 2090ee693c..696fb5ff75 100644
--- a/tests/qemu-iotests/083.out
+++ b/tests/qemu-iotests/083.out
@@ -1,43 +1,43 @@
 QA output created by 083
 === Check disconnect before neg1 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect after neg1 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 8 neg1 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 16 neg1 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect before export ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect after export ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 4 export ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 12 export ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 16 export ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect before neg2 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect after neg2 ===
 
@@ -45,11 +45,11 @@ read failed: Input/output error
 
 === Check disconnect 8 neg2 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect 10 neg2 ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/foo
 
 === Check disconnect before request ===
 
@@ -86,23 +86,23 @@ read 512/512 bytes at offset 0
 
 === Check disconnect before neg-classic ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/
 
 === Check disconnect 8 neg-classic ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/
 
 === Check disconnect 16 neg-classic ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/
 
 === Check disconnect 24 neg-classic ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/
 
 === Check disconnect 28 neg-classic ===
 
-qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/
+qemu-io: error: can't open device nbd+tcp://127.0.0.1:PORT/
 
 === Check disconnect after neg-classic ===
 
@@ -110,43 +110,43 @@ read failed: Input/output error
 
 === Check disconnect before neg1 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect after neg1 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 8 neg1 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 16 neg1 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect before export ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect after export ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 4 export ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 12 export ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 16 export ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect before neg2 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect after neg2 ===
 
@@ -154,11 +154,11 @@ read failed: Input/output error
 
 === Check disconnect 8 neg2 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 10 neg2 ===
 
-qemu-io: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///foo?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect before request ===
 
@@ -195,23 +195,23 @@ read 512/512 bytes at offset 0
 
 === Check disconnect before neg-classic ===
 
-qemu-io: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 8 neg-classic ===
 
-qemu-io: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 16 neg-classic ===
 
-qemu-io: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 24 neg-classic ===
 
-qemu-io: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect 28 neg-classic ===
 
-qemu-io: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
+qemu-io: error: can't open device nbd+unix:///?socket=SOCK_DIR/nbd.sock
 
 === Check disconnect after neg-classic ===
 
diff --git a/tests/qemu-iotests/098.out b/tests/qemu-iotests/098.out
index 7634d0e8b0..d22713052d 100644
--- a/tests/qemu-iotests/098.out
+++ b/tests/qemu-iotests/098.out
@@ -6,7 +6,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 No errors were found on the image.
 
 === empty_image_prepare ===
@@ -15,7 +15,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 Leaked cluster 4 refcount=1 reference=0
 Leaked cluster 5 refcount=1 reference=0
 Repairing cluster 4 refcount=1 reference=0
@@ -28,7 +28,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 ERROR cluster 0 refcount=0 reference=1
 ERROR cluster 1 refcount=0 reference=1
 ERROR cluster 3 refcount=0 reference=1
@@ -42,7 +42,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
+qemu-img: error: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 ERROR cluster 0 refcount=0 reference=1
 ERROR cluster 1 refcount=0 reference=1
 ERROR cluster 3 refcount=0 reference=1
diff --git a/tests/qemu-iotests/103.out b/tests/qemu-iotests/103.out
index 16704cf499..983212f9cf 100644
--- a/tests/qemu-iotests/103.out
+++ b/tests/qemu-iotests/103.out
@@ -5,13 +5,13 @@ wrote 65536/65536 bytes at offset 0
 
 === Testing invalid option combinations ===
 
-qemu-io: can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
-qemu-io: can't open device TEST_DIR/t.IMGFMT: l2-cache-size may not exceed cache-size
-qemu-io: can't open device TEST_DIR/t.IMGFMT: refcount-cache-size may not exceed cache-size
-qemu-io: can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
-qemu-io: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
-qemu-io: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
-qemu-io: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: l2-cache-size may not exceed cache-size
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: refcount-cache-size may not exceed cache-size
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
+qemu-io: error: can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
 
 === Testing valid option combinations ===
 
diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out
index c459957660..3c1fbcbb70 100644
--- a/tests/qemu-iotests/106.out
+++ b/tests/qemu-iotests/106.out
@@ -40,10 +40,10 @@ Image resized.
 === Testing image shrinking ===
 
 --- growth_mode=falloc ---
-qemu-img: Preallocation can only be used for growing images
+qemu-img: error: Preallocation can only be used for growing images
 
 --- growth_mode=full ---
-qemu-img: Preallocation can only be used for growing images
+qemu-img: error: Preallocation can only be used for growing images
 
 --- growth_mode=off ---
 Image resized.
diff --git a/tests/qemu-iotests/111.out b/tests/qemu-iotests/111.out
index 5279c462fc..fc13d8a635 100644
--- a/tests/qemu-iotests/111.out
+++ b/tests/qemu-iotests/111.out
@@ -1,4 +1,4 @@
 QA output created by 111
-qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory
+qemu-img: error: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory
 Could not open backing image to determine size.
 *** done
diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out
index ae0318cabe..ff5c3e8cfb 100644
--- a/tests/qemu-iotests/112.out
+++ b/tests/qemu-iotests/112.out
@@ -2,13 +2,13 @@ QA output created by 112
 
 === refcount_bits limits ===
 
-qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
+qemu-img: error: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
+qemu-img: error: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 refcount_bits=-1
-qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
+qemu-img: error: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
+qemu-img: error: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 1
@@ -21,9 +21,9 @@ refcount bits: 16
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 16
-qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
+qemu-img: error: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
+qemu-img: error: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 
 === Snapshot limit on refcount_bits=1 ===
@@ -32,7 +32,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 1
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not create snapshot 'foo': -22 (Invalid argument)
+qemu-img: error: Could not create snapshot 'foo': -22 (Invalid argument)
 Leaked cluster 6 refcount=1 reference=0
 
 1 leaked clusters were found on the image.
@@ -44,7 +44,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 2
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not create snapshot 'baz': -22 (Invalid argument)
+qemu-img: error: Could not create snapshot 'baz': -22 (Invalid argument)
 Leaked cluster 7 refcount=1 reference=0
 
 1 leaked clusters were found on the image.
@@ -75,7 +75,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 64
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Could not create snapshot 'foo': -22 (Invalid argument)
+qemu-img: error: Could not create snapshot 'foo': -22 (Invalid argument)
 Leaked cluster 5 refcount=18446744073709551615 reference=1
 Leaked cluster 6 refcount=1 reference=0
 
@@ -98,19 +98,19 @@ refcount bits: 64
 
 === Amend to compat=0.10 ===
 
-qemu-img: compat=0.10 requires refcount_bits=16
+qemu-img: error: compat=0.10 requires refcount_bits=16
 refcount bits: 64
 No errors were found on the image.
 refcount bits: 16
 refcount bits: 16
-qemu-img: Refcount widths other than 16 bits require compatibility level 1.1 or above (use compat=1.1 or greater)
+qemu-img: error: Refcount widths other than 16 bits require compatibility level 1.1 or above (use compat=1.1 or greater)
 refcount bits: 16
 
 === Amend with snapshot ===
 
 wrote 16777216/16777216 bytes at offset 0
 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Cannot decrease refcount entry width to 1 bits: Cluster at offset 0x50000 has a refcount of 2
+qemu-img: error: Cannot decrease refcount entry width to 1 bits: Cluster at offset 0x50000 has a refcount of 2
 No errors were found on the image.
 refcount bits: 16
 No errors were found on the image.
diff --git a/tests/qemu-iotests/113.out b/tests/qemu-iotests/113.out
index 3557e2bbf0..4d3386fa49 100644
--- a/tests/qemu-iotests/113.out
+++ b/tests/qemu-iotests/113.out
@@ -2,15 +2,15 @@ QA output created by 113
 
 === Unsupported image creation in qemu-img create ===
 
-qemu-img: nbd://example.com: Format driver 'bochs' does not support image creation
+qemu-img: error: nbd://example.com: Format driver 'bochs' does not support image creation
 
 === Unsupported image creation in qemu-img convert ===
 
-qemu-img: Format driver 'bochs' does not support image creation
+qemu-img: error: Format driver 'bochs' does not support image creation
 
 === Unsupported format in qemu-img amend ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
-qemu-img: Format driver 'IMGFMT' does not support option amendment
+qemu-img: error: Format driver 'IMGFMT' does not support option amendment
 
 *** done
diff --git a/tests/qemu-iotests/114.out b/tests/qemu-iotests/114.out
index 67adef37a4..4960bb52cf 100644
--- a/tests/qemu-iotests/114.out
+++ b/tests/qemu-iotests/114.out
@@ -7,7 +7,7 @@ virtual size: 64 MiB (67108864 bytes)
 cluster_size: 65536
 backing file: TEST_DIR/t.IMGFMT.base
 backing file format: foo
-qemu-io: can't open device TEST_DIR/t.qcow2: Could not open backing file: Unknown driver 'foo'
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Could not open backing file: Unknown driver 'foo'
 no file open, try 'help open'
 read 4096/4096 bytes at offset 0
 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out
index 849b6cc2ef..ce69c388f4 100644
--- a/tests/qemu-iotests/122.out
+++ b/tests/qemu-iotests/122.out
@@ -79,8 +79,8 @@ read 65536/65536 bytes at offset 4194304
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 65536/65536 bytes at offset 8388608
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images
-qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images
+qemu-img: error: Having a backing file for the target makes no sense when concatenating multiple input images
+qemu-img: error: Having a backing file for the target makes no sense when concatenating multiple input images
 
 === Compression with misaligned allocations and image sizes ===
 
diff --git a/tests/qemu-iotests/133.out b/tests/qemu-iotests/133.out
index 1491ef45a9..076ce0e6b1 100644
--- a/tests/qemu-iotests/133.out
+++ b/tests/qemu-iotests/133.out
@@ -4,18 +4,18 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t
 
 === Check that node-name can't be changed ===
 
-qemu-io: Cannot change the option 'node-name'
-qemu-io: Cannot change the option 'node-name'
-qemu-io: Cannot change the option 'node-name'
+qemu-io: error: Cannot change the option 'node-name'
+qemu-io: error: Cannot change the option 'node-name'
+qemu-io: error: Cannot change the option 'node-name'
 
 === Check that unchanged node-name is okay ===
 
 
 === Check that driver can't be changed ===
 
-qemu-io: Cannot change the option 'driver'
-qemu-io: Cannot change the option 'driver'
-qemu-io: Cannot change the option 'driver'
+qemu-io: error: Cannot change the option 'driver'
+qemu-io: error: Cannot change the option 'driver'
+qemu-io: error: Cannot change the option 'driver'
 
 === Check that unchanged driver is okay ===
 
@@ -27,16 +27,16 @@ format name: null-co
 
 === Check that mixing -c/-r/-w and their corresponding options is forbidden ===
 
-qemu-io: Cannot set both -r/-w and 'read-only'
-qemu-io: Cannot set both -r/-w and 'read-only'
-qemu-io: Cannot set both -c and the cache options
-qemu-io: Cannot set both -c and the cache options
-qemu-io: Cannot set both -c and the cache options
+qemu-io: error: Cannot set both -r/-w and 'read-only'
+qemu-io: error: Cannot set both -r/-w and 'read-only'
+qemu-io: error: Cannot set both -c and the cache options
+qemu-io: error: Cannot set both -c and the cache options
+qemu-io: error: Cannot set both -c and the cache options
 
 === Check that invalid options are handled correctly ===
 
-qemu-io: Parameter 'read-only' expects 'on' or 'off'
-qemu-io: Parameter 'cache.no-flush' expects 'on' or 'off'
-qemu-io: Parameter 'cache.direct' expects 'on' or 'off'
-qemu-io: Parameter 'auto-read-only' expects 'on' or 'off'
+qemu-io: error: Parameter 'read-only' expects 'on' or 'off'
+qemu-io: error: Parameter 'cache.no-flush' expects 'on' or 'off'
+qemu-io: error: Parameter 'cache.direct' expects 'on' or 'off'
+qemu-io: error: Parameter 'auto-read-only' expects 'on' or 'off'
 *** done
diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out
index 86377c80cd..e88776f57d 100644
--- a/tests/qemu-iotests/137.out
+++ b/tests/qemu-iotests/137.out
@@ -15,30 +15,30 @@ read 33554432/33554432 bytes at offset 0
 
 === Try setting some invalid values ===
 
-qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'
-qemu-io: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
-qemu-io: l2-cache-size may not exceed cache-size
-qemu-io: refcount-cache-size may not exceed cache-size
-qemu-io: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
-qemu-io: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
-qemu-io: Refcount cache size too big
-qemu-io: Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all')
-qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
-qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
-qemu-io: Cache clean interval too big
+qemu-io: error: Parameter 'lazy-refcounts' expects 'on' or 'off'
+qemu-io: error: cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
+qemu-io: error: l2-cache-size may not exceed cache-size
+qemu-io: error: refcount-cache-size may not exceed cache-size
+qemu-io: error: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
+qemu-io: error: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
+qemu-io: error: Refcount cache size too big
+qemu-io: error: Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all')
+qemu-io: error: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
+qemu-io: error: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
+qemu-io: error: Cache clean interval too big
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=36028797018963968
-qemu-io: L2 cache size too big
+qemu-io: error: L2 cache size too big
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 
 === Test transaction semantics ===
 
-qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
+qemu-io: error: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 ./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 OK: Dirty bit not set
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'
+qemu-io: error: Parameter 'lazy-refcounts' expects 'on' or 'off'
 qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed
 write failed: Input/output error
 *** done
diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out
index 86b985da75..24cb816f24 100644
--- a/tests/qemu-iotests/140.out
+++ b/tests/qemu-iotests/140.out
@@ -12,7 +12,7 @@ read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 { 'execute': 'eject', 'arguments': { 'device': 'drv' }}
 {"return": {}}
-qemu-io: can't open device nbd+unix:///drv?socket=SOCK_DIR/nbd: Requested export not available
+qemu-io: error: can't open device nbd+unix:///drv?socket=SOCK_DIR/nbd: Requested export not available
 server reported: export 'drv' not present
 { 'execute': 'quit' }
 {"return": {}}
diff --git a/tests/qemu-iotests/142.out b/tests/qemu-iotests/142.out
index 3667e38def..a63c49044b 100644
--- a/tests/qemu-iotests/142.out
+++ b/tests/qemu-iotests/142.out
@@ -26,7 +26,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) quit
 
 Testing: -drive file=TEST_DIR/t.qcow2,cache=invalid_value
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value: invalid cache option
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value: error: invalid cache option
 
 
 === Check inheritance of cache modes ===
@@ -71,13 +71,13 @@ cache.writeback=off on none0
     Cache mode:       writeback
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
@@ -147,13 +147,13 @@ cache.writeback=off on none0
     Cache mode:       writeback
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
@@ -223,13 +223,13 @@ cache.writeback=off on none0
     Cache mode:       writeback, direct
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
@@ -299,13 +299,13 @@ cache.writeback=off on none0
     Cache mode:       writeback, direct
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
@@ -375,13 +375,13 @@ cache.writeback=off on none0
     Cache mode:       writeback
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
@@ -704,13 +704,13 @@ cache.writeback=off on none0
     Cache mode:       writeback, direct
 
 cache.writeback=off on file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: error: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 cache.writeback=off on backing
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: error: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
 
 cache.writeback=off on backing-file
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: error: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
 
 
 cache.no-flush=on on none0
diff --git a/tests/qemu-iotests/143.out b/tests/qemu-iotests/143.out
index 1f4001c601..8db19060f6 100644
--- a/tests/qemu-iotests/143.out
+++ b/tests/qemu-iotests/143.out
@@ -3,7 +3,7 @@ QA output created by 143
 {"return": {}}
 { 'execute': 'nbd-server-start', 'arguments': { 'addr': { 'type': 'unix', 'data': { 'path': 'SOCK_DIR/nbd' }}}}
 {"return": {}}
-qemu-io: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available
+qemu-io: error: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available
 server reported: export 'no_such_export' not present
 { 'execute': 'quit' }
 {"return": {}}
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index f7464dd8d3..99e7659899 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -1,6 +1,6 @@
 QA output created by 153
 == readonly=off,force-share=on should be rejected ==
-QEMU_PROG: -drive if=none,file=null-co://,readonly=off,force-share=on: force-share=on can only be used with read-only images
+QEMU_PROG: -drive if=none,file=null-co://,readonly=off,force-share=on: error: force-share=on can only be used with read-only images
 
 == Creating base image ==
 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=33554432
@@ -11,11 +11,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
 == Launching QEMU, opts: '' ==
 
 == Launching another QEMU, opts: '' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: Failed to get shared "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: error: Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on,force-share=on' ==
@@ -23,89 +23,89 @@ Is another process using the image [TEST_DIR/t.qcow2]?
 == Running utility commands  ==
 
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
 _qemu_io_wrapper -c open -r  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
 _qemu_img_wrapper info TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper check TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper map TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper amend -o  TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 count=1
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-img: error: TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 file format: IMGFMT
 
 == Running utility commands -U ==
 
 _qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 
 _qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2
 
 _qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 no file open, try 'help open'
 
 _qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512
@@ -119,19 +119,19 @@ _qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
 _qemu_img_wrapper map -U TEST_DIR/t.qcow2
 
 _qemu_img_wrapper amend -o  -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
@@ -143,7 +143,7 @@ _qemu_img_wrapper dd -U if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 c
 _qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2
 
 _qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
 { 'execute': 'quit' }
 
 Round done
@@ -157,7 +157,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
 == Launching QEMU, opts: 'read-only=on' ==
 
 == Launching another QEMU, opts: '' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on' ==
@@ -167,13 +167,13 @@ Is another process using the image [TEST_DIR/t.qcow2]?
 == Running utility commands  ==
 
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
 
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
@@ -188,19 +188,19 @@ _qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
 _qemu_img_wrapper map TEST_DIR/t.qcow2
 
 _qemu_img_wrapper amend -o  TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
@@ -212,23 +212,23 @@ _qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 coun
 _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
 
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-img: error: TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 file format: IMGFMT
 
 == Running utility commands -U ==
 
 _qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 
 _qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2
 
 _qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 no file open, try 'help open'
 
 _qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512
@@ -242,19 +242,19 @@ _qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
 _qemu_img_wrapper map -U TEST_DIR/t.qcow2
 
 _qemu_img_wrapper amend -o  -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
@@ -266,7 +266,7 @@ _qemu_img_wrapper dd -U if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 c
 _qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2
 
 _qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
 { 'execute': 'quit' }
 
 Round done
@@ -327,12 +327,12 @@ file format: IMGFMT
 == Running utility commands -U ==
 
 _qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 
 _qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2
 
 _qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
+qemu-io: error: can't open device TEST_DIR/t.qcow2: force-share=on can only be used with read-only images
 no file open, try 'help open'
 
 _qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512
@@ -346,15 +346,15 @@ _qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
 _qemu_img_wrapper map -U TEST_DIR/t.qcow2
 
 _qemu_img_wrapper amend -o  -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
-qemu-img: unrecognized option '-U'
+qemu-img: error: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
@@ -368,23 +368,23 @@ _qemu_img_wrapper dd -U if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 c
 _qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2
 
 _qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
+qemu-img: error: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used with read-only images
 { 'execute': 'quit' }
 
 Round done
 
 == Two devices with the same image (read-only=off - read-only=off) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=off - read-only=on) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: Failed to get shared "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: error: Failed to get shared "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=off - read-only=on,force-share=on) ==
 
 == Two devices with the same image (read-only=on - read-only=off) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=on - read-only=on) ==
@@ -405,13 +405,13 @@ Formatting 'TEST_DIR/t.IMGFMT.c', fmt=IMGFMT size=33554432 backing_file=TEST_DIR
 == Two devices sharing the same file in backing chain ==
 
 == Backing image also as an active device ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Backing image also as an active device (ro) ==
 
 == Symbolic link ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Active commit to intermediate layer should work when base in use ==
@@ -426,7 +426,7 @@ Adding drive
 {"return": "OKrn"}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 Creating overlay with qemu-img when the guest is running should be allowed
 
@@ -447,7 +447,7 @@ _qemu_img_wrapper info TEST_DIR/t.qcow2
 {"return": ""}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 Closing the other
 { 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_del d1' } }
@@ -464,10 +464,10 @@ virtual size: 1 GiB (1073741824 bytes)
 disk size: unavailable
 
 Conflict:
-qemu-img: --force-share/-U conflicts with image options
+qemu-img: error: --force-share/-U conflicts with image options
 
 No conflict:
 
 Conflict:
-qemu-io: -U conflicts with image options
+qemu-io: error: -U conflicts with image options
 *** done
diff --git a/tests/qemu-iotests/162.out b/tests/qemu-iotests/162.out
index 5a00d36d17..dc73df631c 100644
--- a/tests/qemu-iotests/162.out
+++ b/tests/qemu-iotests/162.out
@@ -1,15 +1,15 @@
 QA output created by 162
 
 === NBD ===
-qemu-img: Could not open 'json:{"driver": "nbd", "host": -1}': address resolution failed for -1:10809: Name or service not known
+qemu-img: error: Could not open 'json:{"driver": "nbd", "host": -1}': address resolution failed for -1:10809: Name or service not known
 image: nbd://localhost:PORT
 image: nbd+unix://?socket=42
 
 === SSH ===
-qemu-img: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}': Failed to connect socket: Connection refused
-qemu-img: Could not open 'driver=ssh,host=localhost,port=0,path=/foo': Failed to connect socket: Connection refused
-qemu-img: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}': Parameter 'port' expects a number
-qemu-img: Could not open 'driver=ssh,host=localhost,port=0.42,path=/foo': Parameter 'port' expects a number
+qemu-img: error: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}': Failed to connect socket: Connection refused
+qemu-img: error: Could not open 'driver=ssh,host=localhost,port=0,path=/foo': Failed to connect socket: Connection refused
+qemu-img: error: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}': Parameter 'port' expects a number
+qemu-img: error: Could not open 'driver=ssh,host=localhost,port=0.42,path=/foo': Parameter 'port' expects a number
 
 === blkdebug ===
 image: blkdebug:42:null-co://
diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out
index 7abbe82427..6d07b96028 100644
--- a/tests/qemu-iotests/172.out
+++ b/tests/qemu-iotests/172.out
@@ -724,10 +724,10 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
                 drive-type = "144"
 
 Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=0
-QEMU_PROG: -device floppy,drive=none0,unit=0: Floppy unit 0 is in use
+QEMU_PROG: -device floppy,drive=none0,unit=0: error: Floppy unit 0 is in use
 
 Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=1
-QEMU_PROG: -device floppy,drive=none0,unit=1: Floppy unit 1 is in use
+QEMU_PROG: -device floppy,drive=none0,unit=1: error: Floppy unit 1 is in use
 
 
 === Mixing -drive and -device ===
@@ -809,7 +809,7 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
                 drive-type = "144"
 
 Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=0
-QEMU_PROG: -device floppy,drive=none0,unit=0: Floppy unit 0 is in use
+QEMU_PROG: -device floppy,drive=none0,unit=0: error: Floppy unit 0 is in use
 
 
 === Mixing -global and -device ===
@@ -967,16 +967,16 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
                 drive-type = "144"
 
 Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
-QEMU_PROG: -device floppy,drive=none1,unit=0: Floppy unit 0 is in use
+QEMU_PROG: -device floppy,drive=none1,unit=0: error: Floppy unit 0 is in use
 
 Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
-QEMU_PROG: -device floppy,drive=none1,unit=1: Floppy unit 1 is in use
+QEMU_PROG: -device floppy,drive=none1,unit=1: error: Floppy unit 1 is in use
 
 
 === Too many floppy drives ===
 
 Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -drive if=none,file=TEST_DIR/t.qcow2.3 -global isa-fdc.driveB=none0 -device floppy,drive=none1
-QEMU_PROG: -device floppy,drive=none1: Can't create floppy unit 2, bus supports only 2 units
+QEMU_PROG: -device floppy,drive=none1: error: Can't create floppy unit 2, bus supports only 2 units
 
 
 === Creating an empty drive with anonymous BB ===
@@ -1204,10 +1204,10 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica
                 drive-type = "144"
 
 Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical_block_size=4096
-QEMU_PROG: -device floppy,drive=none0,logical_block_size=4096: Physical and logical block size must be 512 for floppy
+QEMU_PROG: -device floppy,drive=none0,logical_block_size=4096: error: Physical and logical block size must be 512 for floppy
 
 Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physical_block_size=1024
-QEMU_PROG: -device floppy,drive=none0,physical_block_size=1024: Physical and logical block size must be 512 for floppy
+QEMU_PROG: -device floppy,drive=none0,physical_block_size=1024: error: Physical and logical block size must be 512 for floppy
 
 
 === Writethrough caching ===
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
index 9e7d8c44df..1131c41853 100644
--- a/tests/qemu-iotests/178.out.qcow2
+++ b/tests/qemu-iotests/178.out.qcow2
@@ -2,19 +2,19 @@ QA output created by 178
 == Input validation ==
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
-qemu-img: Either --size N or one filename must be specified.
-qemu-img: --size N cannot be used together with a filename.
-qemu-img: At most one filename argument is allowed.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: Invalid option list: ,
-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: Unknown file format 'foo'
+qemu-img: error: Either --size N or one filename must be specified.
+qemu-img: error: --size N cannot be used together with a filename.
+qemu-img: error: At most one filename argument is allowed.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: Invalid option list: ,
+qemu-img: error: Invalid parameter 'snapshot.foo'
+qemu-img: error: Failed in parsing snapshot param 'snapshot.foo'
+qemu-img: error: --output must be used with human or json as argument.
+qemu-img: error: Image size must be less than 8 EiB!
+qemu-img: error: Unknown file format 'foo'
 
 == Size calculation for a new file (human) ==
 
@@ -30,7 +30,7 @@ required size: 168034304
 fully allocated size: 1099679662080
 required size: 343650009088
 fully allocated size: 2252143463694336
-qemu-img: The image size is too large (try using a larger cluster size)
+qemu-img: error: The image size is too large (try using a larger cluster size)
 
 == Empty qcow2 input image (human) ==
 
@@ -167,7 +167,7 @@ converted image file size in bytes: 8716288
     "required": 343650009088,
     "fully-allocated": 2252143463694336
 }
-qemu-img: The image size is too large (try using a larger cluster size)
+qemu-img: error: The image size is too large (try using a larger cluster size)
 
 == Empty qcow2 input image (json) ==
 
diff --git a/tests/qemu-iotests/178.out.raw b/tests/qemu-iotests/178.out.raw
index 6478365905..bfda347e59 100644
--- a/tests/qemu-iotests/178.out.raw
+++ b/tests/qemu-iotests/178.out.raw
@@ -2,19 +2,19 @@ QA output created by 178
 == Input validation ==
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
-qemu-img: Either --size N or one filename must be specified.
-qemu-img: --size N cannot be used together with a filename.
-qemu-img: At most one filename argument is allowed.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: --object, --image-opts, -f, and -l require a filename argument.
-qemu-img: Invalid option list: ,
-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: Unknown file format 'foo'
+qemu-img: error: Either --size N or one filename must be specified.
+qemu-img: error: --size N cannot be used together with a filename.
+qemu-img: error: At most one filename argument is allowed.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: --object, --image-opts, -f, and -l require a filename argument.
+qemu-img: error: Invalid option list: ,
+qemu-img: error: Invalid parameter 'snapshot.foo'
+qemu-img: error: Failed in parsing snapshot param 'snapshot.foo'
+qemu-img: error: --output must be used with human or json as argument.
+qemu-img: error: Image size must be less than 8 EiB!
+qemu-img: error: Unknown file format 'foo'
 
 == Size calculation for a new file (human) ==
 
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
index a8eea166c3..0b3d4b524f 100644
--- a/tests/qemu-iotests/182.out
+++ b/tests/qemu-iotests/182.out
@@ -3,7 +3,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432
 Starting QEMU
 
 Starting a second QEMU using the same image should fail
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: error: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 === Testing reopen ===
diff --git a/tests/qemu-iotests/187.out b/tests/qemu-iotests/187.out
index 86203d8abc..17beda25d0 100644
--- a/tests/qemu-iotests/187.out
+++ b/tests/qemu-iotests/187.out
@@ -3,16 +3,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 
 Start from read-only
 
-qemu-io: Block node is read-only
+qemu-io: error: Block node is read-only
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: Block node is read-only
+qemu-io: error: Block node is read-only
 
 Start from read-write
 
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: Block node is read-only
+qemu-io: error: Block node is read-only
 wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *** done
diff --git a/tests/qemu-iotests/188.out b/tests/qemu-iotests/188.out
index c568ef3701..44cff331f0 100644
--- a/tests/qemu-iotests/188.out
+++ b/tests/qemu-iotests/188.out
@@ -14,7 +14,7 @@ read 16777216/16777216 bytes at offset 0
 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == verify open failure with wrong password ==
-qemu-io: can't open: Invalid password, cannot unlock any keyslot
+qemu-io: error: can't open: Invalid password, cannot unlock any keyslot
 
 == verify that has_zero_init returns false when preallocating ==
 Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=16777216
diff --git a/tests/qemu-iotests/197.out b/tests/qemu-iotests/197.out
index 7ca46be6e4..411c14e2db 100644
--- a/tests/qemu-iotests/197.out
+++ b/tests/qemu-iotests/197.out
@@ -16,7 +16,7 @@ read 2147483136/2147483136 bytes at offset 1024
 2 GiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 1024/1024 bytes at offset 3221226496
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: can't open device TEST_DIR/t.wrap.qcow2: Can't use copy-on-read on read-only device
+qemu-io: error: can't open device TEST_DIR/t.wrap.qcow2: Can't use copy-on-read on read-only device
 2 GiB (0x80010000) bytes     allocated at offset 0 bytes (0x0)
 1023.938 MiB (0x3fff0000) bytes not allocated at offset 2 GiB (0x80010000)
 64 KiB (0x10000) bytes     allocated at offset 3 GiB (0xc0000000)
diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205
index 4bb2c21e8b..9e80fc7d15 100755
--- a/tests/qemu-iotests/205
+++ b/tests/qemu-iotests/205
@@ -78,7 +78,7 @@ class TestNbdServerRemove(iotests.QMPTestCase):
 
     def assertConnectFailed(self, qemu_io_output):
         self.assertEqual(filter_qemu_io(qemu_io_output).strip(),
-                         "qemu-io: can't open device " + nbd_uri +
+                         "qemu-io: error: can't open device " + nbd_uri +
                          ": Requested export not available\n"
                          "server reported: export 'exp' not present")
 
diff --git a/tests/qemu-iotests/215.out b/tests/qemu-iotests/215.out
index 5a2fe40d03..9917f48205 100644
--- a/tests/qemu-iotests/215.out
+++ b/tests/qemu-iotests/215.out
@@ -16,7 +16,7 @@ read 2147483136/2147483136 bytes at offset 1024
 2 GiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 1024/1024 bytes at offset 3221226496
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: can't open device TEST_DIR/t.wrap.qcow2: Block node is read-only
+qemu-io: error: can't open device TEST_DIR/t.wrap.qcow2: Block node is read-only
 2 GiB (0x80010000) bytes     allocated at offset 0 bytes (0x0)
 1023.938 MiB (0x3fff0000) bytes not allocated at offset 2 GiB (0x80010000)
 64 KiB (0x10000) bytes     allocated at offset 3 GiB (0xc0000000)
diff --git a/tests/qemu-iotests/217.out b/tests/qemu-iotests/217.out
index e3fc40a8c7..702c6d825b 100644
--- a/tests/qemu-iotests/217.out
+++ b/tests/qemu-iotests/217.out
@@ -10,7 +10,7 @@ Snapshot list:
 (Snapshot filtered)
 
 qcow2_free_clusters failed: Input/output error
-qemu-img: Could not delete snapshot 'foo': Failed to free the cluster and L1 table: Input/output error
+qemu-img: error: Could not delete snapshot 'foo': Failed to free the cluster and L1 table: Input/output error
 
 --- Checking test image ---
 Leaked cluster 4 refcount=2 reference=1
diff --git a/tests/qemu-iotests/226.out b/tests/qemu-iotests/226.out
index 42be973ff2..5b06a97430 100644
--- a/tests/qemu-iotests/226.out
+++ b/tests/qemu-iotests/226.out
@@ -3,24 +3,24 @@ QA output created by 226
 === Testing with driver:file ===
 
 == Testing RO ==
-qemu-io: can't open: A regular file was expected by the 'file' driver, but something else was given
+qemu-io: error: can't open: A regular file was expected by the 'file' driver, but something else was given
 qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
 == Testing RW ==
-qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
+qemu-io: error: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
 qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
 
 === Testing with driver:host_device ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_device' driver expects either a character or block device
+qemu-io: error: can't open: 'host_device' driver expects either a character or block device
 == Testing RW ==
-qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
+qemu-io: error: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
 
 === Testing with driver:host_cdrom ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_cdrom' driver expects either a character or block device
+qemu-io: error: can't open: 'host_cdrom' driver expects either a character or block device
 == Testing RW ==
-qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
+qemu-io: error: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
 
 *** done
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
index 3bd1a920af..b338f2239c 100644
--- a/tests/qemu-iotests/232.out
+++ b/tests/qemu-iotests/232.out
@@ -21,11 +21,11 @@ NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
 NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
 NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
 
-QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 NODE_NAME: TEST_DIR/t.IMGFMT (file)
 NODE_NAME: TEST_DIR/t.IMGFMT (file)
 
-QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 NODE_NAME: TEST_DIR/t.IMGFMT (file)
 NODE_NAME: TEST_DIR/t.IMGFMT (file)
 
@@ -49,11 +49,11 @@ node0: TEST_DIR/t.IMGFMT (file, read-only)
 node0: TEST_DIR/t.IMGFMT (file, read-only)
 node0: TEST_DIR/t.IMGFMT (file, read-only)
 
-QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 node0: TEST_DIR/t.IMGFMT (file)
-QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 
-QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 node0: TEST_DIR/t.IMGFMT (file)
-QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: error: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
 *** done
diff --git a/tests/qemu-iotests/233.out b/tests/qemu-iotests/233.out
index c3c344811b..df7e588b36 100644
--- a/tests/qemu-iotests/233.out
+++ b/tests/qemu-iotests/233.out
@@ -14,16 +14,16 @@ wrote 1048576/1048576 bytes at offset 1048576
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == check TLS client to plain server fails ==
-qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Denied by server for option 5 (starttls)
+qemu-img: error: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Denied by server for option 5 (starttls)
 server reported: TLS not configured
-qemu-nbd: Denied by server for option 5 (starttls)
+qemu-nbd: error: Denied by server for option 5 (starttls)
 server reported: TLS not configured
 
 == check plain client to TLS server fails ==
-qemu-img: Could not open 'nbd://localhost:PORT': TLS negotiation required before option 7 (go)
+qemu-img: error: Could not open 'nbd://localhost:PORT': TLS negotiation required before option 7 (go)
 Did you forget a valid tls-creds?
 server reported: Option 0x7 not permitted before TLS
-qemu-nbd: TLS negotiation required before option 3 (list)
+qemu-nbd: error: TLS negotiation required before option 3 (list)
 Did you forget a valid tls-creds?
 server reported: Option 0x3 not permitted before TLS
 
@@ -47,8 +47,8 @@ exports available: 1
    base:allocation
 
 == check TLS with different CA fails ==
-qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': The certificate hasn't got a known issuer
-qemu-nbd: The certificate hasn't got a known issuer
+qemu-img: error: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': The certificate hasn't got a known issuer
+qemu-nbd: error: The certificate hasn't got a known issuer
 
 == perform I/O over TLS ==
 read 1048576/1048576 bytes at offset 1048576
@@ -59,12 +59,12 @@ read 1048576/1048576 bytes at offset 1048576
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == check TLS with authorization ==
-qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort
-qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort
+qemu-img: error: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort
+qemu-img: error: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort
 
 == final server log ==
-qemu-nbd: option negotiation failed: Verify failed: No certificate was found.
-qemu-nbd: option negotiation failed: Verify failed: No certificate was found.
-qemu-nbd: option negotiation failed: TLS x509 authz check for CN=localhost,O=Cthulhu Dark Lord Enterprises client1,L=R'lyeh,C=South Pacific is denied
-qemu-nbd: option negotiation failed: TLS x509 authz check for CN=localhost,O=Cthulhu Dark Lord Enterprises client3,L=R'lyeh,C=South Pacific is denied
+qemu-nbd: error: option negotiation failed: Verify failed: No certificate was found.
+qemu-nbd: error: option negotiation failed: Verify failed: No certificate was found.
+qemu-nbd: error: option negotiation failed: TLS x509 authz check for CN=localhost,O=Cthulhu Dark Lord Enterprises client1,L=R'lyeh,C=South Pacific is denied
+qemu-nbd: error: option negotiation failed: TLS x509 authz check for CN=localhost,O=Cthulhu Dark Lord Enterprises client3,L=R'lyeh,C=South Pacific is denied
 *** done
diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out
index 7ac8404d11..fe729faa3e 100644
--- a/tests/qemu-iotests/242.out
+++ b/tests/qemu-iotests/242.out
@@ -143,7 +143,7 @@ Test 5
 {"execute": "block-dirty-bitmap-add", "arguments": {"disabled": false, "granularity": 16384, "name": "bitmap-0", "node": "drive0", "persistent": true}}
 {"return": {}}
 Write an unknown bitmap flag '0x4' into a new QCOW2 image at offset 327695
-qemu-img: Could not open 'TEST_IMG': Bitmap 'bitmap-0' doesn't satisfy the constraints
+qemu-img: error: Could not open 'TEST_IMG': Bitmap 'bitmap-0' doesn't satisfy the constraints
 
 Unset the unknown bitmap flag '0x4' in the bitmap directory entry:
 
diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out
index 6a3d0067cc..6e8b9a9a2b 100644
--- a/tests/qemu-iotests/244.out
+++ b/tests/qemu-iotests/244.out
@@ -9,22 +9,22 @@ read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
 no file open, try 'help open'
 
 Data file required, but without data file name in the image:
-qemu-io: can't open device TEST_DIR/t.qcow2: 'data-file' is required for this image
+qemu-io: error: can't open device TEST_DIR/t.qcow2: 'data-file' is required for this image
 no file open, try 'help open'
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-io: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
 no file open, try 'help open'
 
 Setting data-file for an image with internal data:
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-io: can't open device TEST_DIR/t.qcow2: 'data-file' can only be set for images with an external data file
+qemu-io: error: can't open device TEST_DIR/t.qcow2: 'data-file' can only be set for images with an external data file
 no file open, try 'help open'
-qemu-io: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
+qemu-io: error: can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
 no file open, try 'help open'
 
 === Conflicting features ===
@@ -33,7 +33,7 @@ Convert to compressed target with data file:
 Formatting 'TEST_DIR/t.IMGFMT.src', fmt=IMGFMT size=67108864
 wrote 1048576/1048576 bytes at offset 0
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: error while writing sector 0: Operation not supported
+qemu-img: error: error while writing sector 0: Operation not supported
 
 Convert uncompressed, then write compressed data manually:
 Images are identical.
@@ -41,7 +41,7 @@ write failed: Operation not supported
 No errors were found on the image.
 
 Take an internal snapshot:
-qemu-img: Could not create snapshot 'test': -95 (Operation not supported)
+qemu-img: error: Could not create snapshot 'test': -95 (Operation not supported)
 No errors were found on the image.
 
 === Standalone image with external data file (efficient) ===
diff --git a/tests/qemu-iotests/249.out b/tests/qemu-iotests/249.out
index 51307ed0f7..4ce35e2f6a 100644
--- a/tests/qemu-iotests/249.out
+++ b/tests/qemu-iotests/249.out
@@ -8,7 +8,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.
 === Send a write command to a drive opened in read-only mode (1)
 
 { 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}}
-{"return": "Block node is read-onlyrn"}
+{"return": "error: Block node is read-onlyrn"}
 
 === Run block-commit on base using an invalid filter node name
 
@@ -20,7 +20,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.
 === Send a write command to a drive opened in read-only mode (2)
 
 { 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}}
-{"return": "Block node is read-onlyrn"}
+{"return": "error: Block node is read-onlyrn"}
 
 === Run block-commit on base using the default filter node name
 
@@ -37,5 +37,5 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.
 === Send a write command to a drive opened in read-only mode (3)
 
 { 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}}
-{"return": "Block node is read-onlyrn"}
+{"return": "error: Block node is read-onlyrn"}
 *** done
diff --git a/tests/qemu-iotests/261.out b/tests/qemu-iotests/261.out
index 2600354566..176fee892e 100644
--- a/tests/qemu-iotests/261.out
+++ b/tests/qemu-iotests/261.out
@@ -162,12 +162,12 @@ Snapshots in TEST_DIR/t.IMGFMT:
 
 === Reject too much unknown extra data ===
 
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Too much extra metadata in snapshot table entry 3
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Too much extra metadata in snapshot table entry 3
 You can force-remove this extra metadata with qemu-img check -r all
 
-qemu-img: ERROR failed to read the snapshot table: Too much extra metadata in snapshot table entry 3
+qemu-img: error: ERROR failed to read the snapshot table: Too much extra metadata in snapshot table entry 3
 You can force-remove this extra metadata with qemu-img check -r all
-qemu-img: Check failed: File too large
+qemu-img: error: Check failed: File too large
 
 Discarding too much extra metadata in snapshot table entry 3 (65536 > 1024)
 ERROR cluster 10 refcount=0 reference=1
@@ -185,12 +185,12 @@ No errors were found on the image.
 === Snapshot table too big ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Snapshot table is too big
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Snapshot table is too big
 You can force-remove all 1 overhanging snapshots with qemu-img check -r all
 
-qemu-img: ERROR failed to read the snapshot table: Snapshot table is too big
+qemu-img: error: ERROR failed to read the snapshot table: Snapshot table is too big
 You can force-remove all 1 overhanging snapshots with qemu-img check -r all
-qemu-img: Check failed: File too large
+qemu-img: error: Check failed: File too large
 
 Discarding 1 overhanging snapshots (snapshot table is too big)
 Leaked cluster 14 refcount=1 reference=0
@@ -217,12 +217,12 @@ No errors were found on the image.
 
 Snapshot table size should equal 67108872: 67108872
 
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Too much extra metadata in snapshot table entry 505
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Too much extra metadata in snapshot table entry 505
 You can force-remove this extra metadata with qemu-img check -r all
 
-qemu-img: ERROR failed to read the snapshot table: Too much extra metadata in snapshot table entry 505
+qemu-img: error: ERROR failed to read the snapshot table: Too much extra metadata in snapshot table entry 505
 You can force-remove this extra metadata with qemu-img check -r all
-qemu-img: Check failed: File too large
+qemu-img: error: Check failed: File too large
 
 Discarding too much extra metadata in snapshot table entry 505 (116944 > 1024)
 Discarding 1 overhanging snapshots (snapshot table is too big)
@@ -241,11 +241,11 @@ No errors were found on the image.
 === Too many snapshots ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Snapshot table too large
+qemu-img: error: Could not open 'TEST_DIR/t.IMGFMT': Snapshot table too large
 
-qemu-img: ERROR snapshot table too large
+qemu-img: error: ERROR snapshot table too large
 You can force-remove all 65536 overhanging snapshots with qemu-img check -r all
-qemu-img: Check failed: File too large
+qemu-img: error: Check failed: File too large
 
 Discarding 65536 overhanging snapshots
 Leaked cluster 14 refcount=1 reference=0
diff --git a/tests/qemu-iotests/267.out b/tests/qemu-iotests/267.out
index 8dddb4baa4..7e3f77c259 100644
--- a/tests/qemu-iotests/267.out
+++ b/tests/qemu-iotests/267.out
@@ -6,11 +6,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing:
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) savevm snap0
-Error: No block device can accept snapshots
+error: No block device can accept snapshots
 (qemu) info snapshots
 No available block device supports snapshots
 (qemu) loadvm snap0
-Error: No block device supports snapshots
+error: No block device supports snapshots
 (qemu) quit
 
 
@@ -20,11 +20,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) savevm snap0
-Error: Device 'none0' is writable but does not support snapshots
+error: Device 'none0' is writable but does not support snapshots
 (qemu) info snapshots
 No available block device supports snapshots
 (qemu) loadvm snap0
-Error: Device 'none0' is writable but does not support snapshots
+error: Device 'none0' is writable but does not support snapshots
 (qemu) quit
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
@@ -56,11 +56,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=virtio
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) savevm snap0
-Error: Device 'virtio0' is writable but does not support snapshots
+error: Device 'virtio0' is writable but does not support snapshots
 (qemu) info snapshots
 No available block device supports snapshots
 (qemu) loadvm snap0
-Error: Device 'virtio0' is writable but does not support snapshots
+error: Device 'virtio0' is writable but does not support snapshots
 (qemu) quit
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
@@ -81,11 +81,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) savevm snap0
-Error: Device '' is writable but does not support snapshots
+error: Device '' is writable but does not support snapshots
 (qemu) info snapshots
 No available block device supports snapshots
 (qemu) loadvm snap0
-Error: Device '' is writable but does not support snapshots
+error: Device '' is writable but does not support snapshots
 (qemu) quit
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 3f8ee3e5f7..0f19eeeeca 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -58,7 +58,7 @@ _filter_imgfmt()
 _filter_qemu_img_check()
 {
     $SED -e '/allocated.*fragmented.*compressed clusters/d' \
-        -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
+        -e 's/qemu-img: error: This image format does not support checks/No errors were found on the image./' \
         -e '/Image end offset: [0-9]\+/d'
 }
 
diff --git a/util/qemu-error.c b/util/qemu-error.c
index dac7c7dc50..03ab07341c 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -217,6 +217,7 @@ static void vreport(report_type type, const char *fmt, va_list ap)
 
     switch (type) {
     case REPORT_TYPE_ERROR:
+        error_printf("error: ");
         break;
     case REPORT_TYPE_WARNING:
         error_printf("warning: ");
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (11 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 12/13] add 'error' prefix to vreport Maxim Levitsky
@ 2020-01-27 10:36 ` Maxim Levitsky
  2020-01-28 19:31   ` Maxim Levitsky
  2020-01-27 10:55 ` [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups no-reply
  2020-01-27 19:39 ` John Snow
  14 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

This way they all will be prefixed with 'Error:' which some parsers
(e.g libvirt) need

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719169

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c | 35 ++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 7bbe4e3814..5b060d380d 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -84,7 +84,6 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
     mc = MACHINE_GET_CLASS(current_machine);
     dinfo = drive_new(opts, mc->block_default_type, &err);
     if (err) {
-        error_report_err(err);
         qemu_opts_del(opts);
         goto err;
     }
@@ -98,7 +97,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "OK\n");
         break;
     default:
-        monitor_printf(mon, "Can't hot-add drive to type %d\n", dinfo->type);
+        error_setg(&err, "Can't hot-add drive to type %d", dinfo->type);
         goto err;
     }
     return;
@@ -109,6 +108,7 @@ err:
         monitor_remove_blk(blk);
         blk_unref(blk);
     }
+    hmp_handle_error(mon, err);
 }
 
 void hmp_drive_del(Monitor *mon, const QDict *qdict)
@@ -130,14 +130,14 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
 
     blk = blk_by_name(id);
     if (!blk) {
-        error_report("Device '%s' not found", id);
-        return;
+        error_setg(&local_err, "Device '%s' not found", id);
+        goto err;
     }
 
     if (!blk_legacy_dinfo(blk)) {
-        error_report("Deleting device added with blockdev-add"
-                     " is not supported");
-        return;
+        error_setg(&local_err,
+                   "Deleting device added with blockdev-add is not supported");
+        goto err;
     }
 
     aio_context = blk_get_aio_context(blk);
@@ -146,9 +146,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
     bs = blk_bs(blk);
     if (bs) {
         if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
-            error_report_err(local_err);
             aio_context_release(aio_context);
-            return;
+            goto err;
         }
 
         blk_remove_bs(blk);
@@ -169,12 +168,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
     }
 
     aio_context_release(aio_context);
+err:
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_commit(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
     BlockBackend *blk;
+    Error *local_err = NULL;
     int ret;
 
     if (!strcmp(device, "all")) {
@@ -185,12 +187,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
 
         blk = blk_by_name(device);
         if (!blk) {
-            error_report("Device '%s' not found", device);
-            return;
+            error_setg(&local_err, "Device '%s' not found", device);
+            goto err;
         }
         if (!blk_is_available(blk)) {
-            error_report("Device '%s' has no medium", device);
-            return;
+            error_setg(&local_err, "Device '%s' has no medium", device);
+            goto err;
         }
 
         bs = blk_bs(blk);
@@ -202,8 +204,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
         aio_context_release(aio_context);
     }
     if (ret < 0) {
-        error_report("'commit' error for '%s': %s", device, strerror(-ret));
+        error_setg(&local_err,
+                   "'commit' error for '%s': %s", device, strerror(-ret));
+        goto err;
     }
+    return;
+err:
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 01/13] usb/dev-storage: remove unused include
  2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
@ 2020-01-27 10:49   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-27 10:49 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, qemu-block, QEMU Trivial, Markus Armbruster,
	Max Reitz, Gerd Hoffmann, Dr. David Alan Gilbert

On 1/27/20 11:36 AM, Maxim Levitsky wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>   hw/usb/dev-storage.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
> index 8545193488..50d12244ab 100644
> --- a/hw/usb/dev-storage.c
> +++ b/hw/usb/dev-storage.c
> @@ -19,7 +19,6 @@
>   #include "hw/scsi/scsi.h"
>   #include "ui/console.h"
>   #include "migration/vmstate.h"
> -#include "monitor/monitor.h"
>   #include "sysemu/sysemu.h"
>   #include "sysemu/block-backend.h"
>   #include "qapi/visitor.h"
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (12 preceding siblings ...)
  2020-01-27 10:36 ` [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands Maxim Levitsky
@ 2020-01-27 10:55 ` no-reply
  2020-01-27 10:59   ` Maxim Levitsky
  2020-01-27 19:39 ` John Snow
  14 siblings, 1 reply; 48+ messages in thread
From: no-reply @ 2020-01-27 10:55 UTC (permalink / raw)
  To: mlevitsk
  Cc: kwolf, qemu-block, qemu-devel, armbru, dgilbert, mreitz, kraxel,
	mlevitsk

Patchew URL: https://patchew.org/QEMU/20200127103647.17761-1-mlevitsk@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20200127103647.17761-1-mlevitsk@redhat.com
Subject: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/1579779525-20065-1-git-send-email-imammedo@redhat.com -> patchew/1579779525-20065-1-git-send-email-imammedo@redhat.com
 - [tag update]      patchew/20200124100159.736209-1-stefanha@redhat.com -> patchew/20200124100159.736209-1-stefanha@redhat.com
 - [tag update]      patchew/20200124162606.8787-1-peter.maydell@linaro.org -> patchew/20200124162606.8787-1-peter.maydell@linaro.org
 - [tag update]      patchew/20200124172954.28481-1-peter.maydell@linaro.org -> patchew/20200124172954.28481-1-peter.maydell@linaro.org
 * [new tag]         patchew/20200127103647.17761-1-mlevitsk@redhat.com -> patchew/20200127103647.17761-1-mlevitsk@redhat.com
Switched to a new branch 'test'
9d7e4e6 monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
a549971 add 'error' prefix to vreport
7c7da3a monitor: Move hmp_drive_add_node to block-hmp-cmds.c
a2a0265 monitor/hmp: move hmp_info_block* to block-hmp-cmds.c
d7f13de monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
c067499 monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
f5fab94 monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
4cb26f9 monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
97953d5 monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c
00dc3e8 monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
a4aa184 monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
d76374a monitor/hmp: uninline add_init_drive
13decc9 usb/dev-storage: remove unused include

=== OUTPUT BEGIN ===
1/13 Checking commit 13decc9a539d (usb/dev-storage: remove unused include)
2/13 Checking commit d76374a8829d (monitor/hmp: uninline add_init_drive)
3/13 Checking commit a4aa1842d39b (monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#58: 
new file mode 100644

total: 0 errors, 1 warnings, 83 lines checked

Patch 3/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/13 Checking commit 00dc3e8c0cc5 (monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c)
WARNING: Block comments use a leading /* on a separate line
#81: FILE: block/monitor/block-hmp-cmds.c:119:
+    /* If this BlockBackend has a device attached to it, its refcount will be

total: 0 errors, 1 warnings, 234 lines checked

Patch 4/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/13 Checking commit 97953d583c25 (monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c)
6/13 Checking commit 4cb26f9c9af1 (monitor/hmp: move hmp_block_job* to block-hmp-cmds.c)
7/13 Checking commit f5fab9454aca (monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c)
WARNING: Block comments use a leading /* on a separate line
#29: FILE: block/monitor/block-hmp-cmds.c:294:
+        /* In the future, if 'snapshot-file' is not specified, the snapshot

WARNING: Block comments use * on subsequent lines
#30: FILE: block/monitor/block-hmp-cmds.c:295:
+        /* In the future, if 'snapshot-file' is not specified, the snapshot
+           will be taken internally. Today it's actually required. */

WARNING: Block comments use a trailing */ on a separate line
#30: FILE: block/monitor/block-hmp-cmds.c:295:
+           will be taken internally. Today it's actually required. */

total: 0 errors, 3 warnings, 120 lines checked

Patch 7/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
8/13 Checking commit c06749935535 (monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c)
WARNING: Block comments use a leading /* on a separate line
#60: FILE: block/monitor/block-hmp-cmds.c:363:
+    /* Then try adding all block devices.  If one fails, close all and

total: 0 errors, 1 warnings, 217 lines checked

Patch 8/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/13 Checking commit d7f13ded16b4 (monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c)
WARNING: Block comments use a leading /* on a separate line
#75: FILE: block/monitor/block-hmp-cmds.c:468:
+    /* qmp_block_set_io_throttle has separate parameters for the

WARNING: Block comments use a trailing */ on a separate line
#77: FILE: block/monitor/block-hmp-cmds.c:470:
+     * version has only one, so we must decide which one to pass. */

ERROR: "foo* bar" should be "foo *bar"
#105: FILE: block/monitor/block-hmp-cmds.c:498:
+    const char* device = qdict_get_str(qdict, "device");

ERROR: "foo* bar" should be "foo *bar"
#106: FILE: block/monitor/block-hmp-cmds.c:499:
+    const char* command = qdict_get_str(qdict, "command");

total: 2 errors, 2 warnings, 359 lines checked

Patch 9/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

10/13 Checking commit a2a0265c0910 (monitor/hmp: move hmp_info_block* to block-hmp-cmds.c)
WARNING: line over 80 characters
#67: FILE: block/monitor/block-hmp-cmds.c:593:
+        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {

WARNING: Block comments use a leading /* on a separate line
#381: FILE: block/monitor/block-hmp-cmds.c:907:
+            /* The ID is not guaranteed to be the same on all images, so

total: 0 errors, 2 warnings, 845 lines checked

Patch 10/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/13 Checking commit 7c7da3a311a3 (monitor: Move hmp_drive_add_node to block-hmp-cmds.c)
12/13 Checking commit a549971b349f (add 'error' prefix to vreport)
ERROR: trailing whitespace
#51: FILE: tests/qemu-iotests/026.out:6:
+Event: l1_update; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#62: FILE: tests/qemu-iotests/026.out:16:
+Event: l1_update; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#79: FILE: tests/qemu-iotests/026.out:30:
+Event: l1_update; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#90: FILE: tests/qemu-iotests/026.out:40:
+Event: l1_update; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#107: FILE: tests/qemu-iotests/026.out:54:
+Event: l2_load; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#116: FILE: tests/qemu-iotests/026.out:70:
+Event: l2_load; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#125: FILE: tests/qemu-iotests/026.out:86:
+Event: l2_load; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#134: FILE: tests/qemu-iotests/026.out:102:
+Event: l2_load; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#143: FILE: tests/qemu-iotests/026.out:118:
+Event: l2_update; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#154: FILE: tests/qemu-iotests/026.out:128:
+Event: l2_update; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#171: FILE: tests/qemu-iotests/026.out:142:
+Event: l2_update; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#182: FILE: tests/qemu-iotests/026.out:152:
+Event: l2_update; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#199: FILE: tests/qemu-iotests/026.out:166:
+Event: l2_alloc_write; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#210: FILE: tests/qemu-iotests/026.out:176:
+Event: l2_alloc_write; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#227: FILE: tests/qemu-iotests/026.out:190:
+Event: l2_alloc_write; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#238: FILE: tests/qemu-iotests/026.out:200:
+Event: l2_alloc_write; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#255: FILE: tests/qemu-iotests/026.out:214:
+Event: write_aio; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#266: FILE: tests/qemu-iotests/026.out:224:
+Event: write_aio; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#283: FILE: tests/qemu-iotests/026.out:238:
+Event: write_aio; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#294: FILE: tests/qemu-iotests/026.out:248:
+Event: write_aio; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#311: FILE: tests/qemu-iotests/026.out:262:
+Event: refblock_load; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#322: FILE: tests/qemu-iotests/026.out:272:
+Event: refblock_load; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#339: FILE: tests/qemu-iotests/026.out:286:
+Event: refblock_load; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#350: FILE: tests/qemu-iotests/026.out:296:
+Event: refblock_load; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#367: FILE: tests/qemu-iotests/026.out:310:
+Event: refblock_update_part; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#378: FILE: tests/qemu-iotests/026.out:320:
+Event: refblock_update_part; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#395: FILE: tests/qemu-iotests/026.out:334:
+Event: refblock_update_part; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#406: FILE: tests/qemu-iotests/026.out:344:
+Event: refblock_update_part; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#423: FILE: tests/qemu-iotests/026.out:358:
+Event: refblock_alloc; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#434: FILE: tests/qemu-iotests/026.out:368:
+Event: refblock_alloc; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#451: FILE: tests/qemu-iotests/026.out:382:
+Event: refblock_alloc; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#462: FILE: tests/qemu-iotests/026.out:392:
+Event: refblock_alloc; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#479: FILE: tests/qemu-iotests/026.out:406:
+Event: cluster_alloc; errno: 5; imm: off; once: on; write $

ERROR: trailing whitespace
#488: FILE: tests/qemu-iotests/026.out:416:
+Event: cluster_alloc; errno: 5; imm: off; once: off; write $

ERROR: trailing whitespace
#497: FILE: tests/qemu-iotests/026.out:426:
+Event: cluster_alloc; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#506: FILE: tests/qemu-iotests/026.out:436:
+Event: cluster_alloc; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#515: FILE: tests/qemu-iotests/026.out:449:
+Event: refblock_alloc_hookup; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#526: FILE: tests/qemu-iotests/026.out:459:
+Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#543: FILE: tests/qemu-iotests/026.out:473:
+Event: refblock_alloc_write; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#554: FILE: tests/qemu-iotests/026.out:483:
+Event: refblock_alloc_write; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#571: FILE: tests/qemu-iotests/026.out:497:
+Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#582: FILE: tests/qemu-iotests/026.out:507:
+Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#599: FILE: tests/qemu-iotests/026.out:521:
+Event: refblock_alloc_write_table; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#610: FILE: tests/qemu-iotests/026.out:531:
+Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#627: FILE: tests/qemu-iotests/026.out:545:
+Event: refblock_alloc_switch_table; errno: 28; imm: off; once: on; write $

ERROR: trailing whitespace
#638: FILE: tests/qemu-iotests/026.out:555:
+Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write $

ERROR: trailing whitespace
#781: FILE: tests/qemu-iotests/049.out:107:
+qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for $

ERROR: trailing whitespace
#793: FILE: tests/qemu-iotests/049.out:116:
+qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for $

total: 48 errors, 0 warnings, 3053 lines checked

Patch 12/13 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

13/13 Checking commit 9d7e4e6ebe5d (monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200127103647.17761-1-mlevitsk@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 10:55 ` [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups no-reply
@ 2020-01-27 10:59   ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-27 10:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, armbru, mreitz, kraxel, dgilbert

On Mon, 2020-01-27 at 02:55 -0800, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/20200127103647.17761-1-mlevitsk@redhat.com/
> 
> 
> 
> Hi,
> 
> This series seems to have some coding style problems. See output below for
> more information:

All of these errors are either from code that I moved, and I wanted to
move it as is and from update of iotests, which shows that some of our
error messages end with space, which is stripped by iotest filter,
but once you update the iotest output, it appears again. I'll fix that
in later version of that WIP patch.

Best regards,
	Maxim Levitsky

> 
> Type: series
> Message-id: 20200127103647.17761-1-mlevitsk@redhat.com
> Subject: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> git rev-parse base > /dev/null || exit 0
> git config --local diff.renamelimit 0
> git config --local diff.renames True
> git config --local diff.algorithm histogram
> ./scripts/checkpatch.pl --mailback base..
> === TEST SCRIPT END ===
> 
> Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
> From https://github.com/patchew-project/qemu
>  - [tag update]      patchew/1579779525-20065-1-git-send-email-imammedo@redhat.com -> patchew/1579779525-20065-1-git-send-email-imammedo@redhat.com
>  - [tag update]      patchew/20200124100159.736209-1-stefanha@redhat.com -> patchew/20200124100159.736209-1-stefanha@redhat.com
>  - [tag update]      patchew/20200124162606.8787-1-peter.maydell@linaro.org -> patchew/20200124162606.8787-1-peter.maydell@linaro.org
>  - [tag update]      patchew/20200124172954.28481-1-peter.maydell@linaro.org -> patchew/20200124172954.28481-1-peter.maydell@linaro.org
>  * [new tag]         patchew/20200127103647.17761-1-mlevitsk@redhat.com -> patchew/20200127103647.17761-1-mlevitsk@redhat.com
> Switched to a new branch 'test'
> 9d7e4e6 monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
> a549971 add 'error' prefix to vreport
> 7c7da3a monitor: Move hmp_drive_add_node to block-hmp-cmds.c
> a2a0265 monitor/hmp: move hmp_info_block* to block-hmp-cmds.c
> d7f13de monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
> c067499 monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
> f5fab94 monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
> 4cb26f9 monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
> 97953d5 monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c
> 00dc3e8 monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
> a4aa184 monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
> d76374a monitor/hmp: uninline add_init_drive
> 13decc9 usb/dev-storage: remove unused include
> 
> === OUTPUT BEGIN ===
> 1/13 Checking commit 13decc9a539d (usb/dev-storage: remove unused include)
> 2/13 Checking commit d76374a8829d (monitor/hmp: uninline add_init_drive)
> 3/13 Checking commit a4aa1842d39b (monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c)
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #58: 
> new file mode 100644
> 
> total: 0 errors, 1 warnings, 83 lines checked
> 
> Patch 3/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 4/13 Checking commit 00dc3e8c0cc5 (monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c)
> WARNING: Block comments use a leading /* on a separate line
> #81: FILE: block/monitor/block-hmp-cmds.c:119:
> +    /* If this BlockBackend has a device attached to it, its refcount will be
> 
> total: 0 errors, 1 warnings, 234 lines checked
> 
> Patch 4/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 5/13 Checking commit 97953d583c25 (monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c)
> 6/13 Checking commit 4cb26f9c9af1 (monitor/hmp: move hmp_block_job* to block-hmp-cmds.c)
> 7/13 Checking commit f5fab9454aca (monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c)
> WARNING: Block comments use a leading /* on a separate line
> #29: FILE: block/monitor/block-hmp-cmds.c:294:
> +        /* In the future, if 'snapshot-file' is not specified, the snapshot
> 
> WARNING: Block comments use * on subsequent lines
> #30: FILE: block/monitor/block-hmp-cmds.c:295:
> +        /* In the future, if 'snapshot-file' is not specified, the snapshot
> +           will be taken internally. Today it's actually required. */
> 
> WARNING: Block comments use a trailing */ on a separate line
> #30: FILE: block/monitor/block-hmp-cmds.c:295:
> +           will be taken internally. Today it's actually required. */
> 
> total: 0 errors, 3 warnings, 120 lines checked
> 
> Patch 7/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 8/13 Checking commit c06749935535 (monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c)
> WARNING: Block comments use a leading /* on a separate line
> #60: FILE: block/monitor/block-hmp-cmds.c:363:
> +    /* Then try adding all block devices.  If one fails, close all and
> 
> total: 0 errors, 1 warnings, 217 lines checked
> 
> Patch 8/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 9/13 Checking commit d7f13ded16b4 (monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c)
> WARNING: Block comments use a leading /* on a separate line
> #75: FILE: block/monitor/block-hmp-cmds.c:468:
> +    /* qmp_block_set_io_throttle has separate parameters for the
> 
> WARNING: Block comments use a trailing */ on a separate line
> #77: FILE: block/monitor/block-hmp-cmds.c:470:
> +     * version has only one, so we must decide which one to pass. */
> 
> ERROR: "foo* bar" should be "foo *bar"
> #105: FILE: block/monitor/block-hmp-cmds.c:498:
> +    const char* device = qdict_get_str(qdict, "device");
> 
> ERROR: "foo* bar" should be "foo *bar"
> #106: FILE: block/monitor/block-hmp-cmds.c:499:
> +    const char* command = qdict_get_str(qdict, "command");
> 
> total: 2 errors, 2 warnings, 359 lines checked
> 
> Patch 9/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 10/13 Checking commit a2a0265c0910 (monitor/hmp: move hmp_info_block* to block-hmp-cmds.c)
> WARNING: line over 80 characters
> #67: FILE: block/monitor/block-hmp-cmds.c:593:
> +        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
> 
> WARNING: Block comments use a leading /* on a separate line
> #381: FILE: block/monitor/block-hmp-cmds.c:907:
> +            /* The ID is not guaranteed to be the same on all images, so
> 
> total: 0 errors, 2 warnings, 845 lines checked
> 
> Patch 10/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 11/13 Checking commit 7c7da3a311a3 (monitor: Move hmp_drive_add_node to block-hmp-cmds.c)
> 12/13 Checking commit a549971b349f (add 'error' prefix to vreport)
> ERROR: trailing whitespace
> #51: FILE: tests/qemu-iotests/026.out:6:
> +Event: l1_update; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #62: FILE: tests/qemu-iotests/026.out:16:
> +Event: l1_update; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #79: FILE: tests/qemu-iotests/026.out:30:
> +Event: l1_update; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #90: FILE: tests/qemu-iotests/026.out:40:
> +Event: l1_update; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #107: FILE: tests/qemu-iotests/026.out:54:
> +Event: l2_load; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #116: FILE: tests/qemu-iotests/026.out:70:
> +Event: l2_load; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #125: FILE: tests/qemu-iotests/026.out:86:
> +Event: l2_load; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #134: FILE: tests/qemu-iotests/026.out:102:
> +Event: l2_load; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #143: FILE: tests/qemu-iotests/026.out:118:
> +Event: l2_update; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #154: FILE: tests/qemu-iotests/026.out:128:
> +Event: l2_update; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #171: FILE: tests/qemu-iotests/026.out:142:
> +Event: l2_update; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #182: FILE: tests/qemu-iotests/026.out:152:
> +Event: l2_update; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #199: FILE: tests/qemu-iotests/026.out:166:
> +Event: l2_alloc_write; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #210: FILE: tests/qemu-iotests/026.out:176:
> +Event: l2_alloc_write; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #227: FILE: tests/qemu-iotests/026.out:190:
> +Event: l2_alloc_write; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #238: FILE: tests/qemu-iotests/026.out:200:
> +Event: l2_alloc_write; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #255: FILE: tests/qemu-iotests/026.out:214:
> +Event: write_aio; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #266: FILE: tests/qemu-iotests/026.out:224:
> +Event: write_aio; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #283: FILE: tests/qemu-iotests/026.out:238:
> +Event: write_aio; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #294: FILE: tests/qemu-iotests/026.out:248:
> +Event: write_aio; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #311: FILE: tests/qemu-iotests/026.out:262:
> +Event: refblock_load; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #322: FILE: tests/qemu-iotests/026.out:272:
> +Event: refblock_load; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #339: FILE: tests/qemu-iotests/026.out:286:
> +Event: refblock_load; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #350: FILE: tests/qemu-iotests/026.out:296:
> +Event: refblock_load; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #367: FILE: tests/qemu-iotests/026.out:310:
> +Event: refblock_update_part; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #378: FILE: tests/qemu-iotests/026.out:320:
> +Event: refblock_update_part; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #395: FILE: tests/qemu-iotests/026.out:334:
> +Event: refblock_update_part; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #406: FILE: tests/qemu-iotests/026.out:344:
> +Event: refblock_update_part; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #423: FILE: tests/qemu-iotests/026.out:358:
> +Event: refblock_alloc; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #434: FILE: tests/qemu-iotests/026.out:368:
> +Event: refblock_alloc; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #451: FILE: tests/qemu-iotests/026.out:382:
> +Event: refblock_alloc; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #462: FILE: tests/qemu-iotests/026.out:392:
> +Event: refblock_alloc; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #479: FILE: tests/qemu-iotests/026.out:406:
> +Event: cluster_alloc; errno: 5; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #488: FILE: tests/qemu-iotests/026.out:416:
> +Event: cluster_alloc; errno: 5; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #497: FILE: tests/qemu-iotests/026.out:426:
> +Event: cluster_alloc; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #506: FILE: tests/qemu-iotests/026.out:436:
> +Event: cluster_alloc; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #515: FILE: tests/qemu-iotests/026.out:449:
> +Event: refblock_alloc_hookup; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #526: FILE: tests/qemu-iotests/026.out:459:
> +Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #543: FILE: tests/qemu-iotests/026.out:473:
> +Event: refblock_alloc_write; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #554: FILE: tests/qemu-iotests/026.out:483:
> +Event: refblock_alloc_write; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #571: FILE: tests/qemu-iotests/026.out:497:
> +Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #582: FILE: tests/qemu-iotests/026.out:507:
> +Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #599: FILE: tests/qemu-iotests/026.out:521:
> +Event: refblock_alloc_write_table; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #610: FILE: tests/qemu-iotests/026.out:531:
> +Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #627: FILE: tests/qemu-iotests/026.out:545:
> +Event: refblock_alloc_switch_table; errno: 28; imm: off; once: on; write $
> 
> ERROR: trailing whitespace
> #638: FILE: tests/qemu-iotests/026.out:555:
> +Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write $
> 
> ERROR: trailing whitespace
> #781: FILE: tests/qemu-iotests/049.out:107:
> +qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for $
> 
> ERROR: trailing whitespace
> #793: FILE: tests/qemu-iotests/049.out:116:
> +qemu-img: error: Invalid image size specified! You may use k, M, G, T, P or E suffixes for $
> 
> total: 48 errors, 0 warnings, 3053 lines checked
> 
> Patch 12/13 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 13/13 Checking commit 9d7e4e6ebe5d (monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands)
> === OUTPUT END ===
> 
> Test command exited with code: 1
> 
> 
> The full log is available at
> http://patchew.org/logs/20200127103647.17761-1-mlevitsk@redhat.com/testing.checkpatch/?type=message.
> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
                   ` (13 preceding siblings ...)
  2020-01-27 10:55 ` [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups no-reply
@ 2020-01-27 19:39 ` John Snow
  2020-01-27 20:43   ` Peter Krempa
  14 siblings, 1 reply; 48+ messages in thread
From: John Snow @ 2020-01-27 19:39 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Peter Krempa, Jan Tomko, qemu-block,
	Markus Armbruster, Max Reitz, Gerd Hoffmann,
	Dr. David Alan Gilbert



On 1/27/20 5:36 AM, Maxim Levitsky wrote:
> This patch series is bunch of cleanups
> to the hmp monitor code.
> 
> This series only touched blockdev related hmp handlers.
> 
> No functional changes expected other that
> light error message changes by the last patch.
> 
> This was inspired by this bugzilla:
> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> 
> Basically some users still parse hmp error messages,
> and they would like to have them prefixed with 'Error:'
> 

HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
like consistency in my UIs (it's useful for human eyes, too), but I'd
like to know more about the request.

Is this request coming from libvirt? Can we wean them off of this
interface? What do they need as a replacement?

(Is blockdev not enough?)

--js



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 19:39 ` John Snow
@ 2020-01-27 20:43   ` Peter Krempa
  2020-01-27 21:01     ` John Snow
  2020-01-28  8:17     ` Markus Armbruster
  0 siblings, 2 replies; 48+ messages in thread
From: Peter Krempa @ 2020-01-27 20:43 UTC (permalink / raw)
  To: John Snow
  Cc: Kevin Wolf, Jan Tomko, qemu-block, qemu-devel, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky

On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
> 
> 
> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
> > This patch series is bunch of cleanups
> > to the hmp monitor code.
> > 
> > This series only touched blockdev related hmp handlers.
> > 
> > No functional changes expected other that
> > light error message changes by the last patch.
> > 
> > This was inspired by this bugzilla:
> > https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> > 
> > Basically some users still parse hmp error messages,
> > and they would like to have them prefixed with 'Error:'
> > 
> 
> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
> like consistency in my UIs (it's useful for human eyes, too), but I'd
> like to know more about the request.

That's true as long as there's an stable replacement ... see below.

> 
> Is this request coming from libvirt? Can we wean them off of this
> interface? What do they need as a replacement?

There are 5 commands that libvirt still has HMP interfaces for:

drive_add
drive_del

savevm
loadvm
delvm

From upstream point of view there's no value in adding the 'error'
prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
command instead which have implicit error propagation.

There are no replacements for the internal snapshot commands, but they
reported the 'error' prefix for some time even before this series.

Said that, please don't break savevm/loadvm/delvm until a QMP
replacement is added.

The bug was reported at the time when libvirt didn't use blockdev yet,
but at this point it's pointless from our side. This wouldn't even fix
the scenario when old (pre-5.10) libvirt would use new qemu because the
drive-add handler never checked the error prefix.

[1] https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor_text.c;h=9135a11f0a3aae718c86bb199112fba8d16d4d80;hb=HEAD



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 20:43   ` Peter Krempa
@ 2020-01-27 21:01     ` John Snow
  2020-01-28  9:13       ` Ján Tomko
  2020-01-28 16:47       ` Dr. David Alan Gilbert
  2020-01-28  8:17     ` Markus Armbruster
  1 sibling, 2 replies; 48+ messages in thread
From: John Snow @ 2020-01-27 21:01 UTC (permalink / raw)
  To: Peter Krempa
  Cc: Kevin Wolf, Jan Tomko, qemu-block, qemu-devel, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann, Maxim Levitsky



On 1/27/20 3:43 PM, Peter Krempa wrote:
> On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
>>
>>
>> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
>>> This patch series is bunch of cleanups
>>> to the hmp monitor code.
>>>
>>> This series only touched blockdev related hmp handlers.
>>>
>>> No functional changes expected other that
>>> light error message changes by the last patch.
>>>
>>> This was inspired by this bugzilla:
>>> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
>>>
>>> Basically some users still parse hmp error messages,
>>> and they would like to have them prefixed with 'Error:'
>>>
>>
>> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
>> like consistency in my UIs (it's useful for human eyes, too), but I'd
>> like to know more about the request.
> 
> That's true as long as there's an stable replacement ... see below.
> 

Thanks for the context!

>>
>> Is this request coming from libvirt? Can we wean them off of this
>> interface? What do they need as a replacement?
> 
> There are 5 commands that libvirt still has HMP interfaces for:
> 
> drive_add
> drive_del
> 
> savevm
> loadvm
> delvm
> 
> From upstream point of view there's no value in adding the 'error'
> prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
> command instead which have implicit error propagation.
> 

As thought.

> There are no replacements for the internal snapshot commands, but they
> reported the 'error' prefix for some time even before this series.
> 
> Said that, please don't break savevm/loadvm/delvm until a QMP
> replacement is added.
> 

Yes, noted. I wonder where userfaultfd write support is these days...

> The bug was reported at the time when libvirt didn't use blockdev yet,
> but at this point it's pointless from our side. This wouldn't even fix
> the scenario when old (pre-5.10) libvirt would use new qemu because the
> drive-add handler never checked the error prefix.
> 
> [1] https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor_text.c;h=9135a11f0a3aae718c86bb199112fba8d16d4d80;hb=HEAD
> 

Thank you for the report from libvirtville :)

--js



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 20:43   ` Peter Krempa
  2020-01-27 21:01     ` John Snow
@ 2020-01-28  8:17     ` Markus Armbruster
  1 sibling, 0 replies; 48+ messages in thread
From: Markus Armbruster @ 2020-01-28  8:17 UTC (permalink / raw)
  To: Peter Krempa
  Cc: Kevin Wolf, Maxim Levitsky, Jan Tomko, qemu-block, qemu-devel,
	Dr. David Alan Gilbert, Gerd Hoffmann, Max Reitz, John Snow

Peter Krempa <pkrempa@redhat.com> writes:

> On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
>> 
>> 
>> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
>> > This patch series is bunch of cleanups
>> > to the hmp monitor code.
>> > 
>> > This series only touched blockdev related hmp handlers.
>> > 
>> > No functional changes expected other that
>> > light error message changes by the last patch.
>> > 
>> > This was inspired by this bugzilla:
>> > https://bugzilla.redhat.com/show_bug.cgi?id=1719169
>> > 
>> > Basically some users still parse hmp error messages,
>> > and they would like to have them prefixed with 'Error:'
>> > 
>> 
>> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
>> like consistency in my UIs (it's useful for human eyes, too), but I'd
>> like to know more about the request.
>
> That's true as long as there's an stable replacement ... see below.
>
>> 
>> Is this request coming from libvirt? Can we wean them off of this
>> interface? What do they need as a replacement?
>
> There are 5 commands that libvirt still has HMP interfaces for:
>
> drive_add
> drive_del
>
> savevm
> loadvm
> delvm
>
> From upstream point of view there's no value in adding the 'error'
> prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
> command instead which have implicit error propagation.
>
> There are no replacements for the internal snapshot commands, but they
> reported the 'error' prefix for some time even before this series.
>
> Said that, please don't break savevm/loadvm/delvm until a QMP
> replacement is added.

Replacements have been proposed several times, but they went nowhere
because they replicated the HMP commands' design flaws in QMP.  Here's
one that got some design analysis in its review, by yours truly:
https://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg03593.html

Sane QMP replacements are certainly possible, but so far nobody has
cared enough to pitch in the work.

> The bug was reported at the time when libvirt didn't use blockdev yet,
> but at this point it's pointless from our side. This wouldn't even fix
> the scenario when old (pre-5.10) libvirt would use new qemu because the
> drive-add handler never checked the error prefix.
>
> [1] https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor_text.c;h=9135a11f0a3aae718c86bb199112fba8d16d4d80;hb=HEAD

Thanks!



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 21:01     ` John Snow
@ 2020-01-28  9:13       ` Ján Tomko
  2020-01-28 16:47       ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 48+ messages in thread
From: Ján Tomko @ 2020-01-28  9:13 UTC (permalink / raw)
  To: John Snow
  Cc: Kevin Wolf, Maxim Levitsky, Peter Krempa, qemu-block,
	Markus Armbruster, Dr. David Alan Gilbert, qemu-devel,
	Gerd Hoffmann, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

On Mon, Jan 27, 2020 at 04:01:31PM -0500, John Snow wrote:
>
>
>On 1/27/20 3:43 PM, Peter Krempa wrote:
>> On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
>>>
>>>
>>> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
>>>> This patch series is bunch of cleanups
>>>> to the hmp monitor code.
>>>>
>>>> This series only touched blockdev related hmp handlers.
>>>>
>>>> No functional changes expected other that
>>>> light error message changes by the last patch.
>>>>
>>>> This was inspired by this bugzilla:
>>>> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
>>>>
>>>> Basically some users still parse hmp error messages,
>>>> and they would like to have them prefixed with 'Error:'
>>>>
>>>

[...]

>> The bug was reported at the time when libvirt didn't use blockdev yet,
>> but at this point it's pointless from our side.

Just for the record, this bug was the motivation for the prefix request:
https://bugzilla.redhat.com/show_bug.cgi?id=1718255

>> This wouldn't even fix
>> the scenario when old (pre-5.10) libvirt would use new qemu because the
>> drive-add handler never checked the error prefix.

And running older libvirt with newer QEMU is not something we care
about.

Jano

>>
>> [1] https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor_text.c;h=9135a11f0a3aae718c86bb199112fba8d16d4d80;hb=HEAD
>>
>
>Thank you for the report from libvirtville :)
>
>--js
>
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-27 21:01     ` John Snow
  2020-01-28  9:13       ` Ján Tomko
@ 2020-01-28 16:47       ` Dr. David Alan Gilbert
  2020-02-05 23:25         ` John Snow
  1 sibling, 1 reply; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 16:47 UTC (permalink / raw)
  To: John Snow
  Cc: Kevin Wolf, Peter Krempa, Jan Tomko, qemu-block,
	Markus Armbruster, qemu-devel, Max Reitz, Gerd Hoffmann,
	Maxim Levitsky

* John Snow (jsnow@redhat.com) wrote:
> 
> 
> On 1/27/20 3:43 PM, Peter Krempa wrote:
> > On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
> >>
> >>
> >> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
> >>> This patch series is bunch of cleanups
> >>> to the hmp monitor code.
> >>>
> >>> This series only touched blockdev related hmp handlers.
> >>>
> >>> No functional changes expected other that
> >>> light error message changes by the last patch.
> >>>
> >>> This was inspired by this bugzilla:
> >>> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> >>>
> >>> Basically some users still parse hmp error messages,
> >>> and they would like to have them prefixed with 'Error:'
> >>>
> >>
> >> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
> >> like consistency in my UIs (it's useful for human eyes, too), but I'd
> >> like to know more about the request.
> > 
> > That's true as long as there's an stable replacement ... see below.
> > 
> 
> Thanks for the context!
> 
> >>
> >> Is this request coming from libvirt? Can we wean them off of this
> >> interface? What do they need as a replacement?
> > 
> > There are 5 commands that libvirt still has HMP interfaces for:
> > 
> > drive_add
> > drive_del
> > 
> > savevm
> > loadvm
> > delvm
> > 
> > From upstream point of view there's no value in adding the 'error'
> > prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
> > command instead which have implicit error propagation.
> > 
> 
> As thought.
> 
> > There are no replacements for the internal snapshot commands, but they
> > reported the 'error' prefix for some time even before this series.
> > 
> > Said that, please don't break savevm/loadvm/delvm until a QMP
> > replacement is added.
> > 
> 
> Yes, noted. I wonder where userfaultfd write support is these days...

How would that help you there?

Dave

> > The bug was reported at the time when libvirt didn't use blockdev yet,
> > but at this point it's pointless from our side. This wouldn't even fix
> > the scenario when old (pre-5.10) libvirt would use new qemu because the
> > drive-add handler never checked the error prefix.
> > 
> > [1] https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor_text.c;h=9135a11f0a3aae718c86bb199112fba8d16d4d80;hb=HEAD
> > 
> 
> Thank you for the report from libvirtville :)
> 
> --js
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
@ 2020-01-28 16:56   ` Dr. David Alan Gilbert
  2020-01-28 19:28     ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 16:56 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> These days device-hotplug.c only contains the hmp_drive_add
> In the next patch, rest of hmp_drive* functions will be moved
> there.
> 
> Also change the license of that file to GPL2+ since most
> of the code that will be moved there is under that license

How do we check that's OK?

> Also add block-hmp-commands.h to contain prototypes of these
> functions
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  MAINTAINERS                                   |  1 +
>  Makefile.objs                                 |  2 +-
>  block/Makefile.objs                           |  1 +
>  block/monitor/Makefile.objs                   |  1 +
>  .../monitor/block-hmp-cmds.c                  | 23 ++++---------------
>  include/block/block-hmp-commands.h            |  8 +++++++
>  include/sysemu/sysemu.h                       |  3 ---
>  monitor/misc.c                                |  1 +
>  8 files changed, 18 insertions(+), 22 deletions(-)
>  create mode 100644 block/monitor/Makefile.objs
>  rename device-hotplug.c => block/monitor/block-hmp-cmds.c (55%)
>  create mode 100644 include/block/block-hmp-commands.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f6511d5120..5d50d09ad8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1882,6 +1882,7 @@ Block QAPI, monitor, command line
>  M: Markus Armbruster <armbru@redhat.com>
>  S: Supported
>  F: blockdev.c
> +F: blockdev-hmp-cmds.c
>  F: block/qapi.c
>  F: qapi/block*.json
>  F: qapi/transaction.json
> diff --git a/Makefile.objs b/Makefile.objs
> index ff396b9209..15209eb6b5 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -48,7 +48,7 @@ common-obj-y += dump/
>  common-obj-y += job-qmp.o
>  common-obj-y += monitor/
>  common-obj-y += net/
> -common-obj-y += qdev-monitor.o device-hotplug.o
> +common-obj-y += qdev-monitor.o
>  common-obj-$(CONFIG_WIN32) += os-win32.o
>  common-obj-$(CONFIG_POSIX) += os-posix.o
>  
> diff --git a/block/Makefile.objs b/block/Makefile.objs
> index 330529b0b7..3f65544a6b 100644
> --- a/block/Makefile.objs
> +++ b/block/Makefile.objs
> @@ -44,6 +44,7 @@ block-obj-y += crypto.o
>  block-obj-y += aio_task.o
>  block-obj-y += backup-top.o
>  block-obj-y += filter-compress.o
> +common-obj-y += monitor/
>  
>  common-obj-y += stream.o
>  
> diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs
> new file mode 100644
> index 0000000000..0a74f9a8b5
> --- /dev/null
> +++ b/block/monitor/Makefile.objs
> @@ -0,0 +1 @@
> +common-obj-y += block-hmp-cmds.o
> diff --git a/device-hotplug.c b/block/monitor/block-hmp-cmds.c
> similarity index 55%
> rename from device-hotplug.c
> rename to block/monitor/block-hmp-cmds.c
> index 554e4d98db..c65aaa86ea 100644
> --- a/device-hotplug.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -1,25 +1,11 @@
>  /*
> - * QEMU device hotplug helpers
> + * Blockdev HMP commands
>   *
>   * Copyright (c) 2004 Fabrice Bellard
>   *
> - * Permission is hereby granted, free of charge, to any person obtaining a copy
> - * of this software and associated documentation files (the "Software"), to deal
> - * in the Software without restriction, including without limitation the rights
> - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> - * copies of the Software, and to permit persons to whom the Software is
> - * furnished to do so, subject to the following conditions:
> - *
> - * The above copyright notice and this permission notice shall be included in
> - * all copies or substantial portions of the Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> - * THE SOFTWARE.
> + * This work is licensed under the terms of the GNU GPL, version 2.
> + * or (at your option) any later version.
> + * See the COPYING file in the top-level directory.
>   */
>  
>  #include "qemu/osdep.h"
> @@ -33,6 +19,7 @@
>  #include "sysemu/sysemu.h"
>  #include "monitor/monitor.h"
>  #include "block/block_int.h"
> +#include "block/block-hmp-commands.h"
>  
>  
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> new file mode 100644
> index 0000000000..4f9033a8a6
> --- /dev/null
> +++ b/include/block/block-hmp-commands.h
> @@ -0,0 +1,8 @@
> +#ifndef BLOCK_HMP_COMMANDS_H
> +#define BLOCK_HMP_COMMANDS_H
> +
> +/* HMP commands related to the block layer*/

Should this file get a copyright header as well?

> +
> +void hmp_drive_add(Monitor *mon, const QDict *qdict);
> +
> +#endif
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 80c57fdc4e..c48635666d 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -68,9 +68,6 @@ extern int nb_option_roms;
>  extern const char *prom_envs[MAX_PROM_ENVS];
>  extern unsigned int nb_prom_envs;
>  
> -/* generic hotplug */
> -void hmp_drive_add(Monitor *mon, const QDict *qdict);
> -
>  /* pcie aer error injection */
>  void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
>  
> diff --git a/monitor/misc.c b/monitor/misc.c
> index de1ca4d114..0466c00830 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -79,6 +79,7 @@
>  #include "sysemu/cpus.h"
>  #include "qemu/cutils.h"
>  #include "tcg/tcg.h"
> +#include "block/block-hmp-commands.h"
>  
>  #if defined(TARGET_S390X)
>  #include "hw/s390x/storage-keys.h"
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
@ 2020-01-28 17:51   ` Dr. David Alan Gilbert
  2020-01-28 19:29     ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 17:51 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

(It's easier to compare if you keep the function order the same)

> ---
>  block/monitor/block-hmp-cmds.c     | 97 +++++++++++++++++++++++++++++-
>  blockdev.c                         | 95 -----------------------------
>  include/block/block-hmp-commands.h |  3 +
>  include/sysemu/blockdev.h          |  4 --
>  4 files changed, 99 insertions(+), 100 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index c65aaa86ea..9614c67e77 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -12,6 +12,7 @@
>  #include "hw/boards.h"
>  #include "sysemu/block-backend.h"
>  #include "sysemu/blockdev.h"
> +#include "qapi/qapi-commands-block.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/error.h"
>  #include "qemu/config-file.h"
> @@ -21,7 +22,6 @@
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
>  
> -
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
> @@ -69,3 +69,98 @@ err:
>          blk_unref(blk);
>      }
>  }
> +
> +void hmp_drive_del(Monitor *mon, const QDict *qdict)
> +{
> +    const char *id = qdict_get_str(qdict, "id");
> +    BlockBackend *blk;
> +    BlockDriverState *bs;
> +    AioContext *aio_context;
> +    Error *local_err = NULL;
> +
> +    bs = bdrv_find_node(id);
> +    if (bs) {
> +        qmp_blockdev_del(id, &local_err);
> +        if (local_err) {
> +            error_report_err(local_err);
> +        }
> +        return;
> +    }
> +
> +    blk = blk_by_name(id);
> +    if (!blk) {
> +        error_report("Device '%s' not found", id);
> +        return;
> +    }
> +
> +    if (!blk_legacy_dinfo(blk)) {
> +        error_report("Deleting device added with blockdev-add"
> +                     " is not supported");
> +        return;
> +    }
> +
> +    aio_context = blk_get_aio_context(blk);
> +    aio_context_acquire(aio_context);
> +
> +    bs = blk_bs(blk);
> +    if (bs) {
> +        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> +            error_report_err(local_err);
> +            aio_context_release(aio_context);
> +            return;
> +        }
> +
> +        blk_remove_bs(blk);
> +    }
> +
> +    /* Make the BlockBackend and the attached BlockDriverState anonymous */
> +    monitor_remove_blk(blk);
> +
> +    /* If this BlockBackend has a device attached to it, its refcount will be
> +     * decremented when the device is removed; otherwise we have to do so here.
> +     */
> +    if (blk_get_attached_dev(blk)) {
> +        /* Further I/O must not pause the guest */
> +        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
> +                         BLOCKDEV_ON_ERROR_REPORT);
> +    } else {
> +        blk_unref(blk);
> +    }
> +
> +    aio_context_release(aio_context);
> +}
> +
> +void hmp_commit(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    BlockBackend *blk;
> +    int ret;
> +
> +    if (!strcmp(device, "all")) {
> +        ret = blk_commit_all();
> +    } else {
> +        BlockDriverState *bs;
> +        AioContext *aio_context;
> +
> +        blk = blk_by_name(device);
> +        if (!blk) {
> +            error_report("Device '%s' not found", device);
> +            return;
> +        }
> +        if (!blk_is_available(blk)) {
> +            error_report("Device '%s' has no medium", device);
> +            return;
> +        }
> +
> +        bs = blk_bs(blk);
> +        aio_context = bdrv_get_aio_context(bs);
> +        aio_context_acquire(aio_context);
> +
> +        ret = bdrv_commit(bs);
> +
> +        aio_context_release(aio_context);
> +    }
> +    if (ret < 0) {
> +        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> +    }
> +}
> diff --git a/blockdev.c b/blockdev.c
> index 8e029e9c01..df43e0aaef 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1074,41 +1074,6 @@ static BlockBackend *qmp_get_blk(const char *blk_name, const char *qdev_id,
>      return blk;
>  }
>  
> -void hmp_commit(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    BlockBackend *blk;
> -    int ret;
> -
> -    if (!strcmp(device, "all")) {
> -        ret = blk_commit_all();
> -    } else {
> -        BlockDriverState *bs;
> -        AioContext *aio_context;
> -
> -        blk = blk_by_name(device);
> -        if (!blk) {
> -            error_report("Device '%s' not found", device);
> -            return;
> -        }
> -        if (!blk_is_available(blk)) {
> -            error_report("Device '%s' has no medium", device);
> -            return;
> -        }
> -
> -        bs = blk_bs(blk);
> -        aio_context = bdrv_get_aio_context(bs);
> -        aio_context_acquire(aio_context);
> -
> -        ret = bdrv_commit(bs);
> -
> -        aio_context_release(aio_context);
> -    }
> -    if (ret < 0) {
> -        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> -    }
> -}
> -
>  static void blockdev_do_action(TransactionAction *action, Error **errp)
>  {
>      TransactionActionList list;
> @@ -3101,66 +3066,6 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
>      return ret;
>  }
>  
> -void hmp_drive_del(Monitor *mon, const QDict *qdict)
> -{
> -    const char *id = qdict_get_str(qdict, "id");
> -    BlockBackend *blk;
> -    BlockDriverState *bs;
> -    AioContext *aio_context;
> -    Error *local_err = NULL;
> -
> -    bs = bdrv_find_node(id);
> -    if (bs) {
> -        qmp_blockdev_del(id, &local_err);
> -        if (local_err) {
> -            error_report_err(local_err);
> -        }
> -        return;
> -    }
> -
> -    blk = blk_by_name(id);
> -    if (!blk) {
> -        error_report("Device '%s' not found", id);
> -        return;
> -    }
> -
> -    if (!blk_legacy_dinfo(blk)) {
> -        error_report("Deleting device added with blockdev-add"
> -                     " is not supported");
> -        return;
> -    }
> -
> -    aio_context = blk_get_aio_context(blk);
> -    aio_context_acquire(aio_context);
> -
> -    bs = blk_bs(blk);
> -    if (bs) {
> -        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> -            error_report_err(local_err);
> -            aio_context_release(aio_context);
> -            return;
> -        }
> -
> -        blk_remove_bs(blk);
> -    }
> -
> -    /* Make the BlockBackend and the attached BlockDriverState anonymous */
> -    monitor_remove_blk(blk);
> -
> -    /* If this BlockBackend has a device attached to it, its refcount will be
> -     * decremented when the device is removed; otherwise we have to do so here.
> -     */
> -    if (blk_get_attached_dev(blk)) {
> -        /* Further I/O must not pause the guest */
> -        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
> -                         BLOCKDEV_ON_ERROR_REPORT);
> -    } else {
> -        blk_unref(blk);
> -    }
> -
> -    aio_context_release(aio_context);
> -}
> -
>  void qmp_block_resize(bool has_device, const char *device,
>                        bool has_node_name, const char *node_name,
>                        int64_t size, Error **errp)
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index 4f9033a8a6..c5e394c0fc 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -5,4 +5,7 @@
>  
>  void hmp_drive_add(Monitor *mon, const QDict *qdict);
>  
> +void hmp_commit(Monitor *mon, const QDict *qdict);
> +void hmp_drive_del(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> index d34c4920dc..a86d99b3d8 100644
> --- a/include/sysemu/blockdev.h
> +++ b/include/sysemu/blockdev.h
> @@ -57,8 +57,4 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
>  DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
>                       Error **errp);
>  
> -/* device-hotplug */
> -
> -void hmp_commit(Monitor *mon, const QDict *qdict);
> -void hmp_drive_del(Monitor *mon, const QDict *qdict);
>  #endif
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup " Maxim Levitsky
@ 2020-01-28 17:59   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 17:59 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 64 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  3 ++
>  include/monitor/hmp.h              |  2 -
>  monitor/hmp-cmds.c                 | 58 ---------------------------
>  4 files changed, 67 insertions(+), 60 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index 9614c67e77..ae3890aaab 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -2,6 +2,10 @@
>   * Blockdev HMP commands
>   *
>   * Copyright (c) 2004 Fabrice Bellard
> + * Copyright IBM, Corp. 2011
> + *
> + * Authors:
> + *  Anthony Liguori   <aliguori@us.ibm.com>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2.
>   * or (at your option) any later version.
> @@ -15,12 +19,14 @@
>  #include "qapi/qapi-commands-block.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/error.h"
> +#include "qapi/qmp/qerror.h"
>  #include "qemu/config-file.h"
>  #include "qemu/option.h"
>  #include "sysemu/sysemu.h"
>  #include "monitor/monitor.h"
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
> +#include "monitor/hmp.h"
>  
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>  {
> @@ -164,3 +170,61 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>          error_report("'commit' error for '%s': %s", device, strerror(-ret));
>      }
>  }
> +
> +void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
> +{
> +    const char *filename = qdict_get_str(qdict, "target");
> +    const char *format = qdict_get_try_str(qdict, "format");
> +    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> +    bool full = qdict_get_try_bool(qdict, "full", false);
> +    Error *err = NULL;
> +    DriveMirror mirror = {
> +        .device = (char *)qdict_get_str(qdict, "device"),
> +        .target = (char *)filename,
> +        .has_format = !!format,
> +        .format = (char *)format,
> +        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
> +        .has_mode = true,
> +        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
> +        .unmap = true,
> +    };
> +
> +    if (!filename) {
> +        error_setg(&err, QERR_MISSING_PARAMETER, "target");
> +        hmp_handle_error(mon, err);
> +        return;
> +    }
> +    qmp_drive_mirror(&mirror, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_drive_backup(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *filename = qdict_get_str(qdict, "target");
> +    const char *format = qdict_get_try_str(qdict, "format");
> +    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> +    bool full = qdict_get_try_bool(qdict, "full", false);
> +    bool compress = qdict_get_try_bool(qdict, "compress", false);
> +    Error *err = NULL;
> +    DriveBackup backup = {
> +        .device = (char *)device,
> +        .target = (char *)filename,
> +        .has_format = !!format,
> +        .format = (char *)format,
> +        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
> +        .has_mode = true,
> +        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
> +        .has_compress = !!compress,
> +        .compress = compress,
> +    };
> +
> +    if (!filename) {
> +        error_setg(&err, QERR_MISSING_PARAMETER, "target");
> +        hmp_handle_error(mon, err);
> +        return;
> +    }
> +
> +    qmp_drive_backup(&backup, &err);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index c5e394c0fc..fcaf753118 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -8,4 +8,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict);
>  void hmp_commit(Monitor *mon, const QDict *qdict);
>  void hmp_drive_del(Monitor *mon, const QDict *qdict);
>  
> +void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
> +void hmp_drive_backup(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 3d329853b2..c1b363ee57 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -64,8 +64,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict);
>  void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
>  void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
>  void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
> -void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
> -void hmp_drive_backup(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index d0e0af893a..a70bcb1d16 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1337,64 +1337,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
> -{
> -    const char *filename = qdict_get_str(qdict, "target");
> -    const char *format = qdict_get_try_str(qdict, "format");
> -    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> -    bool full = qdict_get_try_bool(qdict, "full", false);
> -    Error *err = NULL;
> -    DriveMirror mirror = {
> -        .device = (char *)qdict_get_str(qdict, "device"),
> -        .target = (char *)filename,
> -        .has_format = !!format,
> -        .format = (char *)format,
> -        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
> -        .has_mode = true,
> -        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
> -        .unmap = true,
> -    };
> -
> -    if (!filename) {
> -        error_setg(&err, QERR_MISSING_PARAMETER, "target");
> -        hmp_handle_error(mon, err);
> -        return;
> -    }
> -    qmp_drive_mirror(&mirror, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_drive_backup(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *filename = qdict_get_str(qdict, "target");
> -    const char *format = qdict_get_try_str(qdict, "format");
> -    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> -    bool full = qdict_get_try_bool(qdict, "full", false);
> -    bool compress = qdict_get_try_bool(qdict, "compress", false);
> -    Error *err = NULL;
> -    DriveBackup backup = {
> -        .device = (char *)device,
> -        .target = (char *)filename,
> -        .has_format = !!format,
> -        .format = (char *)format,
> -        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
> -        .has_mode = true,
> -        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
> -        .has_compress = !!compress,
> -        .compress = compress,
> -    };
> -
> -    if (!filename) {
> -        error_setg(&err, QERR_MISSING_PARAMETER, "target");
> -        hmp_handle_error(mon, err);
> -        return;
> -    }
> -
> -    qmp_drive_backup(&backup, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
>  {
>      const char *device = qdict_get_str(qdict, "device");
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 06/13] monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
@ 2020-01-28 18:11   ` Dr. David Alan Gilbert
  2020-01-28 18:15   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:11 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 52 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  6 ++++
>  include/monitor/hmp.h              |  5 ---
>  monitor/hmp-cmds.c                 | 52 ------------------------------
>  4 files changed, 58 insertions(+), 57 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index ae3890aaab..ed3c350143 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -228,3 +228,55 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
>      qmp_drive_backup(&backup, &err);
>      hmp_handle_error(mon, err);
>  }
> +
> +void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    int64_t value = qdict_get_int(qdict, "speed");
> +
> +    qmp_block_job_set_speed(device, value, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    bool force = qdict_get_try_bool(qdict, "force", false);
> +
> +    qmp_block_job_cancel(device, true, force, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_pause(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_resume(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_complete(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index fcaf753118..ea6578a5f6 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -11,4 +11,10 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict);
>  void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
>  void hmp_drive_backup(Monitor *mon, const QDict *qdict);
>  
> +void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index c1b363ee57..592ce0ccfe 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -87,11 +87,6 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
>  void hmp_change(Monitor *mon, const QDict *qdict);
>  void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
>  void hmp_block_stream(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
>  void hmp_migrate(Monitor *mon, const QDict *qdict);
>  void hmp_device_add(Monitor *mon, const QDict *qdict);
>  void hmp_device_del(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index a70bcb1d16..996ce96430 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1975,58 +1975,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, error);
>  }
>  
> -void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    int64_t value = qdict_get_int(qdict, "speed");
> -
> -    qmp_block_job_set_speed(device, value, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    bool force = qdict_get_try_bool(qdict, "force", false);
> -
> -    qmp_block_job_cancel(device, true, force, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_pause(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_resume(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_complete(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
>  typedef struct HMPMigrationStatus
>  {
>      QEMUTimer *timer;
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 06/13] monitor/hmp: move hmp_block_job* to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
  2020-01-28 18:11   ` Dr. David Alan Gilbert
@ 2020-01-28 18:15   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:15 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 52 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  6 ++++
>  include/monitor/hmp.h              |  5 ---
>  monitor/hmp-cmds.c                 | 52 ------------------------------
>  4 files changed, 58 insertions(+), 57 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index ae3890aaab..ed3c350143 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -228,3 +228,55 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
>      qmp_drive_backup(&backup, &err);
>      hmp_handle_error(mon, err);
>  }
> +
> +void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    int64_t value = qdict_get_int(qdict, "speed");
> +
> +    qmp_block_job_set_speed(device, value, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    bool force = qdict_get_try_bool(qdict, "force", false);
> +
> +    qmp_block_job_cancel(device, true, force, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_pause(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_resume(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +
> +    qmp_block_job_complete(device, &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index fcaf753118..ea6578a5f6 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -11,4 +11,10 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict);
>  void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
>  void hmp_drive_backup(Monitor *mon, const QDict *qdict);
>  
> +void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
> +void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index c1b363ee57..592ce0ccfe 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -87,11 +87,6 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
>  void hmp_change(Monitor *mon, const QDict *qdict);
>  void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
>  void hmp_block_stream(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
> -void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
>  void hmp_migrate(Monitor *mon, const QDict *qdict);
>  void hmp_device_add(Monitor *mon, const QDict *qdict);
>  void hmp_device_del(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index a70bcb1d16..996ce96430 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1975,58 +1975,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, error);
>  }
>  
> -void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    int64_t value = qdict_get_int(qdict, "speed");
> -
> -    qmp_block_job_set_speed(device, value, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    bool force = qdict_get_try_bool(qdict, "force", false);
> -
> -    qmp_block_job_cancel(device, true, force, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_pause(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_resume(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
> -void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -
> -    qmp_block_job_complete(device, &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
>  typedef struct HMPMigrationStatus
>  {
>      QEMUTimer *timer;
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
@ 2020-01-28 18:45   ` Dr. David Alan Gilbert
  2020-01-28 18:51   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:45 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 138 +++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |   9 ++
>  include/monitor/hmp.h              |   6 --
>  monitor/hmp-cmds.c                 | 137 ----------------------------
>  4 files changed, 147 insertions(+), 143 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index df0178d0f9..60d63bfe18 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -29,6 +29,7 @@
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
>  #include "monitor/hmp.h"
> +#include "qemu-io.h"
>  
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>  {
> @@ -415,3 +416,140 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
>      qmp_nbd_server_stop(&err);
>      hmp_handle_error(mon, err);
>  }
> +
> +void hmp_block_resize(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    int64_t size = qdict_get_int(qdict, "size");
> +    Error *err = NULL;
> +
> +    qmp_block_resize(true, device, false, NULL, size, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_block_stream(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *base = qdict_get_try_str(qdict, "base");
> +    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
> +
> +    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
> +                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
> +                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
> +                     &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_passwd(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *password = qdict_get_str(qdict, "password");
> +    Error *err = NULL;
> +
> +    qmp_block_passwd(true, device, false, NULL, password, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +    char *device = (char *) qdict_get_str(qdict, "device");
> +    BlockIOThrottle throttle = {
> +        .bps = qdict_get_int(qdict, "bps"),
> +        .bps_rd = qdict_get_int(qdict, "bps_rd"),
> +        .bps_wr = qdict_get_int(qdict, "bps_wr"),
> +        .iops = qdict_get_int(qdict, "iops"),
> +        .iops_rd = qdict_get_int(qdict, "iops_rd"),
> +        .iops_wr = qdict_get_int(qdict, "iops_wr"),
> +    };
> +
> +    /* qmp_block_set_io_throttle has separate parameters for the
> +     * (deprecated) block device name and the qdev ID but the HMP
> +     * version has only one, so we must decide which one to pass. */
> +    if (blk_by_name(device)) {
> +        throttle.has_device = true;
> +        throttle.device = device;
> +    } else {
> +        throttle.has_id = true;
> +        throttle.id = device;
> +    }
> +
> +    qmp_block_set_io_throttle(&throttle, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_eject(Monitor *mon, const QDict *qdict)
> +{
> +    bool force = qdict_get_try_bool(qdict, "force", false);
> +    const char *device = qdict_get_str(qdict, "device");
> +    Error *err = NULL;
> +
> +    qmp_eject(true, device, false, NULL, true, force, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> +{
> +    BlockBackend *blk;
> +    BlockBackend *local_blk = NULL;
> +    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
> +    const char* device = qdict_get_str(qdict, "device");
> +    const char* command = qdict_get_str(qdict, "command");
> +    Error *err = NULL;
> +    int ret;
> +
> +    if (qdev) {
> +        blk = blk_by_qdev_id(device, &err);
> +        if (!blk) {
> +            goto fail;
> +        }
> +    } else {
> +        blk = blk_by_name(device);
> +        if (!blk) {
> +            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
> +            if (bs) {
> +                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
> +                                          0, BLK_PERM_ALL);
> +                ret = blk_insert_bs(blk, bs, &err);
> +                if (ret < 0) {
> +                    goto fail;
> +                }
> +            } else {
> +                goto fail;
> +            }
> +        }
> +    }
> +
> +    /*
> +     * Notably absent: Proper permission management. This is sad, but it seems
> +     * almost impossible to achieve without changing the semantics and thereby
> +     * limiting the use cases of the qemu-io HMP command.
> +     *
> +     * In an ideal world we would unconditionally create a new BlockBackend for
> +     * qemuio_command(), but we have commands like 'reopen' and want them to
> +     * take effect on the exact BlockBackend whose name the user passed instead
> +     * of just on a temporary copy of it.
> +     *
> +     * Another problem is that deleting the temporary BlockBackend involves
> +     * draining all requests on it first, but some qemu-iotests cases want to
> +     * issue multiple aio_read/write requests and expect them to complete in
> +     * the background while the monitor has already returned.
> +     *
> +     * This is also what prevents us from saving the original permissions and
> +     * restoring them later: We can't revoke permissions until all requests
> +     * have completed, and we don't know when that is nor can we really let
> +     * anything else run before we have revoken them to avoid race conditions.
> +     *
> +     * What happens now is that command() in qemu-io-cmds.c can extend the
> +     * permissions if necessary for the qemu-io command. And they simply stay
> +     * extended, possibly resulting in a read-only guest device keeping write
> +     * permissions. Ugly, but it appears to be the lesser evil.
> +     */
> +    qemuio_command(blk, command);
> +
> +fail:
> +    blk_unref(local_blk);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index 721b9a1978..99145c8fcf 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -26,4 +26,13 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
>  void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
>  void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
>  
> +void hmp_block_resize(Monitor *mon, const QDict *qdict);
> +void hmp_block_stream(Monitor *mon, const QDict *qdict);
> +void hmp_block_passwd(Monitor *mon, const QDict *qdict);
> +void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
> +void hmp_eject(Monitor *mon, const QDict *qdict);
> +
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> +
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 736a969131..47a7cad734 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -58,9 +58,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
>  void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
>  void hmp_nmi(Monitor *mon, const QDict *qdict);
>  void hmp_set_link(Monitor *mon, const QDict *qdict);
> -void hmp_block_passwd(Monitor *mon, const QDict *qdict);
>  void hmp_balloon(Monitor *mon, const QDict *qdict);
> -void hmp_block_resize(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> @@ -80,10 +78,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict);
>  void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
>  void hmp_set_password(Monitor *mon, const QDict *qdict);
>  void hmp_expire_password(Monitor *mon, const QDict *qdict);
> -void hmp_eject(Monitor *mon, const QDict *qdict);
>  void hmp_change(Monitor *mon, const QDict *qdict);
> -void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
> -void hmp_block_stream(Monitor *mon, const QDict *qdict);
>  void hmp_migrate(Monitor *mon, const QDict *qdict);
>  void hmp_device_add(Monitor *mon, const QDict *qdict);
>  void hmp_device_del(Monitor *mon, const QDict *qdict);
> @@ -98,7 +93,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_change(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_send_break(Monitor *mon, const QDict *qdict);
> -void hmp_qemu_io(Monitor *mon, const QDict *qdict);
>  void hmp_cpu_add(Monitor *mon, const QDict *qdict);
>  void hmp_object_add(Monitor *mon, const QDict *qdict);
>  void hmp_object_del(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 67d2ca8a4c..c224e0f338 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -46,7 +46,6 @@
>  #include "qom/object_interfaces.h"
>  #include "ui/console.h"
>  #include "block/qapi.h"
> -#include "qemu-io.h"
>  #include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "exec/ramlist.h"
> @@ -1307,16 +1306,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_passwd(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *password = qdict_get_str(qdict, "password");
> -    Error *err = NULL;
> -
> -    qmp_block_passwd(true, device, false, NULL, password, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_balloon(Monitor *mon, const QDict *qdict)
>  {
>      int64_t value = qdict_get_int(qdict, "value");
> @@ -1326,16 +1315,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_resize(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    int64_t size = qdict_get_int(qdict, "size");
> -    Error *err = NULL;
> -
> -    qmp_block_resize(true, device, false, NULL, size, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_loadvm(Monitor *mon, const QDict *qdict)
>  {
>      int saved_vm_running  = runstate_is_running();
> @@ -1818,15 +1797,6 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_eject(Monitor *mon, const QDict *qdict)
> -{
> -    bool force = qdict_get_try_bool(qdict, "force", false);
> -    const char *device = qdict_get_str(qdict, "device");
> -    Error *err = NULL;
> -
> -    qmp_eject(true, device, false, NULL, true, force, &err);
> -    hmp_handle_error(mon, err);
> -}
>  
>  #ifdef CONFIG_VNC
>  static void hmp_change_read_arg(void *opaque, const char *password,
> @@ -1884,49 +1854,6 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
> -{
> -    Error *err = NULL;
> -    char *device = (char *) qdict_get_str(qdict, "device");
> -    BlockIOThrottle throttle = {
> -        .bps = qdict_get_int(qdict, "bps"),
> -        .bps_rd = qdict_get_int(qdict, "bps_rd"),
> -        .bps_wr = qdict_get_int(qdict, "bps_wr"),
> -        .iops = qdict_get_int(qdict, "iops"),
> -        .iops_rd = qdict_get_int(qdict, "iops_rd"),
> -        .iops_wr = qdict_get_int(qdict, "iops_wr"),
> -    };
> -
> -    /* qmp_block_set_io_throttle has separate parameters for the
> -     * (deprecated) block device name and the qdev ID but the HMP
> -     * version has only one, so we must decide which one to pass. */
> -    if (blk_by_name(device)) {
> -        throttle.has_device = true;
> -        throttle.device = device;
> -    } else {
> -        throttle.has_id = true;
> -        throttle.id = device;
> -    }
> -
> -    qmp_block_set_io_throttle(&throttle, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_block_stream(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *base = qdict_get_try_str(qdict, "base");
> -    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
> -
> -    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
> -                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
> -                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
> -                     &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
>  typedef struct HMPMigrationStatus
>  {
>      QEMUTimer *timer;
> @@ -2219,70 +2146,6 @@ void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, local_err);
>  }
>  
> -void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> -{
> -    BlockBackend *blk;
> -    BlockBackend *local_blk = NULL;
> -    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
> -    const char* device = qdict_get_str(qdict, "device");
> -    const char* command = qdict_get_str(qdict, "command");
> -    Error *err = NULL;
> -    int ret;
> -
> -    if (qdev) {
> -        blk = blk_by_qdev_id(device, &err);
> -        if (!blk) {
> -            goto fail;
> -        }
> -    } else {
> -        blk = blk_by_name(device);
> -        if (!blk) {
> -            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
> -            if (bs) {
> -                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
> -                                          0, BLK_PERM_ALL);
> -                ret = blk_insert_bs(blk, bs, &err);
> -                if (ret < 0) {
> -                    goto fail;
> -                }
> -            } else {
> -                goto fail;
> -            }
> -        }
> -    }
> -
> -    /*
> -     * Notably absent: Proper permission management. This is sad, but it seems
> -     * almost impossible to achieve without changing the semantics and thereby
> -     * limiting the use cases of the qemu-io HMP command.
> -     *
> -     * In an ideal world we would unconditionally create a new BlockBackend for
> -     * qemuio_command(), but we have commands like 'reopen' and want them to
> -     * take effect on the exact BlockBackend whose name the user passed instead
> -     * of just on a temporary copy of it.
> -     *
> -     * Another problem is that deleting the temporary BlockBackend involves
> -     * draining all requests on it first, but some qemu-iotests cases want to
> -     * issue multiple aio_read/write requests and expect them to complete in
> -     * the background while the monitor has already returned.
> -     *
> -     * This is also what prevents us from saving the original permissions and
> -     * restoring them later: We can't revoke permissions until all requests
> -     * have completed, and we don't know when that is nor can we really let
> -     * anything else run before we have revoken them to avoid race conditions.
> -     *
> -     * What happens now is that command() in qemu-io-cmds.c can extend the
> -     * permissions if necessary for the qemu-io command. And they simply stay
> -     * extended, possibly resulting in a read-only guest device keeping write
> -     * permissions. Ugly, but it appears to be the lesser evil.
> -     */
> -    qemuio_command(blk, command);
> -
> -fail:
> -    blk_unref(local_blk);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_object_del(Monitor *mon, const QDict *qdict)
>  {
>      const char *id = qdict_get_str(qdict, "id");
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
  2020-01-28 18:45   ` Dr. David Alan Gilbert
@ 2020-01-28 18:51   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:51 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 138 +++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |   9 ++
>  include/monitor/hmp.h              |   6 --
>  monitor/hmp-cmds.c                 | 137 ----------------------------
>  4 files changed, 147 insertions(+), 143 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index df0178d0f9..60d63bfe18 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -29,6 +29,7 @@
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
>  #include "monitor/hmp.h"
> +#include "qemu-io.h"
>  
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>  {
> @@ -415,3 +416,140 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
>      qmp_nbd_server_stop(&err);
>      hmp_handle_error(mon, err);
>  }
> +
> +void hmp_block_resize(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    int64_t size = qdict_get_int(qdict, "size");
> +    Error *err = NULL;
> +
> +    qmp_block_resize(true, device, false, NULL, size, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_block_stream(Monitor *mon, const QDict *qdict)
> +{
> +    Error *error = NULL;
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *base = qdict_get_try_str(qdict, "base");
> +    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
> +
> +    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
> +                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
> +                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
> +                     &error);
> +
> +    hmp_handle_error(mon, error);
> +}
> +
> +void hmp_block_passwd(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *password = qdict_get_str(qdict, "password");
> +    Error *err = NULL;
> +
> +    qmp_block_passwd(true, device, false, NULL, password, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +    char *device = (char *) qdict_get_str(qdict, "device");
> +    BlockIOThrottle throttle = {
> +        .bps = qdict_get_int(qdict, "bps"),
> +        .bps_rd = qdict_get_int(qdict, "bps_rd"),
> +        .bps_wr = qdict_get_int(qdict, "bps_wr"),
> +        .iops = qdict_get_int(qdict, "iops"),
> +        .iops_rd = qdict_get_int(qdict, "iops_rd"),
> +        .iops_wr = qdict_get_int(qdict, "iops_wr"),
> +    };
> +
> +    /* qmp_block_set_io_throttle has separate parameters for the
> +     * (deprecated) block device name and the qdev ID but the HMP
> +     * version has only one, so we must decide which one to pass. */
> +    if (blk_by_name(device)) {
> +        throttle.has_device = true;
> +        throttle.device = device;
> +    } else {
> +        throttle.has_id = true;
> +        throttle.id = device;
> +    }
> +
> +    qmp_block_set_io_throttle(&throttle, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_eject(Monitor *mon, const QDict *qdict)
> +{
> +    bool force = qdict_get_try_bool(qdict, "force", false);
> +    const char *device = qdict_get_str(qdict, "device");
> +    Error *err = NULL;
> +
> +    qmp_eject(true, device, false, NULL, true, force, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> +{
> +    BlockBackend *blk;
> +    BlockBackend *local_blk = NULL;
> +    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
> +    const char* device = qdict_get_str(qdict, "device");
> +    const char* command = qdict_get_str(qdict, "command");
> +    Error *err = NULL;
> +    int ret;
> +
> +    if (qdev) {
> +        blk = blk_by_qdev_id(device, &err);
> +        if (!blk) {
> +            goto fail;
> +        }
> +    } else {
> +        blk = blk_by_name(device);
> +        if (!blk) {
> +            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
> +            if (bs) {
> +                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
> +                                          0, BLK_PERM_ALL);
> +                ret = blk_insert_bs(blk, bs, &err);
> +                if (ret < 0) {
> +                    goto fail;
> +                }
> +            } else {
> +                goto fail;
> +            }
> +        }
> +    }
> +
> +    /*
> +     * Notably absent: Proper permission management. This is sad, but it seems
> +     * almost impossible to achieve without changing the semantics and thereby
> +     * limiting the use cases of the qemu-io HMP command.
> +     *
> +     * In an ideal world we would unconditionally create a new BlockBackend for
> +     * qemuio_command(), but we have commands like 'reopen' and want them to
> +     * take effect on the exact BlockBackend whose name the user passed instead
> +     * of just on a temporary copy of it.
> +     *
> +     * Another problem is that deleting the temporary BlockBackend involves
> +     * draining all requests on it first, but some qemu-iotests cases want to
> +     * issue multiple aio_read/write requests and expect them to complete in
> +     * the background while the monitor has already returned.
> +     *
> +     * This is also what prevents us from saving the original permissions and
> +     * restoring them later: We can't revoke permissions until all requests
> +     * have completed, and we don't know when that is nor can we really let
> +     * anything else run before we have revoken them to avoid race conditions.
> +     *
> +     * What happens now is that command() in qemu-io-cmds.c can extend the
> +     * permissions if necessary for the qemu-io command. And they simply stay
> +     * extended, possibly resulting in a read-only guest device keeping write
> +     * permissions. Ugly, but it appears to be the lesser evil.
> +     */
> +    qemuio_command(blk, command);
> +
> +fail:
> +    blk_unref(local_blk);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index 721b9a1978..99145c8fcf 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -26,4 +26,13 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
>  void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
>  void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
>  
> +void hmp_block_resize(Monitor *mon, const QDict *qdict);
> +void hmp_block_stream(Monitor *mon, const QDict *qdict);
> +void hmp_block_passwd(Monitor *mon, const QDict *qdict);
> +void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
> +void hmp_eject(Monitor *mon, const QDict *qdict);
> +
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> +
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 736a969131..47a7cad734 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -58,9 +58,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
>  void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
>  void hmp_nmi(Monitor *mon, const QDict *qdict);
>  void hmp_set_link(Monitor *mon, const QDict *qdict);
> -void hmp_block_passwd(Monitor *mon, const QDict *qdict);
>  void hmp_balloon(Monitor *mon, const QDict *qdict);
> -void hmp_block_resize(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> @@ -80,10 +78,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict);
>  void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
>  void hmp_set_password(Monitor *mon, const QDict *qdict);
>  void hmp_expire_password(Monitor *mon, const QDict *qdict);
> -void hmp_eject(Monitor *mon, const QDict *qdict);
>  void hmp_change(Monitor *mon, const QDict *qdict);
> -void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
> -void hmp_block_stream(Monitor *mon, const QDict *qdict);
>  void hmp_migrate(Monitor *mon, const QDict *qdict);
>  void hmp_device_add(Monitor *mon, const QDict *qdict);
>  void hmp_device_del(Monitor *mon, const QDict *qdict);
> @@ -98,7 +93,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_change(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_send_break(Monitor *mon, const QDict *qdict);
> -void hmp_qemu_io(Monitor *mon, const QDict *qdict);
>  void hmp_cpu_add(Monitor *mon, const QDict *qdict);
>  void hmp_object_add(Monitor *mon, const QDict *qdict);
>  void hmp_object_del(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 67d2ca8a4c..c224e0f338 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -46,7 +46,6 @@
>  #include "qom/object_interfaces.h"
>  #include "ui/console.h"
>  #include "block/qapi.h"
> -#include "qemu-io.h"
>  #include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "exec/ramlist.h"
> @@ -1307,16 +1306,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_passwd(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *password = qdict_get_str(qdict, "password");
> -    Error *err = NULL;
> -
> -    qmp_block_passwd(true, device, false, NULL, password, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_balloon(Monitor *mon, const QDict *qdict)
>  {
>      int64_t value = qdict_get_int(qdict, "value");
> @@ -1326,16 +1315,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_resize(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    int64_t size = qdict_get_int(qdict, "size");
> -    Error *err = NULL;
> -
> -    qmp_block_resize(true, device, false, NULL, size, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_loadvm(Monitor *mon, const QDict *qdict)
>  {
>      int saved_vm_running  = runstate_is_running();
> @@ -1818,15 +1797,6 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_eject(Monitor *mon, const QDict *qdict)
> -{
> -    bool force = qdict_get_try_bool(qdict, "force", false);
> -    const char *device = qdict_get_str(qdict, "device");
> -    Error *err = NULL;
> -
> -    qmp_eject(true, device, false, NULL, true, force, &err);
> -    hmp_handle_error(mon, err);
> -}
>  
>  #ifdef CONFIG_VNC
>  static void hmp_change_read_arg(void *opaque, const char *password,
> @@ -1884,49 +1854,6 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
> -{
> -    Error *err = NULL;
> -    char *device = (char *) qdict_get_str(qdict, "device");
> -    BlockIOThrottle throttle = {
> -        .bps = qdict_get_int(qdict, "bps"),
> -        .bps_rd = qdict_get_int(qdict, "bps_rd"),
> -        .bps_wr = qdict_get_int(qdict, "bps_wr"),
> -        .iops = qdict_get_int(qdict, "iops"),
> -        .iops_rd = qdict_get_int(qdict, "iops_rd"),
> -        .iops_wr = qdict_get_int(qdict, "iops_wr"),
> -    };
> -
> -    /* qmp_block_set_io_throttle has separate parameters for the
> -     * (deprecated) block device name and the qdev ID but the HMP
> -     * version has only one, so we must decide which one to pass. */
> -    if (blk_by_name(device)) {
> -        throttle.has_device = true;
> -        throttle.device = device;
> -    } else {
> -        throttle.has_id = true;
> -        throttle.id = device;
> -    }
> -
> -    qmp_block_set_io_throttle(&throttle, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_block_stream(Monitor *mon, const QDict *qdict)
> -{
> -    Error *error = NULL;
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *base = qdict_get_try_str(qdict, "base");
> -    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
> -
> -    qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
> -                     false, NULL, qdict_haskey(qdict, "speed"), speed, true,
> -                     BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
> -                     &error);
> -
> -    hmp_handle_error(mon, error);
> -}
> -
>  typedef struct HMPMigrationStatus
>  {
>      QEMUTimer *timer;
> @@ -2219,70 +2146,6 @@ void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, local_err);
>  }
>  
> -void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> -{
> -    BlockBackend *blk;
> -    BlockBackend *local_blk = NULL;
> -    bool qdev = qdict_get_try_bool(qdict, "qdev", false);
> -    const char* device = qdict_get_str(qdict, "device");
> -    const char* command = qdict_get_str(qdict, "command");
> -    Error *err = NULL;
> -    int ret;
> -
> -    if (qdev) {
> -        blk = blk_by_qdev_id(device, &err);
> -        if (!blk) {
> -            goto fail;
> -        }
> -    } else {
> -        blk = blk_by_name(device);
> -        if (!blk) {
> -            BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
> -            if (bs) {
> -                blk = local_blk = blk_new(bdrv_get_aio_context(bs),
> -                                          0, BLK_PERM_ALL);
> -                ret = blk_insert_bs(blk, bs, &err);
> -                if (ret < 0) {
> -                    goto fail;
> -                }
> -            } else {
> -                goto fail;
> -            }
> -        }
> -    }
> -
> -    /*
> -     * Notably absent: Proper permission management. This is sad, but it seems
> -     * almost impossible to achieve without changing the semantics and thereby
> -     * limiting the use cases of the qemu-io HMP command.
> -     *
> -     * In an ideal world we would unconditionally create a new BlockBackend for
> -     * qemuio_command(), but we have commands like 'reopen' and want them to
> -     * take effect on the exact BlockBackend whose name the user passed instead
> -     * of just on a temporary copy of it.
> -     *
> -     * Another problem is that deleting the temporary BlockBackend involves
> -     * draining all requests on it first, but some qemu-iotests cases want to
> -     * issue multiple aio_read/write requests and expect them to complete in
> -     * the background while the monitor has already returned.
> -     *
> -     * This is also what prevents us from saving the original permissions and
> -     * restoring them later: We can't revoke permissions until all requests
> -     * have completed, and we don't know when that is nor can we really let
> -     * anything else run before we have revoken them to avoid race conditions.
> -     *
> -     * What happens now is that command() in qemu-io-cmds.c can extend the
> -     * permissions if necessary for the qemu-io command. And they simply stay
> -     * extended, possibly resulting in a read-only guest device keeping write
> -     * permissions. Ugly, but it appears to be the lesser evil.
> -     */
> -    qemuio_command(blk, command);
> -
> -fail:
> -    blk_unref(local_blk);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_object_del(Monitor *mon, const QDict *qdict)
>  {
>      const char *id = qdict_get_str(qdict, "id");
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* " Maxim Levitsky
@ 2020-01-28 18:53   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:53 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 47 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  4 +++
>  include/monitor/hmp.h              |  3 --
>  monitor/hmp-cmds.c                 | 47 ------------------------------
>  4 files changed, 51 insertions(+), 50 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index ed3c350143..9aa94ea6e0 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -280,3 +280,50 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
>  
>      hmp_handle_error(mon, error);
>  }
> +
> +void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
> +    const char *format = qdict_get_try_str(qdict, "format");
> +    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> +    enum NewImageMode mode;
> +    Error *err = NULL;
> +
> +    if (!filename) {
> +        /* In the future, if 'snapshot-file' is not specified, the snapshot
> +           will be taken internally. Today it's actually required. */
> +        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
> +        hmp_handle_error(mon, err);
> +        return;
> +    }
> +
> +    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> +    qmp_blockdev_snapshot_sync(true, device, false, NULL,
> +                               filename, false, NULL,
> +                               !!format, format,
> +                               true, mode, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *name = qdict_get_str(qdict, "name");
> +    Error *err = NULL;
> +
> +    qmp_blockdev_snapshot_internal_sync(device, name, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *name = qdict_get_str(qdict, "name");
> +    const char *id = qdict_get_try_str(qdict, "id");
> +    Error *err = NULL;
> +
> +    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
> +                                               true, name, &err);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index ea6578a5f6..3fc2daf3a9 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -17,4 +17,8 @@ void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
>  void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
>  void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
>  
> +void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
> +void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
> +void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 592ce0ccfe..6d34e29bb6 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -61,9 +61,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict);
>  void hmp_block_passwd(Monitor *mon, const QDict *qdict);
>  void hmp_balloon(Monitor *mon, const QDict *qdict);
>  void hmp_block_resize(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 996ce96430..46b46b6dd7 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1337,53 +1337,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
> -    const char *format = qdict_get_try_str(qdict, "format");
> -    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> -    enum NewImageMode mode;
> -    Error *err = NULL;
> -
> -    if (!filename) {
> -        /* In the future, if 'snapshot-file' is not specified, the snapshot
> -           will be taken internally. Today it's actually required. */
> -        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
> -        hmp_handle_error(mon, err);
> -        return;
> -    }
> -
> -    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> -    qmp_blockdev_snapshot_sync(true, device, false, NULL,
> -                               filename, false, NULL,
> -                               !!format, format,
> -                               true, mode, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *name = qdict_get_str(qdict, "name");
> -    Error *err = NULL;
> -
> -    qmp_blockdev_snapshot_internal_sync(device, name, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *name = qdict_get_str(qdict, "name");
> -    const char *id = qdict_get_try_str(qdict, "id");
> -    Error *err = NULL;
> -
> -    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
> -                                               true, name, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_loadvm(Monitor *mon, const QDict *qdict)
>  {
>      int saved_vm_running  = runstate_is_running();
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* " Maxim Levitsky
@ 2020-01-28 18:56   ` Dr. David Alan Gilbert
  2020-01-28 20:05     ` Eric Blake
  0 siblings, 1 reply; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 18:56 UTC (permalink / raw)
  To: Maxim Levitsky, eblake
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Yes, I think that's OK; I can imagine nbd might want to move on it's own
somewhere since it's not really core block code; copying in Eric.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 88 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  5 ++
>  include/monitor/hmp.h              |  4 --
>  monitor/hmp-cmds.c                 | 87 -----------------------------
>  4 files changed, 93 insertions(+), 91 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index 9aa94ea6e0..df0178d0f9 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -22,8 +22,10 @@
>  #include "qapi/qmp/qerror.h"
>  #include "qemu/config-file.h"
>  #include "qemu/option.h"
> +#include "qemu/sockets.h"
>  #include "sysemu/sysemu.h"
>  #include "monitor/monitor.h"
> +#include "block/nbd.h"
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
>  #include "monitor/hmp.h"
> @@ -327,3 +329,89 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
>                                                 true, name, &err);
>      hmp_handle_error(mon, err);
>  }
> +
> +void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
> +{
> +    const char *uri = qdict_get_str(qdict, "uri");
> +    bool writable = qdict_get_try_bool(qdict, "writable", false);
> +    bool all = qdict_get_try_bool(qdict, "all", false);
> +    Error *local_err = NULL;
> +    BlockInfoList *block_list, *info;
> +    SocketAddress *addr;
> +
> +    if (writable && !all) {
> +        error_setg(&local_err, "-w only valid together with -a");
> +        goto exit;
> +    }
> +
> +    /* First check if the address is valid and start the server.  */
> +    addr = socket_parse(uri, &local_err);
> +    if (local_err != NULL) {
> +        goto exit;
> +    }
> +
> +    nbd_server_start(addr, NULL, NULL, &local_err);
> +    qapi_free_SocketAddress(addr);
> +    if (local_err != NULL) {
> +        goto exit;
> +    }
> +
> +    if (!all) {
> +        return;
> +    }
> +
> +    /* Then try adding all block devices.  If one fails, close all and
> +     * exit.
> +     */
> +    block_list = qmp_query_block(NULL);
> +
> +    for (info = block_list; info; info = info->next) {
> +        if (!info->value->has_inserted) {
> +            continue;
> +        }
> +
> +        qmp_nbd_server_add(info->value->device, false, NULL,
> +                           true, writable, false, NULL, &local_err);
> +
> +        if (local_err != NULL) {
> +            qmp_nbd_server_stop(NULL);
> +            break;
> +        }
> +    }
> +
> +    qapi_free_BlockInfoList(block_list);
> +
> +exit:
> +    hmp_handle_error(mon, local_err);
> +}
> +
> +void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *name = qdict_get_try_str(qdict, "name");
> +    bool writable = qdict_get_try_bool(qdict, "writable", false);
> +    Error *local_err = NULL;
> +
> +    qmp_nbd_server_add(device, !!name, name, true, writable,
> +                       false, NULL, &local_err);
> +    hmp_handle_error(mon, local_err);
> +}
> +
> +void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
> +{
> +    const char *name = qdict_get_str(qdict, "name");
> +    bool force = qdict_get_try_bool(qdict, "force", false);
> +    Error *err = NULL;
> +
> +    /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
> +    qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +
> +    qmp_nbd_server_stop(&err);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index 3fc2daf3a9..721b9a1978 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -21,4 +21,9 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
>  void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
>  void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
>  
> +void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
> +void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
> +void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
> +void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 6d34e29bb6..736a969131 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -94,10 +94,6 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);
>  void hmp_closefd(Monitor *mon, const QDict *qdict);
>  void hmp_sendkey(Monitor *mon, const QDict *qdict);
>  void hmp_screendump(Monitor *mon, const QDict *qdict);
> -void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
> -void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
> -void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
> -void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_add(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_change(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 46b46b6dd7..67d2ca8a4c 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -45,7 +45,6 @@
>  #include "qapi/string-output-visitor.h"
>  #include "qom/object_interfaces.h"
>  #include "ui/console.h"
> -#include "block/nbd.h"
>  #include "block/qapi.h"
>  #include "qemu-io.h"
>  #include "qemu/cutils.h"
> @@ -2154,92 +2153,6 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
> -{
> -    const char *uri = qdict_get_str(qdict, "uri");
> -    bool writable = qdict_get_try_bool(qdict, "writable", false);
> -    bool all = qdict_get_try_bool(qdict, "all", false);
> -    Error *local_err = NULL;
> -    BlockInfoList *block_list, *info;
> -    SocketAddress *addr;
> -
> -    if (writable && !all) {
> -        error_setg(&local_err, "-w only valid together with -a");
> -        goto exit;
> -    }
> -
> -    /* First check if the address is valid and start the server.  */
> -    addr = socket_parse(uri, &local_err);
> -    if (local_err != NULL) {
> -        goto exit;
> -    }
> -
> -    nbd_server_start(addr, NULL, NULL, &local_err);
> -    qapi_free_SocketAddress(addr);
> -    if (local_err != NULL) {
> -        goto exit;
> -    }
> -
> -    if (!all) {
> -        return;
> -    }
> -
> -    /* Then try adding all block devices.  If one fails, close all and
> -     * exit.
> -     */
> -    block_list = qmp_query_block(NULL);
> -
> -    for (info = block_list; info; info = info->next) {
> -        if (!info->value->has_inserted) {
> -            continue;
> -        }
> -
> -        qmp_nbd_server_add(info->value->device, false, NULL,
> -                           true, writable, false, NULL, &local_err);
> -
> -        if (local_err != NULL) {
> -            qmp_nbd_server_stop(NULL);
> -            break;
> -        }
> -    }
> -
> -    qapi_free_BlockInfoList(block_list);
> -
> -exit:
> -    hmp_handle_error(mon, local_err);
> -}
> -
> -void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *name = qdict_get_try_str(qdict, "name");
> -    bool writable = qdict_get_try_bool(qdict, "writable", false);
> -    Error *local_err = NULL;
> -
> -    qmp_nbd_server_add(device, !!name, name, true, writable,
> -                       false, NULL, &local_err);
> -    hmp_handle_error(mon, local_err);
> -}
> -
> -void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
> -{
> -    const char *name = qdict_get_str(qdict, "name");
> -    bool force = qdict_get_try_bool(qdict, "force", false);
> -    Error *err = NULL;
> -
> -    /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
> -    qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
> -{
> -    Error *err = NULL;
> -
> -    qmp_nbd_server_stop(&err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_chardev_add(Monitor *mon, const QDict *qdict)
>  {
>      const char *args = qdict_get_str(qdict, "args");
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 10/13] monitor/hmp: move hmp_info_block* to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 10/13] monitor/hmp: move hmp_info_block* " Maxim Levitsky
@ 2020-01-28 19:00   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 19:00 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 388 +++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |   4 +
>  include/monitor/hmp.h              |   4 -
>  monitor/hmp-cmds.c                 | 388 -----------------------------
>  4 files changed, 392 insertions(+), 392 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index 60d63bfe18..a4b1604aee 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -23,11 +23,13 @@
>  #include "qemu/config-file.h"
>  #include "qemu/option.h"
>  #include "qemu/sockets.h"
> +#include "qemu/cutils.h"
>  #include "sysemu/sysemu.h"
>  #include "monitor/monitor.h"
>  #include "block/nbd.h"
>  #include "block/block_int.h"
>  #include "block/block-hmp-commands.h"
> +#include "block/qapi.h"
>  #include "monitor/hmp.h"
>  #include "qemu-io.h"
>  
> @@ -553,3 +555,389 @@ fail:
>      blk_unref(local_blk);
>      hmp_handle_error(mon, err);
>  }
> +
> +static void print_block_info(Monitor *mon, BlockInfo *info,
> +                             BlockDeviceInfo *inserted, bool verbose)
> +{
> +    ImageInfo *image_info;
> +
> +    assert(!info || !info->has_inserted || info->inserted == inserted);
> +
> +    if (info && *info->device) {
> +        monitor_printf(mon, "%s", info->device);
> +        if (inserted && inserted->has_node_name) {
> +            monitor_printf(mon, " (%s)", inserted->node_name);
> +        }
> +    } else {
> +        assert(info || inserted);
> +        monitor_printf(mon, "%s",
> +                       inserted && inserted->has_node_name ? inserted->node_name
> +                       : info && info->has_qdev ? info->qdev
> +                       : "<anonymous>");
> +    }
> +
> +    if (inserted) {
> +        monitor_printf(mon, ": %s (%s%s%s)\n",
> +                       inserted->file,
> +                       inserted->drv,
> +                       inserted->ro ? ", read-only" : "",
> +                       inserted->encrypted ? ", encrypted" : "");
> +    } else {
> +        monitor_printf(mon, ": [not inserted]\n");
> +    }
> +
> +    if (info) {
> +        if (info->has_qdev) {
> +            monitor_printf(mon, "    Attached to:      %s\n", info->qdev);
> +        }
> +        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
> +            monitor_printf(mon, "    I/O status:       %s\n",
> +                           BlockDeviceIoStatus_str(info->io_status));
> +        }
> +
> +        if (info->removable) {
> +            monitor_printf(mon, "    Removable device: %slocked, tray %s\n",
> +                           info->locked ? "" : "not ",
> +                           info->tray_open ? "open" : "closed");
> +        }
> +    }
> +
> +
> +    if (!inserted) {
> +        return;
> +    }
> +
> +    monitor_printf(mon, "    Cache mode:       %s%s%s\n",
> +                   inserted->cache->writeback ? "writeback" : "writethrough",
> +                   inserted->cache->direct ? ", direct" : "",
> +                   inserted->cache->no_flush ? ", ignore flushes" : "");
> +
> +    if (inserted->has_backing_file) {
> +        monitor_printf(mon,
> +                       "    Backing file:     %s "
> +                       "(chain depth: %" PRId64 ")\n",
> +                       inserted->backing_file,
> +                       inserted->backing_file_depth);
> +    }
> +
> +    if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
> +        monitor_printf(mon, "    Detect zeroes:    %s\n",
> +                BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
> +    }
> +
> +    if (inserted->bps  || inserted->bps_rd  || inserted->bps_wr  ||
> +        inserted->iops || inserted->iops_rd || inserted->iops_wr)
> +    {
> +        monitor_printf(mon, "    I/O throttling:   bps=%" PRId64
> +                        " bps_rd=%" PRId64  " bps_wr=%" PRId64
> +                        " bps_max=%" PRId64
> +                        " bps_rd_max=%" PRId64
> +                        " bps_wr_max=%" PRId64
> +                        " iops=%" PRId64 " iops_rd=%" PRId64
> +                        " iops_wr=%" PRId64
> +                        " iops_max=%" PRId64
> +                        " iops_rd_max=%" PRId64
> +                        " iops_wr_max=%" PRId64
> +                        " iops_size=%" PRId64
> +                        " group=%s\n",
> +                        inserted->bps,
> +                        inserted->bps_rd,
> +                        inserted->bps_wr,
> +                        inserted->bps_max,
> +                        inserted->bps_rd_max,
> +                        inserted->bps_wr_max,
> +                        inserted->iops,
> +                        inserted->iops_rd,
> +                        inserted->iops_wr,
> +                        inserted->iops_max,
> +                        inserted->iops_rd_max,
> +                        inserted->iops_wr_max,
> +                        inserted->iops_size,
> +                        inserted->group);
> +    }
> +
> +    if (verbose) {
> +        monitor_printf(mon, "\nImages:\n");
> +        image_info = inserted->image;
> +        while (1) {
> +                bdrv_image_info_dump(image_info);
> +            if (image_info->has_backing_image) {
> +                image_info = image_info->backing_image;
> +            } else {
> +                break;
> +            }
> +        }
> +    }
> +}
> +
> +void hmp_info_block(Monitor *mon, const QDict *qdict)
> +{
> +    BlockInfoList *block_list, *info;
> +    BlockDeviceInfoList *blockdev_list, *blockdev;
> +    const char *device = qdict_get_try_str(qdict, "device");
> +    bool verbose = qdict_get_try_bool(qdict, "verbose", false);
> +    bool nodes = qdict_get_try_bool(qdict, "nodes", false);
> +    bool printed = false;
> +
> +    /* Print BlockBackend information */
> +    if (!nodes) {
> +        block_list = qmp_query_block(NULL);
> +    } else {
> +        block_list = NULL;
> +    }
> +
> +    for (info = block_list; info; info = info->next) {
> +        if (device && strcmp(device, info->value->device)) {
> +            continue;
> +        }
> +
> +        if (info != block_list) {
> +            monitor_printf(mon, "\n");
> +        }
> +
> +        print_block_info(mon, info->value, info->value->has_inserted
> +                                           ? info->value->inserted : NULL,
> +                         verbose);
> +        printed = true;
> +    }
> +
> +    qapi_free_BlockInfoList(block_list);
> +
> +    if ((!device && !nodes) || printed) {
> +        return;
> +    }
> +
> +    /* Print node information */
> +    blockdev_list = qmp_query_named_block_nodes(NULL);
> +    for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
> +        assert(blockdev->value->has_node_name);
> +        if (device && strcmp(device, blockdev->value->node_name)) {
> +            continue;
> +        }
> +
> +        if (blockdev != blockdev_list) {
> +            monitor_printf(mon, "\n");
> +        }
> +
> +        print_block_info(mon, NULL, blockdev->value, verbose);
> +    }
> +    qapi_free_BlockDeviceInfoList(blockdev_list);
> +}
> +
> +void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
> +{
> +    BlockStatsList *stats_list, *stats;
> +
> +    stats_list = qmp_query_blockstats(false, false, NULL);
> +
> +    for (stats = stats_list; stats; stats = stats->next) {
> +        if (!stats->value->has_device) {
> +            continue;
> +        }
> +
> +        monitor_printf(mon, "%s:", stats->value->device);
> +        monitor_printf(mon, " rd_bytes=%" PRId64
> +                       " wr_bytes=%" PRId64
> +                       " rd_operations=%" PRId64
> +                       " wr_operations=%" PRId64
> +                       " flush_operations=%" PRId64
> +                       " wr_total_time_ns=%" PRId64
> +                       " rd_total_time_ns=%" PRId64
> +                       " flush_total_time_ns=%" PRId64
> +                       " rd_merged=%" PRId64
> +                       " wr_merged=%" PRId64
> +                       " idle_time_ns=%" PRId64
> +                       "\n",
> +                       stats->value->stats->rd_bytes,
> +                       stats->value->stats->wr_bytes,
> +                       stats->value->stats->rd_operations,
> +                       stats->value->stats->wr_operations,
> +                       stats->value->stats->flush_operations,
> +                       stats->value->stats->wr_total_time_ns,
> +                       stats->value->stats->rd_total_time_ns,
> +                       stats->value->stats->flush_total_time_ns,
> +                       stats->value->stats->rd_merged,
> +                       stats->value->stats->wr_merged,
> +                       stats->value->stats->idle_time_ns);
> +    }
> +
> +    qapi_free_BlockStatsList(stats_list);
> +}
> +
> +void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
> +{
> +    BlockJobInfoList *list;
> +    Error *err = NULL;
> +
> +    list = qmp_query_block_jobs(&err);
> +    assert(!err);
> +
> +    if (!list) {
> +        monitor_printf(mon, "No active jobs\n");
> +        return;
> +    }
> +
> +    while (list) {
> +        if (strcmp(list->value->type, "stream") == 0) {
> +            monitor_printf(mon, "Streaming device %s: Completed %" PRId64
> +                           " of %" PRId64 " bytes, speed limit %" PRId64
> +                           " bytes/s\n",
> +                           list->value->device,
> +                           list->value->offset,
> +                           list->value->len,
> +                           list->value->speed);
> +        } else {
> +            monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
> +                           " of %" PRId64 " bytes, speed limit %" PRId64
> +                           " bytes/s\n",
> +                           list->value->type,
> +                           list->value->device,
> +                           list->value->offset,
> +                           list->value->len,
> +                           list->value->speed);
> +        }
> +        list = list->next;
> +    }
> +
> +    qapi_free_BlockJobInfoList(list);
> +}
> +
> +void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
> +{
> +    BlockDriverState *bs, *bs1;
> +    BdrvNextIterator it1;
> +    QEMUSnapshotInfo *sn_tab, *sn;
> +    bool no_snapshot = true;
> +    int nb_sns, i;
> +    int total;
> +    int *global_snapshots;
> +    AioContext *aio_context;
> +
> +    typedef struct SnapshotEntry {
> +        QEMUSnapshotInfo sn;
> +        QTAILQ_ENTRY(SnapshotEntry) next;
> +    } SnapshotEntry;
> +
> +    typedef struct ImageEntry {
> +        const char *imagename;
> +        QTAILQ_ENTRY(ImageEntry) next;
> +        QTAILQ_HEAD(, SnapshotEntry) snapshots;
> +    } ImageEntry;
> +
> +    QTAILQ_HEAD(, ImageEntry) image_list =
> +        QTAILQ_HEAD_INITIALIZER(image_list);
> +
> +    ImageEntry *image_entry, *next_ie;
> +    SnapshotEntry *snapshot_entry;
> +
> +    bs = bdrv_all_find_vmstate_bs();
> +    if (!bs) {
> +        monitor_printf(mon, "No available block device supports snapshots\n");
> +        return;
> +    }
> +    aio_context = bdrv_get_aio_context(bs);
> +
> +    aio_context_acquire(aio_context);
> +    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
> +    aio_context_release(aio_context);
> +
> +    if (nb_sns < 0) {
> +        monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
> +        return;
> +    }
> +
> +    for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) {
> +        int bs1_nb_sns = 0;
> +        ImageEntry *ie;
> +        SnapshotEntry *se;
> +        AioContext *ctx = bdrv_get_aio_context(bs1);
> +
> +        aio_context_acquire(ctx);
> +        if (bdrv_can_snapshot(bs1)) {
> +            sn = NULL;
> +            bs1_nb_sns = bdrv_snapshot_list(bs1, &sn);
> +            if (bs1_nb_sns > 0) {
> +                no_snapshot = false;
> +                ie = g_new0(ImageEntry, 1);
> +                ie->imagename = bdrv_get_device_name(bs1);
> +                QTAILQ_INIT(&ie->snapshots);
> +                QTAILQ_INSERT_TAIL(&image_list, ie, next);
> +                for (i = 0; i < bs1_nb_sns; i++) {
> +                    se = g_new0(SnapshotEntry, 1);
> +                    se->sn = sn[i];
> +                    QTAILQ_INSERT_TAIL(&ie->snapshots, se, next);
> +                }
> +            }
> +            g_free(sn);
> +        }
> +        aio_context_release(ctx);
> +    }
> +
> +    if (no_snapshot) {
> +        monitor_printf(mon, "There is no snapshot available.\n");
> +        return;
> +    }
> +
> +    global_snapshots = g_new0(int, nb_sns);
> +    total = 0;
> +    for (i = 0; i < nb_sns; i++) {
> +        SnapshotEntry *next_sn;
> +        if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) {
> +            global_snapshots[total] = i;
> +            total++;
> +            QTAILQ_FOREACH(image_entry, &image_list, next) {
> +                QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots,
> +                                    next, next_sn) {
> +                    if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) {
> +                        QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry,
> +                                      next);
> +                        g_free(snapshot_entry);
> +                    }
> +                }
> +            }
> +        }
> +    }
> +    monitor_printf(mon, "List of snapshots present on all disks:\n");
> +
> +    if (total > 0) {
> +        bdrv_snapshot_dump(NULL);
> +        monitor_printf(mon, "\n");
> +        for (i = 0; i < total; i++) {
> +            sn = &sn_tab[global_snapshots[i]];
> +            /* The ID is not guaranteed to be the same on all images, so
> +             * overwrite it.
> +             */
> +            pstrcpy(sn->id_str, sizeof(sn->id_str), "--");
> +            bdrv_snapshot_dump(sn);
> +            monitor_printf(mon, "\n");
> +        }
> +    } else {
> +        monitor_printf(mon, "None\n");
> +    }
> +
> +    QTAILQ_FOREACH(image_entry, &image_list, next) {
> +        if (QTAILQ_EMPTY(&image_entry->snapshots)) {
> +            continue;
> +        }
> +        monitor_printf(mon,
> +                       "\nList of partial (non-loadable) snapshots on '%s':\n",
> +                       image_entry->imagename);
> +        bdrv_snapshot_dump(NULL);
> +        monitor_printf(mon, "\n");
> +        QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) {
> +            bdrv_snapshot_dump(&snapshot_entry->sn);
> +            monitor_printf(mon, "\n");
> +        }
> +    }
> +
> +    QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) {
> +        SnapshotEntry *next_sn;
> +        QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next,
> +                            next_sn) {
> +            g_free(snapshot_entry);
> +        }
> +        g_free(image_entry);
> +    }
> +    g_free(sn_tab);
> +    g_free(global_snapshots);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index 99145c8fcf..206635ffed 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -34,5 +34,9 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
>  
>  void hmp_qemu_io(Monitor *mon, const QDict *qdict);
>  
> +void hmp_info_block(Monitor *mon, const QDict *qdict);
> +void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
> +void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
> +void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
>  
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 47a7cad734..e33ca5a911 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -30,8 +30,6 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
>  void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
>  void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
>  void hmp_info_cpus(Monitor *mon, const QDict *qdict);
> -void hmp_info_block(Monitor *mon, const QDict *qdict);
> -void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
>  void hmp_info_vnc(Monitor *mon, const QDict *qdict);
>  void hmp_info_spice(Monitor *mon, const QDict *qdict);
>  void hmp_info_balloon(Monitor *mon, const QDict *qdict);
> @@ -39,7 +37,6 @@ void hmp_info_irq(Monitor *mon, const QDict *qdict);
>  void hmp_info_pic(Monitor *mon, const QDict *qdict);
>  void hmp_info_rdma(Monitor *mon, const QDict *qdict);
>  void hmp_info_pci(Monitor *mon, const QDict *qdict);
> -void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
>  void hmp_info_tpm(Monitor *mon, const QDict *qdict);
>  void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
>  void hmp_quit(Monitor *mon, const QDict *qdict);
> @@ -62,7 +59,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> -void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_continue(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_incoming(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index c224e0f338..1ddfe2fceb 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -45,7 +45,6 @@
>  #include "qapi/string-output-visitor.h"
>  #include "qom/object_interfaces.h"
>  #include "ui/console.h"
> -#include "block/qapi.h"
>  #include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "exec/ramlist.h"
> @@ -465,213 +464,6 @@ void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict)
>                     qmp_query_migrate_cache_size(NULL) >> 10);
>  }
>  
> -static void print_block_info(Monitor *mon, BlockInfo *info,
> -                             BlockDeviceInfo *inserted, bool verbose)
> -{
> -    ImageInfo *image_info;
> -
> -    assert(!info || !info->has_inserted || info->inserted == inserted);
> -
> -    if (info && *info->device) {
> -        monitor_printf(mon, "%s", info->device);
> -        if (inserted && inserted->has_node_name) {
> -            monitor_printf(mon, " (%s)", inserted->node_name);
> -        }
> -    } else {
> -        assert(info || inserted);
> -        monitor_printf(mon, "%s",
> -                       inserted && inserted->has_node_name ? inserted->node_name
> -                       : info && info->has_qdev ? info->qdev
> -                       : "<anonymous>");
> -    }
> -
> -    if (inserted) {
> -        monitor_printf(mon, ": %s (%s%s%s)\n",
> -                       inserted->file,
> -                       inserted->drv,
> -                       inserted->ro ? ", read-only" : "",
> -                       inserted->encrypted ? ", encrypted" : "");
> -    } else {
> -        monitor_printf(mon, ": [not inserted]\n");
> -    }
> -
> -    if (info) {
> -        if (info->has_qdev) {
> -            monitor_printf(mon, "    Attached to:      %s\n", info->qdev);
> -        }
> -        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
> -            monitor_printf(mon, "    I/O status:       %s\n",
> -                           BlockDeviceIoStatus_str(info->io_status));
> -        }
> -
> -        if (info->removable) {
> -            monitor_printf(mon, "    Removable device: %slocked, tray %s\n",
> -                           info->locked ? "" : "not ",
> -                           info->tray_open ? "open" : "closed");
> -        }
> -    }
> -
> -
> -    if (!inserted) {
> -        return;
> -    }
> -
> -    monitor_printf(mon, "    Cache mode:       %s%s%s\n",
> -                   inserted->cache->writeback ? "writeback" : "writethrough",
> -                   inserted->cache->direct ? ", direct" : "",
> -                   inserted->cache->no_flush ? ", ignore flushes" : "");
> -
> -    if (inserted->has_backing_file) {
> -        monitor_printf(mon,
> -                       "    Backing file:     %s "
> -                       "(chain depth: %" PRId64 ")\n",
> -                       inserted->backing_file,
> -                       inserted->backing_file_depth);
> -    }
> -
> -    if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
> -        monitor_printf(mon, "    Detect zeroes:    %s\n",
> -                BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
> -    }
> -
> -    if (inserted->bps  || inserted->bps_rd  || inserted->bps_wr  ||
> -        inserted->iops || inserted->iops_rd || inserted->iops_wr)
> -    {
> -        monitor_printf(mon, "    I/O throttling:   bps=%" PRId64
> -                        " bps_rd=%" PRId64  " bps_wr=%" PRId64
> -                        " bps_max=%" PRId64
> -                        " bps_rd_max=%" PRId64
> -                        " bps_wr_max=%" PRId64
> -                        " iops=%" PRId64 " iops_rd=%" PRId64
> -                        " iops_wr=%" PRId64
> -                        " iops_max=%" PRId64
> -                        " iops_rd_max=%" PRId64
> -                        " iops_wr_max=%" PRId64
> -                        " iops_size=%" PRId64
> -                        " group=%s\n",
> -                        inserted->bps,
> -                        inserted->bps_rd,
> -                        inserted->bps_wr,
> -                        inserted->bps_max,
> -                        inserted->bps_rd_max,
> -                        inserted->bps_wr_max,
> -                        inserted->iops,
> -                        inserted->iops_rd,
> -                        inserted->iops_wr,
> -                        inserted->iops_max,
> -                        inserted->iops_rd_max,
> -                        inserted->iops_wr_max,
> -                        inserted->iops_size,
> -                        inserted->group);
> -    }
> -
> -    if (verbose) {
> -        monitor_printf(mon, "\nImages:\n");
> -        image_info = inserted->image;
> -        while (1) {
> -                bdrv_image_info_dump(image_info);
> -            if (image_info->has_backing_image) {
> -                image_info = image_info->backing_image;
> -            } else {
> -                break;
> -            }
> -        }
> -    }
> -}
> -
> -void hmp_info_block(Monitor *mon, const QDict *qdict)
> -{
> -    BlockInfoList *block_list, *info;
> -    BlockDeviceInfoList *blockdev_list, *blockdev;
> -    const char *device = qdict_get_try_str(qdict, "device");
> -    bool verbose = qdict_get_try_bool(qdict, "verbose", false);
> -    bool nodes = qdict_get_try_bool(qdict, "nodes", false);
> -    bool printed = false;
> -
> -    /* Print BlockBackend information */
> -    if (!nodes) {
> -        block_list = qmp_query_block(NULL);
> -    } else {
> -        block_list = NULL;
> -    }
> -
> -    for (info = block_list; info; info = info->next) {
> -        if (device && strcmp(device, info->value->device)) {
> -            continue;
> -        }
> -
> -        if (info != block_list) {
> -            monitor_printf(mon, "\n");
> -        }
> -
> -        print_block_info(mon, info->value, info->value->has_inserted
> -                                           ? info->value->inserted : NULL,
> -                         verbose);
> -        printed = true;
> -    }
> -
> -    qapi_free_BlockInfoList(block_list);
> -
> -    if ((!device && !nodes) || printed) {
> -        return;
> -    }
> -
> -    /* Print node information */
> -    blockdev_list = qmp_query_named_block_nodes(NULL);
> -    for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
> -        assert(blockdev->value->has_node_name);
> -        if (device && strcmp(device, blockdev->value->node_name)) {
> -            continue;
> -        }
> -
> -        if (blockdev != blockdev_list) {
> -            monitor_printf(mon, "\n");
> -        }
> -
> -        print_block_info(mon, NULL, blockdev->value, verbose);
> -    }
> -    qapi_free_BlockDeviceInfoList(blockdev_list);
> -}
> -
> -void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
> -{
> -    BlockStatsList *stats_list, *stats;
> -
> -    stats_list = qmp_query_blockstats(false, false, NULL);
> -
> -    for (stats = stats_list; stats; stats = stats->next) {
> -        if (!stats->value->has_device) {
> -            continue;
> -        }
> -
> -        monitor_printf(mon, "%s:", stats->value->device);
> -        monitor_printf(mon, " rd_bytes=%" PRId64
> -                       " wr_bytes=%" PRId64
> -                       " rd_operations=%" PRId64
> -                       " wr_operations=%" PRId64
> -                       " flush_operations=%" PRId64
> -                       " wr_total_time_ns=%" PRId64
> -                       " rd_total_time_ns=%" PRId64
> -                       " flush_total_time_ns=%" PRId64
> -                       " rd_merged=%" PRId64
> -                       " wr_merged=%" PRId64
> -                       " idle_time_ns=%" PRId64
> -                       "\n",
> -                       stats->value->stats->rd_bytes,
> -                       stats->value->stats->wr_bytes,
> -                       stats->value->stats->rd_operations,
> -                       stats->value->stats->wr_operations,
> -                       stats->value->stats->flush_operations,
> -                       stats->value->stats->wr_total_time_ns,
> -                       stats->value->stats->rd_total_time_ns,
> -                       stats->value->stats->flush_total_time_ns,
> -                       stats->value->stats->rd_merged,
> -                       stats->value->stats->wr_merged,
> -                       stats->value->stats->idle_time_ns);
> -    }
> -
> -    qapi_free_BlockStatsList(stats_list);
> -}
>  
>  #ifdef CONFIG_VNC
>  /* Helper for hmp_info_vnc_clients, _servers */
> @@ -1051,44 +843,6 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict)
>      qapi_free_PciInfoList(info_list);
>  }
>  
> -void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
> -{
> -    BlockJobInfoList *list;
> -    Error *err = NULL;
> -
> -    list = qmp_query_block_jobs(&err);
> -    assert(!err);
> -
> -    if (!list) {
> -        monitor_printf(mon, "No active jobs\n");
> -        return;
> -    }
> -
> -    while (list) {
> -        if (strcmp(list->value->type, "stream") == 0) {
> -            monitor_printf(mon, "Streaming device %s: Completed %" PRId64
> -                           " of %" PRId64 " bytes, speed limit %" PRId64
> -                           " bytes/s\n",
> -                           list->value->device,
> -                           list->value->offset,
> -                           list->value->len,
> -                           list->value->speed);
> -        } else {
> -            monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
> -                           " of %" PRId64 " bytes, speed limit %" PRId64
> -                           " bytes/s\n",
> -                           list->value->type,
> -                           list->value->device,
> -                           list->value->offset,
> -                           list->value->len,
> -                           list->value->speed);
> -        }
> -        list = list->next;
> -    }
> -
> -    qapi_free_BlockJobInfoList(list);
> -}
> -
>  void hmp_info_tpm(Monitor *mon, const QDict *qdict)
>  {
>      TPMInfoList *info_list, *info;
> @@ -1351,148 +1105,6 @@ void hmp_delvm(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
> -{
> -    BlockDriverState *bs, *bs1;
> -    BdrvNextIterator it1;
> -    QEMUSnapshotInfo *sn_tab, *sn;
> -    bool no_snapshot = true;
> -    int nb_sns, i;
> -    int total;
> -    int *global_snapshots;
> -    AioContext *aio_context;
> -
> -    typedef struct SnapshotEntry {
> -        QEMUSnapshotInfo sn;
> -        QTAILQ_ENTRY(SnapshotEntry) next;
> -    } SnapshotEntry;
> -
> -    typedef struct ImageEntry {
> -        const char *imagename;
> -        QTAILQ_ENTRY(ImageEntry) next;
> -        QTAILQ_HEAD(, SnapshotEntry) snapshots;
> -    } ImageEntry;
> -
> -    QTAILQ_HEAD(, ImageEntry) image_list =
> -        QTAILQ_HEAD_INITIALIZER(image_list);
> -
> -    ImageEntry *image_entry, *next_ie;
> -    SnapshotEntry *snapshot_entry;
> -
> -    bs = bdrv_all_find_vmstate_bs();
> -    if (!bs) {
> -        monitor_printf(mon, "No available block device supports snapshots\n");
> -        return;
> -    }
> -    aio_context = bdrv_get_aio_context(bs);
> -
> -    aio_context_acquire(aio_context);
> -    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
> -    aio_context_release(aio_context);
> -
> -    if (nb_sns < 0) {
> -        monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
> -        return;
> -    }
> -
> -    for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) {
> -        int bs1_nb_sns = 0;
> -        ImageEntry *ie;
> -        SnapshotEntry *se;
> -        AioContext *ctx = bdrv_get_aio_context(bs1);
> -
> -        aio_context_acquire(ctx);
> -        if (bdrv_can_snapshot(bs1)) {
> -            sn = NULL;
> -            bs1_nb_sns = bdrv_snapshot_list(bs1, &sn);
> -            if (bs1_nb_sns > 0) {
> -                no_snapshot = false;
> -                ie = g_new0(ImageEntry, 1);
> -                ie->imagename = bdrv_get_device_name(bs1);
> -                QTAILQ_INIT(&ie->snapshots);
> -                QTAILQ_INSERT_TAIL(&image_list, ie, next);
> -                for (i = 0; i < bs1_nb_sns; i++) {
> -                    se = g_new0(SnapshotEntry, 1);
> -                    se->sn = sn[i];
> -                    QTAILQ_INSERT_TAIL(&ie->snapshots, se, next);
> -                }
> -            }
> -            g_free(sn);
> -        }
> -        aio_context_release(ctx);
> -    }
> -
> -    if (no_snapshot) {
> -        monitor_printf(mon, "There is no snapshot available.\n");
> -        return;
> -    }
> -
> -    global_snapshots = g_new0(int, nb_sns);
> -    total = 0;
> -    for (i = 0; i < nb_sns; i++) {
> -        SnapshotEntry *next_sn;
> -        if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) {
> -            global_snapshots[total] = i;
> -            total++;
> -            QTAILQ_FOREACH(image_entry, &image_list, next) {
> -                QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots,
> -                                    next, next_sn) {
> -                    if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) {
> -                        QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry,
> -                                      next);
> -                        g_free(snapshot_entry);
> -                    }
> -                }
> -            }
> -        }
> -    }
> -
> -    monitor_printf(mon, "List of snapshots present on all disks:\n");
> -
> -    if (total > 0) {
> -        bdrv_snapshot_dump(NULL);
> -        monitor_printf(mon, "\n");
> -        for (i = 0; i < total; i++) {
> -            sn = &sn_tab[global_snapshots[i]];
> -            /* The ID is not guaranteed to be the same on all images, so
> -             * overwrite it.
> -             */
> -            pstrcpy(sn->id_str, sizeof(sn->id_str), "--");
> -            bdrv_snapshot_dump(sn);
> -            monitor_printf(mon, "\n");
> -        }
> -    } else {
> -        monitor_printf(mon, "None\n");
> -    }
> -
> -    QTAILQ_FOREACH(image_entry, &image_list, next) {
> -        if (QTAILQ_EMPTY(&image_entry->snapshots)) {
> -            continue;
> -        }
> -        monitor_printf(mon,
> -                       "\nList of partial (non-loadable) snapshots on '%s':\n",
> -                       image_entry->imagename);
> -        bdrv_snapshot_dump(NULL);
> -        monitor_printf(mon, "\n");
> -        QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) {
> -            bdrv_snapshot_dump(&snapshot_entry->sn);
> -            monitor_printf(mon, "\n");
> -        }
> -    }
> -
> -    QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) {
> -        SnapshotEntry *next_sn;
> -        QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next,
> -                            next_sn) {
> -            g_free(snapshot_entry);
> -        }
> -        g_free(image_entry);
> -    }
> -    g_free(sn_tab);
> -    g_free(global_snapshots);
> -
> -}
> -
>  void hmp_announce_self(Monitor *mon, const QDict *qdict)
>  {
>      const char *interfaces_str = qdict_get_try_str(qdict, "interfaces");
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 11/13] monitor: Move hmp_drive_add_node to block-hmp-cmds.c
  2020-01-27 10:36 ` [PATCH v3 11/13] monitor: Move hmp_drive_add_node " Maxim Levitsky
@ 2020-01-28 19:03   ` Dr. David Alan Gilbert
  2020-01-28 19:30     ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-28 19:03 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Looks OK to me, I'm not clear on the name for 'bdrv_set_monitor_owned'
I'd want a block person to OK that, but:


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c | 30 ++++++++++++++++++++++++
>  blockdev.c                     | 42 +++++++---------------------------
>  include/block/block_int.h      |  5 ++--
>  3 files changed, 41 insertions(+), 36 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index a4b1604aee..7bbe4e3814 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -33,6 +33,36 @@
>  #include "monitor/hmp.h"
>  #include "qemu-io.h"
>  
> +static void hmp_drive_add_node(Monitor *mon, const char *optstr)
> +{
> +    QemuOpts *opts;
> +    QDict *qdict;
> +    Error *local_err = NULL;
> +
> +    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
> +    if (!opts) {
> +        return;
> +    }
> +
> +    qdict = qemu_opts_to_qdict(opts, NULL);
> +
> +    if (!qdict_get_try_str(qdict, "node-name")) {
> +        qobject_unref(qdict);
> +        error_report("'node-name' needs to be specified");
> +        goto out;
> +    }
> +
> +    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
> +    if (!bs) {
> +        error_report_err(local_err);
> +        goto out;
> +    }
> +
> +    bdrv_set_monitor_owned(bs);
> +out:
> +    qemu_opts_del(opts);
> +}
> +
>  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
> diff --git a/blockdev.c b/blockdev.c
> index df43e0aaef..63805f34b5 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -64,7 +64,7 @@
>  #include "qemu/main-loop.h"
>  #include "qemu/throttle-options.h"
>  
> -static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
> +QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
>      QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
>  
>  static int do_open_tray(const char *blk_name, const char *qdev_id,
> @@ -75,6 +75,11 @@ static void blockdev_insert_medium(bool has_device, const char *device,
>                                     bool has_id, const char *id,
>                                     const char *node_name, Error **errp);
>  
> +void bdrv_set_monitor_owned(BlockDriverState *bs)
> +{
> +    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> +}
> +
>  static const char *const if_name[IF_COUNT] = {
>      [IF_NONE] = "none",
>      [IF_IDE] = "ide",
> @@ -652,7 +657,7 @@ err_no_opts:
>  }
>  
>  /* Takes the ownership of bs_opts */
> -static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
> +BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
>  {
>      int bdrv_flags = 0;
>  
> @@ -4201,37 +4206,6 @@ out:
>      aio_context_release(aio_context);
>  }
>  
> -void hmp_drive_add_node(Monitor *mon, const char *optstr)
> -{
> -    QemuOpts *opts;
> -    QDict *qdict;
> -    Error *local_err = NULL;
> -
> -    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
> -    if (!opts) {
> -        return;
> -    }
> -
> -    qdict = qemu_opts_to_qdict(opts, NULL);
> -
> -    if (!qdict_get_try_str(qdict, "node-name")) {
> -        qobject_unref(qdict);
> -        error_report("'node-name' needs to be specified");
> -        goto out;
> -    }
> -
> -    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
> -    if (!bs) {
> -        error_report_err(local_err);
> -        goto out;
> -    }
> -
> -    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> -
> -out:
> -    qemu_opts_del(opts);
> -}
> -
>  void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
>  {
>      BlockDriverState *bs;
> @@ -4261,7 +4235,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
>          goto fail;
>      }
>  
> -    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> +    bdrv_set_monitor_owned(bs);
>  
>  fail:
>      visit_free(v);
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index dd033d0b37..10df257a61 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -1217,8 +1217,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
>                              BlockCompletionFunc *cb, void *opaque,
>                              JobTxn *txn, Error **errp);
>  
> -void hmp_drive_add_node(Monitor *mon, const char *optstr);
> -
>  BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
>                                    const char *child_name,
>                                    const BdrvChildRole *child_role,
> @@ -1320,4 +1318,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
>  
>  int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
>  
> +void bdrv_set_monitor_owned(BlockDriverState *bs);
> +BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp);
> +
>  #endif /* BLOCK_INT_H */
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  2020-01-28 16:56   ` Dr. David Alan Gilbert
@ 2020-01-28 19:28     ` Maxim Levitsky
  2020-01-29 10:19       ` Markus Armbruster
  0 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-28 19:28 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

On Tue, 2020-01-28 at 16:56 +0000, Dr. David Alan Gilbert wrote:
> * Maxim Levitsky (mlevitsk@redhat.com) wrote:
> > These days device-hotplug.c only contains the hmp_drive_add
> > In the next patch, rest of hmp_drive* functions will be moved
> > there.
> > 
> > Also change the license of that file to GPL2+ since most
> > of the code that will be moved there is under that license
> 
> How do we check that's OK?

Currently that code is BSD licensed, and in next patches I will move
here GPLv2+ code, and as far as I know combining them gives you GPLv2+

I wasn't even aware that we have mixed licenses, and so this change was done
after Markus pointed this out in the previous patchset review.

Best regards,
	Maxim Levitsky

> 
> > Also add block-hmp-commands.h to contain prototypes of these
> > functions
> > 
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > ---
> >  MAINTAINERS                                   |  1 +
> >  Makefile.objs                                 |  2 +-
> >  block/Makefile.objs                           |  1 +
> >  block/monitor/Makefile.objs                   |  1 +
> >  .../monitor/block-hmp-cmds.c                  | 23 ++++---------------
> >  include/block/block-hmp-commands.h            |  8 +++++++
> >  include/sysemu/sysemu.h                       |  3 ---
> >  monitor/misc.c                                |  1 +
> >  8 files changed, 18 insertions(+), 22 deletions(-)
> >  create mode 100644 block/monitor/Makefile.objs
> >  rename device-hotplug.c => block/monitor/block-hmp-cmds.c (55%)
> >  create mode 100644 include/block/block-hmp-commands.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index f6511d5120..5d50d09ad8 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -1882,6 +1882,7 @@ Block QAPI, monitor, command line
> >  M: Markus Armbruster <armbru@redhat.com>
> >  S: Supported
> >  F: blockdev.c
> > +F: blockdev-hmp-cmds.c
> >  F: block/qapi.c
> >  F: qapi/block*.json
> >  F: qapi/transaction.json
> > diff --git a/Makefile.objs b/Makefile.objs
> > index ff396b9209..15209eb6b5 100644
> > --- a/Makefile.objs
> > +++ b/Makefile.objs
> > @@ -48,7 +48,7 @@ common-obj-y += dump/
> >  common-obj-y += job-qmp.o
> >  common-obj-y += monitor/
> >  common-obj-y += net/
> > -common-obj-y += qdev-monitor.o device-hotplug.o
> > +common-obj-y += qdev-monitor.o
> >  common-obj-$(CONFIG_WIN32) += os-win32.o
> >  common-obj-$(CONFIG_POSIX) += os-posix.o
> >  
> > diff --git a/block/Makefile.objs b/block/Makefile.objs
> > index 330529b0b7..3f65544a6b 100644
> > --- a/block/Makefile.objs
> > +++ b/block/Makefile.objs
> > @@ -44,6 +44,7 @@ block-obj-y += crypto.o
> >  block-obj-y += aio_task.o
> >  block-obj-y += backup-top.o
> >  block-obj-y += filter-compress.o
> > +common-obj-y += monitor/
> >  
> >  common-obj-y += stream.o
> >  
> > diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs
> > new file mode 100644
> > index 0000000000..0a74f9a8b5
> > --- /dev/null
> > +++ b/block/monitor/Makefile.objs
> > @@ -0,0 +1 @@
> > +common-obj-y += block-hmp-cmds.o
> > diff --git a/device-hotplug.c b/block/monitor/block-hmp-cmds.c
> > similarity index 55%
> > rename from device-hotplug.c
> > rename to block/monitor/block-hmp-cmds.c
> > index 554e4d98db..c65aaa86ea 100644
> > --- a/device-hotplug.c
> > +++ b/block/monitor/block-hmp-cmds.c
> > @@ -1,25 +1,11 @@
> >  /*
> > - * QEMU device hotplug helpers
> > + * Blockdev HMP commands
> >   *
> >   * Copyright (c) 2004 Fabrice Bellard
> >   *
> > - * Permission is hereby granted, free of charge, to any person obtaining a copy
> > - * of this software and associated documentation files (the "Software"), to deal
> > - * in the Software without restriction, including without limitation the rights
> > - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > - * copies of the Software, and to permit persons to whom the Software is
> > - * furnished to do so, subject to the following conditions:
> > - *
> > - * The above copyright notice and this permission notice shall be included in
> > - * all copies or substantial portions of the Software.
> > - *
> > - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > - * THE SOFTWARE.
> > + * This work is licensed under the terms of the GNU GPL, version 2.
> > + * or (at your option) any later version.
> > + * See the COPYING file in the top-level directory.
> >   */
> >  
> >  #include "qemu/osdep.h"
> > @@ -33,6 +19,7 @@
> >  #include "sysemu/sysemu.h"
> >  #include "monitor/monitor.h"
> >  #include "block/block_int.h"
> > +#include "block/block-hmp-commands.h"
> >  
> >  
> >  void hmp_drive_add(Monitor *mon, const QDict *qdict)
> > diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> > new file mode 100644
> > index 0000000000..4f9033a8a6
> > --- /dev/null
> > +++ b/include/block/block-hmp-commands.h
> > @@ -0,0 +1,8 @@
> > +#ifndef BLOCK_HMP_COMMANDS_H
> > +#define BLOCK_HMP_COMMANDS_H
> > +
> > +/* HMP commands related to the block layer*/
> 
> Should this file get a copyright header as well?
> 
> > +
> > +void hmp_drive_add(Monitor *mon, const QDict *qdict);
> > +
> > +#endif
> > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> > index 80c57fdc4e..c48635666d 100644
> > --- a/include/sysemu/sysemu.h
> > +++ b/include/sysemu/sysemu.h
> > @@ -68,9 +68,6 @@ extern int nb_option_roms;
> >  extern const char *prom_envs[MAX_PROM_ENVS];
> >  extern unsigned int nb_prom_envs;
> >  
> > -/* generic hotplug */
> > -void hmp_drive_add(Monitor *mon, const QDict *qdict);
> > -
> >  /* pcie aer error injection */
> >  void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
> >  
> > diff --git a/monitor/misc.c b/monitor/misc.c
> > index de1ca4d114..0466c00830 100644
> > --- a/monitor/misc.c
> > +++ b/monitor/misc.c
> > @@ -79,6 +79,7 @@
> >  #include "sysemu/cpus.h"
> >  #include "qemu/cutils.h"
> >  #include "tcg/tcg.h"
> > +#include "block/block-hmp-commands.h"
> >  
> >  #if defined(TARGET_S390X)
> >  #include "hw/s390x/storage-keys.h"
> > -- 
> > 2.17.2
> > 
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c
  2020-01-28 17:51   ` Dr. David Alan Gilbert
@ 2020-01-28 19:29     ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-28 19:29 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

On Tue, 2020-01-28 at 17:51 +0000, Dr. David Alan Gilbert wrote:
> * Maxim Levitsky (mlevitsk@redhat.com) wrote:
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> (It's easier to compare if you keep the function order the same)

Sorry about that, next time I will do that.
Thanks a lot for the review!
Best regards,
	Maxim Levitsky
> 
> > ---
> >  block/monitor/block-hmp-cmds.c     | 97 +++++++++++++++++++++++++++++-
> >  blockdev.c                         | 95 -----------------------------
> >  include/block/block-hmp-commands.h |  3 +
> >  include/sysemu/blockdev.h          |  4 --
> >  4 files changed, 99 insertions(+), 100 deletions(-)
> > 
> > diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> > index c65aaa86ea..9614c67e77 100644
> > --- a/block/monitor/block-hmp-cmds.c
> > +++ b/block/monitor/block-hmp-cmds.c
> > @@ -12,6 +12,7 @@
> >  #include "hw/boards.h"
> >  #include "sysemu/block-backend.h"
> >  #include "sysemu/blockdev.h"
> > +#include "qapi/qapi-commands-block.h"
> >  #include "qapi/qmp/qdict.h"
> >  #include "qapi/error.h"
> >  #include "qemu/config-file.h"
> > @@ -21,7 +22,6 @@
> >  #include "block/block_int.h"
> >  #include "block/block-hmp-commands.h"
> >  
> > -
> >  void hmp_drive_add(Monitor *mon, const QDict *qdict)
> >  {
> >      Error *err = NULL;
> > @@ -69,3 +69,98 @@ err:
> >          blk_unref(blk);
> >      }
> >  }
> > +
> > +void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > +{
> > +    const char *id = qdict_get_str(qdict, "id");
> > +    BlockBackend *blk;
> > +    BlockDriverState *bs;
> > +    AioContext *aio_context;
> > +    Error *local_err = NULL;
> > +
> > +    bs = bdrv_find_node(id);
> > +    if (bs) {
> > +        qmp_blockdev_del(id, &local_err);
> > +        if (local_err) {
> > +            error_report_err(local_err);
> > +        }
> > +        return;
> > +    }
> > +
> > +    blk = blk_by_name(id);
> > +    if (!blk) {
> > +        error_report("Device '%s' not found", id);
> > +        return;
> > +    }
> > +
> > +    if (!blk_legacy_dinfo(blk)) {
> > +        error_report("Deleting device added with blockdev-add"
> > +                     " is not supported");
> > +        return;
> > +    }
> > +
> > +    aio_context = blk_get_aio_context(blk);
> > +    aio_context_acquire(aio_context);
> > +
> > +    bs = blk_bs(blk);
> > +    if (bs) {
> > +        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> > +            error_report_err(local_err);
> > +            aio_context_release(aio_context);
> > +            return;
> > +        }
> > +
> > +        blk_remove_bs(blk);
> > +    }
> > +
> > +    /* Make the BlockBackend and the attached BlockDriverState anonymous */
> > +    monitor_remove_blk(blk);
> > +
> > +    /* If this BlockBackend has a device attached to it, its refcount will be
> > +     * decremented when the device is removed; otherwise we have to do so here.
> > +     */
> > +    if (blk_get_attached_dev(blk)) {
> > +        /* Further I/O must not pause the guest */
> > +        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
> > +                         BLOCKDEV_ON_ERROR_REPORT);
> > +    } else {
> > +        blk_unref(blk);
> > +    }
> > +
> > +    aio_context_release(aio_context);
> > +}
> > +
> > +void hmp_commit(Monitor *mon, const QDict *qdict)
> > +{
> > +    const char *device = qdict_get_str(qdict, "device");
> > +    BlockBackend *blk;
> > +    int ret;
> > +
> > +    if (!strcmp(device, "all")) {
> > +        ret = blk_commit_all();
> > +    } else {
> > +        BlockDriverState *bs;
> > +        AioContext *aio_context;
> > +
> > +        blk = blk_by_name(device);
> > +        if (!blk) {
> > +            error_report("Device '%s' not found", device);
> > +            return;
> > +        }
> > +        if (!blk_is_available(blk)) {
> > +            error_report("Device '%s' has no medium", device);
> > +            return;
> > +        }
> > +
> > +        bs = blk_bs(blk);
> > +        aio_context = bdrv_get_aio_context(bs);
> > +        aio_context_acquire(aio_context);
> > +
> > +        ret = bdrv_commit(bs);
> > +
> > +        aio_context_release(aio_context);
> > +    }
> > +    if (ret < 0) {
> > +        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> > +    }
> > +}
> > diff --git a/blockdev.c b/blockdev.c
> > index 8e029e9c01..df43e0aaef 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -1074,41 +1074,6 @@ static BlockBackend *qmp_get_blk(const char *blk_name, const char *qdev_id,
> >      return blk;
> >  }
> >  
> > -void hmp_commit(Monitor *mon, const QDict *qdict)
> > -{
> > -    const char *device = qdict_get_str(qdict, "device");
> > -    BlockBackend *blk;
> > -    int ret;
> > -
> > -    if (!strcmp(device, "all")) {
> > -        ret = blk_commit_all();
> > -    } else {
> > -        BlockDriverState *bs;
> > -        AioContext *aio_context;
> > -
> > -        blk = blk_by_name(device);
> > -        if (!blk) {
> > -            error_report("Device '%s' not found", device);
> > -            return;
> > -        }
> > -        if (!blk_is_available(blk)) {
> > -            error_report("Device '%s' has no medium", device);
> > -            return;
> > -        }
> > -
> > -        bs = blk_bs(blk);
> > -        aio_context = bdrv_get_aio_context(bs);
> > -        aio_context_acquire(aio_context);
> > -
> > -        ret = bdrv_commit(bs);
> > -
> > -        aio_context_release(aio_context);
> > -    }
> > -    if (ret < 0) {
> > -        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> > -    }
> > -}
> > -
> >  static void blockdev_do_action(TransactionAction *action, Error **errp)
> >  {
> >      TransactionActionList list;
> > @@ -3101,66 +3066,6 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
> >      return ret;
> >  }
> >  
> > -void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > -{
> > -    const char *id = qdict_get_str(qdict, "id");
> > -    BlockBackend *blk;
> > -    BlockDriverState *bs;
> > -    AioContext *aio_context;
> > -    Error *local_err = NULL;
> > -
> > -    bs = bdrv_find_node(id);
> > -    if (bs) {
> > -        qmp_blockdev_del(id, &local_err);
> > -        if (local_err) {
> > -            error_report_err(local_err);
> > -        }
> > -        return;
> > -    }
> > -
> > -    blk = blk_by_name(id);
> > -    if (!blk) {
> > -        error_report("Device '%s' not found", id);
> > -        return;
> > -    }
> > -
> > -    if (!blk_legacy_dinfo(blk)) {
> > -        error_report("Deleting device added with blockdev-add"
> > -                     " is not supported");
> > -        return;
> > -    }
> > -
> > -    aio_context = blk_get_aio_context(blk);
> > -    aio_context_acquire(aio_context);
> > -
> > -    bs = blk_bs(blk);
> > -    if (bs) {
> > -        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> > -            error_report_err(local_err);
> > -            aio_context_release(aio_context);
> > -            return;
> > -        }
> > -
> > -        blk_remove_bs(blk);
> > -    }
> > -
> > -    /* Make the BlockBackend and the attached BlockDriverState anonymous */
> > -    monitor_remove_blk(blk);
> > -
> > -    /* If this BlockBackend has a device attached to it, its refcount will be
> > -     * decremented when the device is removed; otherwise we have to do so here.
> > -     */
> > -    if (blk_get_attached_dev(blk)) {
> > -        /* Further I/O must not pause the guest */
> > -        blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
> > -                         BLOCKDEV_ON_ERROR_REPORT);
> > -    } else {
> > -        blk_unref(blk);
> > -    }
> > -
> > -    aio_context_release(aio_context);
> > -}
> > -
> >  void qmp_block_resize(bool has_device, const char *device,
> >                        bool has_node_name, const char *node_name,
> >                        int64_t size, Error **errp)
> > diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> > index 4f9033a8a6..c5e394c0fc 100644
> > --- a/include/block/block-hmp-commands.h
> > +++ b/include/block/block-hmp-commands.h
> > @@ -5,4 +5,7 @@
> >  
> >  void hmp_drive_add(Monitor *mon, const QDict *qdict);
> >  
> > +void hmp_commit(Monitor *mon, const QDict *qdict);
> > +void hmp_drive_del(Monitor *mon, const QDict *qdict);
> > +
> >  #endif
> > diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> > index d34c4920dc..a86d99b3d8 100644
> > --- a/include/sysemu/blockdev.h
> > +++ b/include/sysemu/blockdev.h
> > @@ -57,8 +57,4 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
> >  DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
> >                       Error **errp);
> >  
> > -/* device-hotplug */
> > -
> > -void hmp_commit(Monitor *mon, const QDict *qdict);
> > -void hmp_drive_del(Monitor *mon, const QDict *qdict);
> >  #endif
> > -- 
> > 2.17.2
> > 
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 11/13] monitor: Move hmp_drive_add_node to block-hmp-cmds.c
  2020-01-28 19:03   ` Dr. David Alan Gilbert
@ 2020-01-28 19:30     ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-28 19:30 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

On Tue, 2020-01-28 at 19:03 +0000, Dr. David Alan Gilbert wrote:
> * Maxim Levitsky (mlevitsk@redhat.com) wrote:
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> 
> Looks OK to me, I'm not clear on the name for 'bdrv_set_monitor_owned'
> I'd want a block person to OK that, but:


The name inspiration came from 'bdrv_next_monitor_owned'. To me it looks
like list of all BlockDriverState which are created by the monitor.
Also comment on 'monitor_list' link chain more or less confirms this.

Thanks for the review!

Best regards,
	Maxim Levitsky


> 
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> > ---
> >  block/monitor/block-hmp-cmds.c | 30 ++++++++++++++++++++++++
> >  blockdev.c                     | 42 +++++++---------------------------
> >  include/block/block_int.h      |  5 ++--
> >  3 files changed, 41 insertions(+), 36 deletions(-)
> > 
> > diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> > index a4b1604aee..7bbe4e3814 100644
> > --- a/block/monitor/block-hmp-cmds.c
> > +++ b/block/monitor/block-hmp-cmds.c
> > @@ -33,6 +33,36 @@
> >  #include "monitor/hmp.h"
> >  #include "qemu-io.h"
> >  
> > +static void hmp_drive_add_node(Monitor *mon, const char *optstr)
> > +{
> > +    QemuOpts *opts;
> > +    QDict *qdict;
> > +    Error *local_err = NULL;
> > +
> > +    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
> > +    if (!opts) {
> > +        return;
> > +    }
> > +
> > +    qdict = qemu_opts_to_qdict(opts, NULL);
> > +
> > +    if (!qdict_get_try_str(qdict, "node-name")) {
> > +        qobject_unref(qdict);
> > +        error_report("'node-name' needs to be specified");
> > +        goto out;
> > +    }
> > +
> > +    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
> > +    if (!bs) {
> > +        error_report_err(local_err);
> > +        goto out;
> > +    }
> > +
> > +    bdrv_set_monitor_owned(bs);
> > +out:
> > +    qemu_opts_del(opts);
> > +}
> > +
> >  void hmp_drive_add(Monitor *mon, const QDict *qdict)
> >  {
> >      Error *err = NULL;
> > diff --git a/blockdev.c b/blockdev.c
> > index df43e0aaef..63805f34b5 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -64,7 +64,7 @@
> >  #include "qemu/main-loop.h"
> >  #include "qemu/throttle-options.h"
> >  
> > -static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
> > +QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
> >      QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
> >  
> >  static int do_open_tray(const char *blk_name, const char *qdev_id,
> > @@ -75,6 +75,11 @@ static void blockdev_insert_medium(bool has_device, const char *device,
> >                                     bool has_id, const char *id,
> >                                     const char *node_name, Error **errp);
> >  
> > +void bdrv_set_monitor_owned(BlockDriverState *bs)
> > +{
> > +    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> > +}
> > +
> >  static const char *const if_name[IF_COUNT] = {
> >      [IF_NONE] = "none",
> >      [IF_IDE] = "ide",
> > @@ -652,7 +657,7 @@ err_no_opts:
> >  }
> >  
> >  /* Takes the ownership of bs_opts */
> > -static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
> > +BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
> >  {
> >      int bdrv_flags = 0;
> >  
> > @@ -4201,37 +4206,6 @@ out:
> >      aio_context_release(aio_context);
> >  }
> >  
> > -void hmp_drive_add_node(Monitor *mon, const char *optstr)
> > -{
> > -    QemuOpts *opts;
> > -    QDict *qdict;
> > -    Error *local_err = NULL;
> > -
> > -    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
> > -    if (!opts) {
> > -        return;
> > -    }
> > -
> > -    qdict = qemu_opts_to_qdict(opts, NULL);
> > -
> > -    if (!qdict_get_try_str(qdict, "node-name")) {
> > -        qobject_unref(qdict);
> > -        error_report("'node-name' needs to be specified");
> > -        goto out;
> > -    }
> > -
> > -    BlockDriverState *bs = bds_tree_init(qdict, &local_err);
> > -    if (!bs) {
> > -        error_report_err(local_err);
> > -        goto out;
> > -    }
> > -
> > -    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> > -
> > -out:
> > -    qemu_opts_del(opts);
> > -}
> > -
> >  void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
> >  {
> >      BlockDriverState *bs;
> > @@ -4261,7 +4235,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
> >          goto fail;
> >      }
> >  
> > -    QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
> > +    bdrv_set_monitor_owned(bs);
> >  
> >  fail:
> >      visit_free(v);
> > diff --git a/include/block/block_int.h b/include/block/block_int.h
> > index dd033d0b37..10df257a61 100644
> > --- a/include/block/block_int.h
> > +++ b/include/block/block_int.h
> > @@ -1217,8 +1217,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
> >                              BlockCompletionFunc *cb, void *opaque,
> >                              JobTxn *txn, Error **errp);
> >  
> > -void hmp_drive_add_node(Monitor *mon, const char *optstr);
> > -
> >  BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
> >                                    const char *child_name,
> >                                    const BdrvChildRole *child_role,
> > @@ -1320,4 +1318,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
> >  
> >  int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
> >  
> > +void bdrv_set_monitor_owned(BlockDriverState *bs);
> > +BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp);
> > +
> >  #endif /* BLOCK_INT_H */
> > -- 
> > 2.17.2
> > 
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 12/13] add 'error' prefix to vreport
  2020-01-27 10:36 ` [PATCH v3 12/13] add 'error' prefix to vreport Maxim Levitsky
@ 2020-01-28 19:30   ` Maxim Levitsky
  2020-01-29 10:38     ` Markus Armbruster
  0 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-28 19:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Krempa, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann

On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
> This changes most of qemu's error messages,
> but it feels like the right thing to do.
> 
> This is WIP patch, since I updated most of iotests but not all of them,
> and will be updated if this patch is accepeted in the review.
> Also few error message already have 'error' prefix, which should be removed.
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> Suggested-by: Markus Armbruster <armbru@redhat.com>

Since Peter Krempa pointed out that libvirt doesn't need the error prefixes any more
(this wasn't the case when I developed this sadly) I guess I'll drop that patch,
although to me it looks just better to have errors cleanly prefixed to be honest.

Best regards,
	Maxim Levitsky



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
  2020-01-27 10:36 ` [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands Maxim Levitsky
@ 2020-01-28 19:31   ` Maxim Levitsky
  2020-01-29 10:27     ` Markus Armbruster
  0 siblings, 1 reply; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-28 19:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Krempa, qemu-block, Markus Armbruster,
	Dr. David Alan Gilbert, Max Reitz, Gerd Hoffmann

On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
> This way they all will be prefixed with 'Error:' which some parsers
> (e.g libvirt) need
> 
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

And I probably will keep that patch since it is not invasive and
still does a nice refactoring.
Thoughts?

Best regards,
	Maxim Levitsky

> ---
>  block/monitor/block-hmp-cmds.c | 35 ++++++++++++++++++++--------------
>  1 file changed, 21 insertions(+), 14 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index 7bbe4e3814..5b060d380d 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -84,7 +84,6 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
>      mc = MACHINE_GET_CLASS(current_machine);
>      dinfo = drive_new(opts, mc->block_default_type, &err);
>      if (err) {
> -        error_report_err(err);
>          qemu_opts_del(opts);
>          goto err;
>      }
> @@ -98,7 +97,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, "OK\n");
>          break;
>      default:
> -        monitor_printf(mon, "Can't hot-add drive to type %d\n", dinfo->type);
> +        error_setg(&err, "Can't hot-add drive to type %d", dinfo->type);
>          goto err;
>      }
>      return;
> @@ -109,6 +108,7 @@ err:
>          monitor_remove_blk(blk);
>          blk_unref(blk);
>      }
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_drive_del(Monitor *mon, const QDict *qdict)
> @@ -130,14 +130,14 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>  
>      blk = blk_by_name(id);
>      if (!blk) {
> -        error_report("Device '%s' not found", id);
> -        return;
> +        error_setg(&local_err, "Device '%s' not found", id);
> +        goto err;
>      }
>  
>      if (!blk_legacy_dinfo(blk)) {
> -        error_report("Deleting device added with blockdev-add"
> -                     " is not supported");
> -        return;
> +        error_setg(&local_err,
> +                   "Deleting device added with blockdev-add is not supported");
> +        goto err;
>      }
>  
>      aio_context = blk_get_aio_context(blk);
> @@ -146,9 +146,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>      bs = blk_bs(blk);
>      if (bs) {
>          if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> -            error_report_err(local_err);
>              aio_context_release(aio_context);
> -            return;
> +            goto err;
>          }
>  
>          blk_remove_bs(blk);
> @@ -169,12 +168,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>      }
>  
>      aio_context_release(aio_context);
> +err:
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_commit(Monitor *mon, const QDict *qdict)
>  {
>      const char *device = qdict_get_str(qdict, "device");
>      BlockBackend *blk;
> +    Error *local_err = NULL;
>      int ret;
>  
>      if (!strcmp(device, "all")) {
> @@ -185,12 +187,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>  
>          blk = blk_by_name(device);
>          if (!blk) {
> -            error_report("Device '%s' not found", device);
> -            return;
> +            error_setg(&local_err, "Device '%s' not found", device);
> +            goto err;
>          }
>          if (!blk_is_available(blk)) {
> -            error_report("Device '%s' has no medium", device);
> -            return;
> +            error_setg(&local_err, "Device '%s' has no medium", device);
> +            goto err;
>          }
>  
>          bs = blk_bs(blk);
> @@ -202,8 +204,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>          aio_context_release(aio_context);
>      }
>      if (ret < 0) {
> -        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> +        error_setg(&local_err,
> +                   "'commit' error for '%s': %s", device, strerror(-ret));
> +        goto err;
>      }
> +    return;
> +err:
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_drive_mirror(Monitor *mon, const QDict *qdict)




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c
  2020-01-28 18:56   ` Dr. David Alan Gilbert
@ 2020-01-28 20:05     ` Eric Blake
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Blake @ 2020-01-28 20:05 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, Markus Armbruster, qemu-devel, Max Reitz,
	Gerd Hoffmann

On 1/28/20 12:56 PM, Dr. David Alan Gilbert wrote:
> * Maxim Levitsky (mlevitsk@redhat.com) wrote:
>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> 
> Yes, I think that's OK; I can imagine nbd might want to move on it's own
> somewhere since it's not really core block code; copying in Eric.

I think that nbd-server-start and friends ARE related to core block 
code; they do not work without a BDS node.  It's not the same as a block 
driver, though, in that it is exposing the BDS to the outside world, 
rather than connecting an outside resource for use internally by the guest.

At any rate, block-hmp-cmds.c seems reasonable enough as a new location 
for these HMP commands.

> 
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
>> ---
>>   block/monitor/block-hmp-cmds.c     | 88 ++++++++++++++++++++++++++++++
>>   include/block/block-hmp-commands.h |  5 ++
>>   include/monitor/hmp.h              |  4 --
>>   monitor/hmp-cmds.c                 | 87 -----------------------------
>>   4 files changed, 93 insertions(+), 91 deletions(-)
>>
Reviewed-by: Eric Blake <eblake@redhat.com>

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



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  2020-01-28 19:28     ` Maxim Levitsky
@ 2020-01-29 10:19       ` Markus Armbruster
  2020-01-29 11:31         ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Markus Armbruster @ 2020-01-29 10:19 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, qemu-block, qemu-devel, Dr. David Alan Gilbert,
	Max Reitz, Gerd Hoffmann

Maxim Levitsky <mlevitsk@redhat.com> writes:

> On Tue, 2020-01-28 at 16:56 +0000, Dr. David Alan Gilbert wrote:
>> * Maxim Levitsky (mlevitsk@redhat.com) wrote:
>> > These days device-hotplug.c only contains the hmp_drive_add
>> > In the next patch, rest of hmp_drive* functions will be moved
>> > there.
>> > 
>> > Also change the license of that file to GPL2+ since most
>> > of the code that will be moved there is under that license
>> 
>> How do we check that's OK?
>
> Currently that code is BSD licensed, and in next patches I will move
> here GPLv2+ code, and as far as I know combining them gives you GPLv2+

Yes, it does.

I'd change the license in the patch that moves in GPLv2+ code.

> I wasn't even aware that we have mixed licenses, and so this change was done
> after Markus pointed this out in the previous patchset review.
>
> Best regards,
> 	Maxim Levitsky
>
>> 
>> > Also add block-hmp-commands.h to contain prototypes of these
>> > functions
>> > 
>> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>> > ---
>> >  MAINTAINERS                                   |  1 +
>> >  Makefile.objs                                 |  2 +-
>> >  block/Makefile.objs                           |  1 +
>> >  block/monitor/Makefile.objs                   |  1 +
>> >  .../monitor/block-hmp-cmds.c                  | 23 ++++---------------
>> >  include/block/block-hmp-commands.h            |  8 +++++++
>> >  include/sysemu/sysemu.h                       |  3 ---
>> >  monitor/misc.c                                |  1 +
>> >  8 files changed, 18 insertions(+), 22 deletions(-)
>> >  create mode 100644 block/monitor/Makefile.objs
>> >  rename device-hotplug.c => block/monitor/block-hmp-cmds.c (55%)
>> >  create mode 100644 include/block/block-hmp-commands.h
>> > 
>> > diff --git a/MAINTAINERS b/MAINTAINERS
>> > index f6511d5120..5d50d09ad8 100644
>> > --- a/MAINTAINERS
>> > +++ b/MAINTAINERS
>> > @@ -1882,6 +1882,7 @@ Block QAPI, monitor, command line
>> >  M: Markus Armbruster <armbru@redhat.com>
>> >  S: Supported
>> >  F: blockdev.c
>> > +F: blockdev-hmp-cmds.c
>> >  F: block/qapi.c
>> >  F: qapi/block*.json
>> >  F: qapi/transaction.json
>> > diff --git a/Makefile.objs b/Makefile.objs
>> > index ff396b9209..15209eb6b5 100644
>> > --- a/Makefile.objs
>> > +++ b/Makefile.objs
>> > @@ -48,7 +48,7 @@ common-obj-y += dump/
>> >  common-obj-y += job-qmp.o
>> >  common-obj-y += monitor/
>> >  common-obj-y += net/
>> > -common-obj-y += qdev-monitor.o device-hotplug.o
>> > +common-obj-y += qdev-monitor.o
>> >  common-obj-$(CONFIG_WIN32) += os-win32.o
>> >  common-obj-$(CONFIG_POSIX) += os-posix.o
>> >  
>> > diff --git a/block/Makefile.objs b/block/Makefile.objs
>> > index 330529b0b7..3f65544a6b 100644
>> > --- a/block/Makefile.objs
>> > +++ b/block/Makefile.objs
>> > @@ -44,6 +44,7 @@ block-obj-y += crypto.o
>> >  block-obj-y += aio_task.o
>> >  block-obj-y += backup-top.o
>> >  block-obj-y += filter-compress.o
>> > +common-obj-y += monitor/
>> >  
>> >  common-obj-y += stream.o
>> >  
>> > diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs
>> > new file mode 100644
>> > index 0000000000..0a74f9a8b5
>> > --- /dev/null
>> > +++ b/block/monitor/Makefile.objs
>> > @@ -0,0 +1 @@
>> > +common-obj-y += block-hmp-cmds.o
>> > diff --git a/device-hotplug.c b/block/monitor/block-hmp-cmds.c
>> > similarity index 55%
>> > rename from device-hotplug.c
>> > rename to block/monitor/block-hmp-cmds.c
>> > index 554e4d98db..c65aaa86ea 100644
>> > --- a/device-hotplug.c
>> > +++ b/block/monitor/block-hmp-cmds.c
>> > @@ -1,25 +1,11 @@
>> >  /*
>> > - * QEMU device hotplug helpers
>> > + * Blockdev HMP commands
>> >   *
>> >   * Copyright (c) 2004 Fabrice Bellard
>> >   *
>> > - * Permission is hereby granted, free of charge, to any person obtaining a copy
>> > - * of this software and associated documentation files (the "Software"), to deal
>> > - * in the Software without restriction, including without limitation the rights
>> > - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>> > - * copies of the Software, and to permit persons to whom the Software is
>> > - * furnished to do so, subject to the following conditions:
>> > - *
>> > - * The above copyright notice and this permission notice shall be included in
>> > - * all copies or substantial portions of the Software.
>> > - *
>> > - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>> > - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> > - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
>> > - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>> > - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>> > - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
>> > - * THE SOFTWARE.
>> > + * This work is licensed under the terms of the GNU GPL, version 2.
>> > + * or (at your option) any later version.
>> > + * See the COPYING file in the top-level directory.
>> >   */
>> >  
>> >  #include "qemu/osdep.h"
>> > @@ -33,6 +19,7 @@
>> >  #include "sysemu/sysemu.h"
>> >  #include "monitor/monitor.h"
>> >  #include "block/block_int.h"
>> > +#include "block/block-hmp-commands.h"
>> >  
>> >  
>> >  void hmp_drive_add(Monitor *mon, const QDict *qdict)
>> > diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
>> > new file mode 100644
>> > index 0000000000..4f9033a8a6
>> > --- /dev/null
>> > +++ b/include/block/block-hmp-commands.h
>> > @@ -0,0 +1,8 @@
>> > +#ifndef BLOCK_HMP_COMMANDS_H
>> > +#define BLOCK_HMP_COMMANDS_H
>> > +
>> > +/* HMP commands related to the block layer*/

Space before */, please.

>> Should this file get a copyright header as well?

I think it should.

>> > +
>> > +void hmp_drive_add(Monitor *mon, const QDict *qdict);
>> > +
>> > +#endif
>> > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>> > index 80c57fdc4e..c48635666d 100644
>> > --- a/include/sysemu/sysemu.h
>> > +++ b/include/sysemu/sysemu.h
>> > @@ -68,9 +68,6 @@ extern int nb_option_roms;
>> >  extern const char *prom_envs[MAX_PROM_ENVS];
>> >  extern unsigned int nb_prom_envs;
>> >  
>> > -/* generic hotplug */
>> > -void hmp_drive_add(Monitor *mon, const QDict *qdict);
>> > -
>> >  /* pcie aer error injection */
>> >  void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
>> >  
>> > diff --git a/monitor/misc.c b/monitor/misc.c
>> > index de1ca4d114..0466c00830 100644
>> > --- a/monitor/misc.c
>> > +++ b/monitor/misc.c
>> > @@ -79,6 +79,7 @@
>> >  #include "sysemu/cpus.h"
>> >  #include "qemu/cutils.h"
>> >  #include "tcg/tcg.h"
>> > +#include "block/block-hmp-commands.h"

Put this next to #include "block/qapi.h", please.

>> >  
>> >  #if defined(TARGET_S390X)
>> >  #include "hw/s390x/storage-keys.h"
>> > -- 
>> > 2.17.2
>> > 

Preferably with my nitpicks addressed:
Reviewed-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
  2020-01-28 19:31   ` Maxim Levitsky
@ 2020-01-29 10:27     ` Markus Armbruster
  2020-01-29 11:05       ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Markus Armbruster @ 2020-01-29 10:27 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, Peter Krempa, qemu-block, qemu-devel, Max Reitz,
	Gerd Hoffmann, Dr. David Alan Gilbert

Maxim Levitsky <mlevitsk@redhat.com> writes:

> On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
>> This way they all will be prefixed with 'Error:' which some parsers
>> (e.g libvirt) need
>> 
>> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719169
>> 
>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>
> And I probably will keep that patch since it is not invasive and
> still does a nice refactoring.
> Thoughts?

The commit message needs updating: libvirt doesn't actually need this
anymore.

What remains is "nice refactoring".  Let's look at the patch from that
perspective.

>
> Best regards,
> 	Maxim Levitsky
>
>> ---
>>  block/monitor/block-hmp-cmds.c | 35 ++++++++++++++++++++--------------
>>  1 file changed, 21 insertions(+), 14 deletions(-)
>> 
>> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
>> index 7bbe4e3814..5b060d380d 100644
>> --- a/block/monitor/block-hmp-cmds.c
>> +++ b/block/monitor/block-hmp-cmds.c
>> @@ -84,7 +84,6 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
>>      mc = MACHINE_GET_CLASS(current_machine);
>>      dinfo = drive_new(opts, mc->block_default_type, &err);
>>      if (err) {
>> -        error_report_err(err);
>>          qemu_opts_del(opts);
>>          goto err;
>>      }
>> @@ -98,7 +97,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
>>          monitor_printf(mon, "OK\n");
>>          break;
>>      default:
>> -        monitor_printf(mon, "Can't hot-add drive to type %d\n", dinfo->type);
>> +        error_setg(&err, "Can't hot-add drive to type %d", dinfo->type);
>>          goto err;
>>      }
>>      return;
>> @@ -109,6 +108,7 @@ err:
>>          monitor_remove_blk(blk);
>>          blk_unref(blk);
>>      }
>> +    hmp_handle_error(mon, err);
>>  }

Is this really nicer?

>>  
>>  void hmp_drive_del(Monitor *mon, const QDict *qdict)
>> @@ -130,14 +130,14 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>>  
>>      blk = blk_by_name(id);
>>      if (!blk) {
>> -        error_report("Device '%s' not found", id);
>> -        return;
>> +        error_setg(&local_err, "Device '%s' not found", id);
>> +        goto err;
>>      }
>>  
>>      if (!blk_legacy_dinfo(blk)) {
>> -        error_report("Deleting device added with blockdev-add"
>> -                     " is not supported");
>> -        return;
>> +        error_setg(&local_err,
>> +                   "Deleting device added with blockdev-add is not supported");
>> +        goto err;
>>      }
>>  
>>      aio_context = blk_get_aio_context(blk);
>> @@ -146,9 +146,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>>      bs = blk_bs(blk);
>>      if (bs) {
>>          if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
>> -            error_report_err(local_err);
>>              aio_context_release(aio_context);
>> -            return;
>> +            goto err;
>>          }
>>  
>>          blk_remove_bs(blk);
>> @@ -169,12 +168,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>>      }
>>  
>>      aio_context_release(aio_context);
>> +err:
>> +    hmp_handle_error(mon, local_err);
>>  }

Likewise.

>>  
>>  void hmp_commit(Monitor *mon, const QDict *qdict)
>>  {
>>      const char *device = qdict_get_str(qdict, "device");
>>      BlockBackend *blk;
>> +    Error *local_err = NULL;
>>      int ret;
>>  
>>      if (!strcmp(device, "all")) {
>> @@ -185,12 +187,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>>  
>>          blk = blk_by_name(device);
>>          if (!blk) {
>> -            error_report("Device '%s' not found", device);
>> -            return;
>> +            error_setg(&local_err, "Device '%s' not found", device);
>> +            goto err;
>>          }
>>          if (!blk_is_available(blk)) {
>> -            error_report("Device '%s' has no medium", device);
>> -            return;
>> +            error_setg(&local_err, "Device '%s' has no medium", device);
>> +            goto err;
>>          }
>>  
>>          bs = blk_bs(blk);
>> @@ -202,8 +204,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>>          aio_context_release(aio_context);
>>      }
>>      if (ret < 0) {
>> -        error_report("'commit' error for '%s': %s", device, strerror(-ret));
>> +        error_setg(&local_err,
>> +                   "'commit' error for '%s': %s", device, strerror(-ret));
>> +        goto err;
>>      }
>> +    return;
>> +err:
>> +    hmp_handle_error(mon, local_err);
>>  }
>>  
>>  void hmp_drive_mirror(Monitor *mon, const QDict *qdict)

Likewise.

Up to the code's maintainers Kevin & Max.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 12/13] add 'error' prefix to vreport
  2020-01-28 19:30   ` Maxim Levitsky
@ 2020-01-29 10:38     ` Markus Armbruster
  2020-01-29 10:58       ` Maxim Levitsky
  0 siblings, 1 reply; 48+ messages in thread
From: Markus Armbruster @ 2020-01-29 10:38 UTC (permalink / raw)
  To: Maxim Levitsky
  Cc: Kevin Wolf, Peter Krempa, qemu-block, qemu-devel, Max Reitz,
	Gerd Hoffmann, Dr. David Alan Gilbert

Maxim Levitsky <mlevitsk@redhat.com> writes:

> On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
>> This changes most of qemu's error messages,
>> but it feels like the right thing to do.
>> 
>> This is WIP patch, since I updated most of iotests but not all of them,
>> and will be updated if this patch is accepeted in the review.
>> Also few error message already have 'error' prefix, which should be removed.
>> 
>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>> Suggested-by: Markus Armbruster <armbru@redhat.com>
>
> Since Peter Krempa pointed out that libvirt doesn't need the error prefixes any more
> (this wasn't the case when I developed this sadly) I guess I'll drop that patch,
> although to me it looks just better to have errors cleanly prefixed to be honest.

The "libvirt needs this" justification is gone.  But perhaps we want it
anyway.  It's hardly an "HMP monitor handlers cleanups", though.
Suggest to split it off this series, so it can't hold it back.  Posting
it separately should also give it a better chance to be noticed.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 12/13] add 'error' prefix to vreport
  2020-01-29 10:38     ` Markus Armbruster
@ 2020-01-29 10:58       ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-29 10:58 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Kevin Wolf, Peter Krempa, qemu-block, qemu-devel, Max Reitz,
	Gerd Hoffmann, Dr. David Alan Gilbert

On Wed, 2020-01-29 at 11:38 +0100, Markus Armbruster wrote:
> Maxim Levitsky <mlevitsk@redhat.com> writes:
> 
> > On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
> > > This changes most of qemu's error messages,
> > > but it feels like the right thing to do.
> > > 
> > > This is WIP patch, since I updated most of iotests but not all of them,
> > > and will be updated if this patch is accepeted in the review.
> > > Also few error message already have 'error' prefix, which should be removed.
> > > 
> > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > Suggested-by: Markus Armbruster <armbru@redhat.com>
> > 
> > Since Peter Krempa pointed out that libvirt doesn't need the error prefixes any more
> > (this wasn't the case when I developed this sadly) I guess I'll drop that patch,
> > although to me it looks just better to have errors cleanly prefixed to be honest.
> 
> The "libvirt needs this" justification is gone.  But perhaps we want it
> anyway.  It's hardly an "HMP monitor handlers cleanups", though.
> Suggest to split it off this series, so it can't hold it back.  Posting
> it separately should also give it a better chance to be noticed.

Fully agree. Thanks!

Best regards,
	Maxim Levitsky



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands
  2020-01-29 10:27     ` Markus Armbruster
@ 2020-01-29 11:05       ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-29 11:05 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Kevin Wolf, Peter Krempa, qemu-block, qemu-devel, Max Reitz,
	Gerd Hoffmann, Dr. David Alan Gilbert

On Wed, 2020-01-29 at 11:27 +0100, Markus Armbruster wrote:
> Maxim Levitsky <mlevitsk@redhat.com> writes:
> 
> > On Mon, 2020-01-27 at 12:36 +0200, Maxim Levitsky wrote:
> > > This way they all will be prefixed with 'Error:' which some parsers
> > > (e.g libvirt) need
> > > 
> > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> > > 
> > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > 
> > And I probably will keep that patch since it is not invasive and
> > still does a nice refactoring.
> > Thoughts?
> 
> The commit message needs updating: libvirt doesn't actually need this
> anymore.
> 
> What remains is "nice refactoring".  Let's look at the patch from that
> perspective.
> 
> > 
> > Best regards,
> > 	Maxim Levitsky
> > 
> > > ---
> > >  block/monitor/block-hmp-cmds.c | 35 ++++++++++++++++++++--------------
> > >  1 file changed, 21 insertions(+), 14 deletions(-)
> > > 
> > > diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> > > index 7bbe4e3814..5b060d380d 100644
> > > --- a/block/monitor/block-hmp-cmds.c
> > > +++ b/block/monitor/block-hmp-cmds.c
> > > @@ -84,7 +84,6 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
> > >      mc = MACHINE_GET_CLASS(current_machine);
> > >      dinfo = drive_new(opts, mc->block_default_type, &err);
> > >      if (err) {
> > > -        error_report_err(err);
> > >          qemu_opts_del(opts);
> > >          goto err;
> > >      }
> > > @@ -98,7 +97,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
> > >          monitor_printf(mon, "OK\n");
> > >          break;
> > >      default:
> > > -        monitor_printf(mon, "Can't hot-add drive to type %d\n", dinfo->type);
> > > +        error_setg(&err, "Can't hot-add drive to type %d", dinfo->type);
> > >          goto err;
> > >      }
> > >      return;
> > > @@ -109,6 +108,7 @@ err:
> > >          monitor_remove_blk(blk);
> > >          blk_unref(blk);
> > >      }
> > > +    hmp_handle_error(mon, err);
> > >  }
> 
> Is this really nicer?
> 
> > >  
> > >  void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > > @@ -130,14 +130,14 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > >  
> > >      blk = blk_by_name(id);
> > >      if (!blk) {
> > > -        error_report("Device '%s' not found", id);
> > > -        return;
> > > +        error_setg(&local_err, "Device '%s' not found", id);
> > > +        goto err;
> > >      }
> > >  
> > >      if (!blk_legacy_dinfo(blk)) {
> > > -        error_report("Deleting device added with blockdev-add"
> > > -                     " is not supported");
> > > -        return;
> > > +        error_setg(&local_err,
> > > +                   "Deleting device added with blockdev-add is not supported");
> > > +        goto err;
> > >      }
> > >  
> > >      aio_context = blk_get_aio_context(blk);
> > > @@ -146,9 +146,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > >      bs = blk_bs(blk);
> > >      if (bs) {
> > >          if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
> > > -            error_report_err(local_err);
> > >              aio_context_release(aio_context);
> > > -            return;
> > > +            goto err;
> > >          }
> > >  
> > >          blk_remove_bs(blk);
> > > @@ -169,12 +168,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
> > >      }
> > >  
> > >      aio_context_release(aio_context);
> > > +err:
> > > +    hmp_handle_error(mon, local_err);
> > >  }
> 
> Likewise.
> 
> > >  
> > >  void hmp_commit(Monitor *mon, const QDict *qdict)
> > >  {
> > >      const char *device = qdict_get_str(qdict, "device");
> > >      BlockBackend *blk;
> > > +    Error *local_err = NULL;
> > >      int ret;
> > >  
> > >      if (!strcmp(device, "all")) {
> > > @@ -185,12 +187,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
> > >  
> > >          blk = blk_by_name(device);
> > >          if (!blk) {
> > > -            error_report("Device '%s' not found", device);
> > > -            return;
> > > +            error_setg(&local_err, "Device '%s' not found", device);
> > > +            goto err;
> > >          }
> > >          if (!blk_is_available(blk)) {
> > > -            error_report("Device '%s' has no medium", device);
> > > -            return;
> > > +            error_setg(&local_err, "Device '%s' has no medium", device);
> > > +            goto err;
> > >          }
> > >  
> > >          bs = blk_bs(blk);
> > > @@ -202,8 +204,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
> > >          aio_context_release(aio_context);
> > >      }
> > >      if (ret < 0) {
> > > -        error_report("'commit' error for '%s': %s", device, strerror(-ret));
> > > +        error_setg(&local_err,
> > > +                   "'commit' error for '%s': %s", device, strerror(-ret));
> > > +        goto err;
> > >      }
> > > +    return;
> > > +err:
> > > +    hmp_handle_error(mon, local_err);
> > >  }
> > >  
> > >  void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
> 
> Likewise.
> 
> Up to the code's maintainers Kevin & Max.
Yep.
In theory, if I understand correctly we should reduce usage of monitor_printf,
but yes, without libvirt justification I don't mind dropping this.

I hope that the rest of the patches will make it, so that this work is not
wasted.

Thanks for the review!

Best regards,
	Maxim Levitsky




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c
  2020-01-29 10:19       ` Markus Armbruster
@ 2020-01-29 11:31         ` Maxim Levitsky
  0 siblings, 0 replies; 48+ messages in thread
From: Maxim Levitsky @ 2020-01-29 11:31 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Kevin Wolf, qemu-block, qemu-devel, Dr. David Alan Gilbert,
	Max Reitz, Gerd Hoffmann

On Wed, 2020-01-29 at 11:19 +0100, Markus Armbruster wrote:
> Maxim Levitsky <mlevitsk@redhat.com> writes:
> 
> > On Tue, 2020-01-28 at 16:56 +0000, Dr. David Alan Gilbert wrote:
> > > * Maxim Levitsky (mlevitsk@redhat.com) wrote:
> > > > These days device-hotplug.c only contains the hmp_drive_add
> > > > In the next patch, rest of hmp_drive* functions will be moved
> > > > there.
> > > > 
> > > > Also change the license of that file to GPL2+ since most
> > > > of the code that will be moved there is under that license
> > > 
> > > How do we check that's OK?
> > 
> > Currently that code is BSD licensed, and in next patches I will move
> > here GPLv2+ code, and as far as I know combining them gives you GPLv2+
> 
> Yes, it does.
> 
> I'd change the license in the patch that moves in GPLv2+ code.

All right.
> 
> > I wasn't even aware that we have mixed licenses, and so this change was done
> > after Markus pointed this out in the previous patchset review.
> > 
> > Best regards,
> > 	Maxim Levitsky
> > 
> > > 
> > > > Also add block-hmp-commands.h to contain prototypes of these
> > > > functions
> > > > 
> > > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > > ---
> > > >  MAINTAINERS                                   |  1 +
> > > >  Makefile.objs                                 |  2 +-
> > > >  block/Makefile.objs                           |  1 +
> > > >  block/monitor/Makefile.objs                   |  1 +
> > > >  .../monitor/block-hmp-cmds.c                  | 23 ++++---------------
> > > >  include/block/block-hmp-commands.h            |  8 +++++++
> > > >  include/sysemu/sysemu.h                       |  3 ---
> > > >  monitor/misc.c                                |  1 +
> > > >  8 files changed, 18 insertions(+), 22 deletions(-)
> > > >  create mode 100644 block/monitor/Makefile.objs
> > > >  rename device-hotplug.c => block/monitor/block-hmp-cmds.c (55%)
> > > >  create mode 100644 include/block/block-hmp-commands.h
> > > > 
> > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > index f6511d5120..5d50d09ad8 100644
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -1882,6 +1882,7 @@ Block QAPI, monitor, command line
> > > >  M: Markus Armbruster <armbru@redhat.com>
> > > >  S: Supported
> > > >  F: blockdev.c
> > > > +F: blockdev-hmp-cmds.c
> > > >  F: block/qapi.c
> > > >  F: qapi/block*.json
> > > >  F: qapi/transaction.json
> > > > diff --git a/Makefile.objs b/Makefile.objs
> > > > index ff396b9209..15209eb6b5 100644
> > > > --- a/Makefile.objs
> > > > +++ b/Makefile.objs
> > > > @@ -48,7 +48,7 @@ common-obj-y += dump/
> > > >  common-obj-y += job-qmp.o
> > > >  common-obj-y += monitor/
> > > >  common-obj-y += net/
> > > > -common-obj-y += qdev-monitor.o device-hotplug.o
> > > > +common-obj-y += qdev-monitor.o
> > > >  common-obj-$(CONFIG_WIN32) += os-win32.o
> > > >  common-obj-$(CONFIG_POSIX) += os-posix.o
> > > >  
> > > > diff --git a/block/Makefile.objs b/block/Makefile.objs
> > > > index 330529b0b7..3f65544a6b 100644
> > > > --- a/block/Makefile.objs
> > > > +++ b/block/Makefile.objs
> > > > @@ -44,6 +44,7 @@ block-obj-y += crypto.o
> > > >  block-obj-y += aio_task.o
> > > >  block-obj-y += backup-top.o
> > > >  block-obj-y += filter-compress.o
> > > > +common-obj-y += monitor/
> > > >  
> > > >  common-obj-y += stream.o
> > > >  
> > > > diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs
> > > > new file mode 100644
> > > > index 0000000000..0a74f9a8b5
> > > > --- /dev/null
> > > > +++ b/block/monitor/Makefile.objs
> > > > @@ -0,0 +1 @@
> > > > +common-obj-y += block-hmp-cmds.o
> > > > diff --git a/device-hotplug.c b/block/monitor/block-hmp-cmds.c
> > > > similarity index 55%
> > > > rename from device-hotplug.c
> > > > rename to block/monitor/block-hmp-cmds.c
> > > > index 554e4d98db..c65aaa86ea 100644
> > > > --- a/device-hotplug.c
> > > > +++ b/block/monitor/block-hmp-cmds.c
> > > > @@ -1,25 +1,11 @@
> > > >  /*
> > > > - * QEMU device hotplug helpers
> > > > + * Blockdev HMP commands
> > > >   *
> > > >   * Copyright (c) 2004 Fabrice Bellard
> > > >   *
> > > > - * Permission is hereby granted, free of charge, to any person obtaining a copy
> > > > - * of this software and associated documentation files (the "Software"), to deal
> > > > - * in the Software without restriction, including without limitation the rights
> > > > - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > > > - * copies of the Software, and to permit persons to whom the Software is
> > > > - * furnished to do so, subject to the following conditions:
> > > > - *
> > > > - * The above copyright notice and this permission notice shall be included in
> > > > - * all copies or substantial portions of the Software.
> > > > - *
> > > > - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > > > - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > > > - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > > > - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > > > - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > > > - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > > > - * THE SOFTWARE.
> > > > + * This work is licensed under the terms of the GNU GPL, version 2.
> > > > + * or (at your option) any later version.
> > > > + * See the COPYING file in the top-level directory.
> > > >   */
> > > >  
> > > >  #include "qemu/osdep.h"
> > > > @@ -33,6 +19,7 @@
> > > >  #include "sysemu/sysemu.h"
> > > >  #include "monitor/monitor.h"
> > > >  #include "block/block_int.h"
> > > > +#include "block/block-hmp-commands.h"
> > > >  
> > > >  
> > > >  void hmp_drive_add(Monitor *mon, const QDict *qdict)
> > > > diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> > > > new file mode 100644
> > > > index 0000000000..4f9033a8a6
> > > > --- /dev/null
> > > > +++ b/include/block/block-hmp-commands.h
> > > > @@ -0,0 +1,8 @@
> > > > +#ifndef BLOCK_HMP_COMMANDS_H
> > > > +#define BLOCK_HMP_COMMANDS_H
> > > > +
> > > > +/* HMP commands related to the block layer*/
> 
> Space before */, please.
No problem!
> 
> > > Should this file get a copyright header as well?
> 
> I think it should.
I'll add. GPLv2+ too I guess.
> 
> > > > +
> > > > +void hmp_drive_add(Monitor *mon, const QDict *qdict);
> > > > +
> > > > +#endif
> > > > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> > > > index 80c57fdc4e..c48635666d 100644
> > > > --- a/include/sysemu/sysemu.h
> > > > +++ b/include/sysemu/sysemu.h
> > > > @@ -68,9 +68,6 @@ extern int nb_option_roms;
> > > >  extern const char *prom_envs[MAX_PROM_ENVS];
> > > >  extern unsigned int nb_prom_envs;
> > > >  
> > > > -/* generic hotplug */
> > > > -void hmp_drive_add(Monitor *mon, const QDict *qdict);
> > > > -
> > > >  /* pcie aer error injection */
> > > >  void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
> > > >  
> > > > diff --git a/monitor/misc.c b/monitor/misc.c
> > > > index de1ca4d114..0466c00830 100644
> > > > --- a/monitor/misc.c
> > > > +++ b/monitor/misc.c
> > > > @@ -79,6 +79,7 @@
> > > >  #include "sysemu/cpus.h"
> > > >  #include "qemu/cutils.h"
> > > >  #include "tcg/tcg.h"
> > > > +#include "block/block-hmp-commands.h"
> 
> Put this next to #include "block/qapi.h", please.
Also no problem!
> 
> > > >  
> > > >  #if defined(TARGET_S390X)
> > > >  #include "hw/s390x/storage-keys.h"
> > > > -- 
> > > > 2.17.2
> > > > 
> 
> Preferably with my nitpicks addressed:
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Thank you very much for the review.
Best regards,
	Maxim Levitsky




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-01-28 16:47       ` Dr. David Alan Gilbert
@ 2020-02-05 23:25         ` John Snow
  2020-02-06  9:35           ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 48+ messages in thread
From: John Snow @ 2020-02-05 23:25 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Kevin Wolf, Peter Krempa, Jan Tomko, qemu-block,
	Markus Armbruster, qemu-devel, Max Reitz, Gerd Hoffmann,
	Maxim Levitsky



On 1/28/20 11:47 AM, Dr. David Alan Gilbert wrote:
> * John Snow (jsnow@redhat.com) wrote:
>>
>>
>> On 1/27/20 3:43 PM, Peter Krempa wrote:
>>> On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
>>>>
>>>>
>>>> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
>>>>> This patch series is bunch of cleanups
>>>>> to the hmp monitor code.
>>>>>
>>>>> This series only touched blockdev related hmp handlers.
>>>>>
>>>>> No functional changes expected other that
>>>>> light error message changes by the last patch.
>>>>>
>>>>> This was inspired by this bugzilla:
>>>>> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
>>>>>
>>>>> Basically some users still parse hmp error messages,
>>>>> and they would like to have them prefixed with 'Error:'
>>>>>
>>>>
>>>> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
>>>> like consistency in my UIs (it's useful for human eyes, too), but I'd
>>>> like to know more about the request.
>>>
>>> That's true as long as there's an stable replacement ... see below.
>>>
>>
>> Thanks for the context!
>>
>>>>
>>>> Is this request coming from libvirt? Can we wean them off of this
>>>> interface? What do they need as a replacement?
>>>
>>> There are 5 commands that libvirt still has HMP interfaces for:
>>>
>>> drive_add
>>> drive_del
>>>
>>> savevm
>>> loadvm
>>> delvm
>>>
>>> From upstream point of view there's no value in adding the 'error'
>>> prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
>>> command instead which have implicit error propagation.
>>>
>>
>> As thought.
>>
>>> There are no replacements for the internal snapshot commands, but they
>>> reported the 'error' prefix for some time even before this series.
>>>
>>> Said that, please don't break savevm/loadvm/delvm until a QMP
>>> replacement is added.
>>>
>>
>> Yes, noted. I wonder where userfaultfd write support is these days...
> 
> How would that help you there?
> 

Left at the traffic lights, but there was a thought that we'd be able to
get transactionable save-memory support in QMP if we could use
userfaultfd to do just-in-time copies of memory as needed, until the job
is complete.

This way we could support it properly in QMP and we'd have a replacement
for the HMP version which -- from memory -- is not appropriate for the
QMP channel.

Maybe I imagined this restriction.

--js



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups
  2020-02-05 23:25         ` John Snow
@ 2020-02-06  9:35           ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 48+ messages in thread
From: Dr. David Alan Gilbert @ 2020-02-06  9:35 UTC (permalink / raw)
  To: John Snow
  Cc: Kevin Wolf, Peter Krempa, Jan Tomko, qemu-block,
	Markus Armbruster, qemu-devel, Max Reitz, Gerd Hoffmann,
	Maxim Levitsky

* John Snow (jsnow@redhat.com) wrote:
> 
> 
> On 1/28/20 11:47 AM, Dr. David Alan Gilbert wrote:
> > * John Snow (jsnow@redhat.com) wrote:
> >>
> >>
> >> On 1/27/20 3:43 PM, Peter Krempa wrote:
> >>> On Mon, Jan 27, 2020 at 14:39:02 -0500, John Snow wrote:
> >>>>
> >>>>
> >>>> On 1/27/20 5:36 AM, Maxim Levitsky wrote:
> >>>>> This patch series is bunch of cleanups
> >>>>> to the hmp monitor code.
> >>>>>
> >>>>> This series only touched blockdev related hmp handlers.
> >>>>>
> >>>>> No functional changes expected other that
> >>>>> light error message changes by the last patch.
> >>>>>
> >>>>> This was inspired by this bugzilla:
> >>>>> https://bugzilla.redhat.com/show_bug.cgi?id=1719169
> >>>>>
> >>>>> Basically some users still parse hmp error messages,
> >>>>> and they would like to have them prefixed with 'Error:'
> >>>>>
> >>>>
> >>>> HMP isn't meant to be parsed. It's explicitly *not* API or ABI. I do
> >>>> like consistency in my UIs (it's useful for human eyes, too), but I'd
> >>>> like to know more about the request.
> >>>
> >>> That's true as long as there's an stable replacement ... see below.
> >>>
> >>
> >> Thanks for the context!
> >>
> >>>>
> >>>> Is this request coming from libvirt? Can we wean them off of this
> >>>> interface? What do they need as a replacement?
> >>>
> >>> There are 5 commands that libvirt still has HMP interfaces for:
> >>>
> >>> drive_add
> >>> drive_del
> >>>
> >>> savevm
> >>> loadvm
> >>> delvm
> >>>
> >>> From upstream point of view there's no value in adding the 'error'
> >>> prefix to drive_add/drive_del as libvirt now uses blockdev-add/del QMP
> >>> command instead which have implicit error propagation.
> >>>
> >>
> >> As thought.
> >>
> >>> There are no replacements for the internal snapshot commands, but they
> >>> reported the 'error' prefix for some time even before this series.
> >>>
> >>> Said that, please don't break savevm/loadvm/delvm until a QMP
> >>> replacement is added.
> >>>
> >>
> >> Yes, noted. I wonder where userfaultfd write support is these days...
> > 
> > How would that help you there?
> > 
> 
> Left at the traffic lights, but there was a thought that we'd be able to
> get transactionable save-memory support in QMP if we could use
> userfaultfd to do just-in-time copies of memory as needed, until the job
> is complete.
> 
> This way we could support it properly in QMP and we'd have a replacement
> for the HMP version which -- from memory -- is not appropriate for the
> QMP channel.
> 
> Maybe I imagined this restriction.

The restriction is there; but it's not related to the memory saving;
savevm mostly uses the core migration code (which would normally run in
a separate thread) but uses it itself in it's own loop in the main
thread with a bunch of bdrv code glued around it to do the snapshots
there. 
It shouldn't be that hard to convert it to be much more like a normal
migration - except it needs some hook then to do the snapshotting stuff
at the end.

Dave

> --js
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2020-02-06  9:37 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
2020-01-27 10:49   ` Philippe Mathieu-Daudé
2020-01-27 10:36 ` [PATCH v3 02/13] monitor/hmp: uninline add_init_drive Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
2020-01-28 16:56   ` Dr. David Alan Gilbert
2020-01-28 19:28     ` Maxim Levitsky
2020-01-29 10:19       ` Markus Armbruster
2020-01-29 11:31         ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
2020-01-28 17:51   ` Dr. David Alan Gilbert
2020-01-28 19:29     ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup " Maxim Levitsky
2020-01-28 17:59   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
2020-01-28 18:11   ` Dr. David Alan Gilbert
2020-01-28 18:15   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* " Maxim Levitsky
2020-01-28 18:53   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* " Maxim Levitsky
2020-01-28 18:56   ` Dr. David Alan Gilbert
2020-01-28 20:05     ` Eric Blake
2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
2020-01-28 18:45   ` Dr. David Alan Gilbert
2020-01-28 18:51   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 10/13] monitor/hmp: move hmp_info_block* " Maxim Levitsky
2020-01-28 19:00   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 11/13] monitor: Move hmp_drive_add_node " Maxim Levitsky
2020-01-28 19:03   ` Dr. David Alan Gilbert
2020-01-28 19:30     ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 12/13] add 'error' prefix to vreport Maxim Levitsky
2020-01-28 19:30   ` Maxim Levitsky
2020-01-29 10:38     ` Markus Armbruster
2020-01-29 10:58       ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands Maxim Levitsky
2020-01-28 19:31   ` Maxim Levitsky
2020-01-29 10:27     ` Markus Armbruster
2020-01-29 11:05       ` Maxim Levitsky
2020-01-27 10:55 ` [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups no-reply
2020-01-27 10:59   ` Maxim Levitsky
2020-01-27 19:39 ` John Snow
2020-01-27 20:43   ` Peter Krempa
2020-01-27 21:01     ` John Snow
2020-01-28  9:13       ` Ján Tomko
2020-01-28 16:47       ` Dr. David Alan Gilbert
2020-02-05 23:25         ` John Snow
2020-02-06  9:35           ` Dr. David Alan Gilbert
2020-01-28  8:17     ` Markus Armbruster

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.