All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError
@ 2015-06-13 14:20 Markus Armbruster
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
                   ` (11 more replies)
  0 siblings, 12 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

After a bit over a year and many patches, QError is finally ripe.  All
that's left of qerror.h after this series is a bunch of QERR_ macros.
Killing them is left for another day.

The diffstat looks a bit scary, but that's almost entirely due to
mechanical changes like PATCH 05.

This series applies on top of my "[PATCH v2 0/7] qdev: Mostly wean off
QError".

Markus Armbruster (11):
  QemuOpts: Wean off qerror_report_err()
  vl: Avoid qerror_report() outside QMP command handlers
  vl: Use error_report() for --display errors
  qerror: Eliminate QERR_DEVICE_NOT_FOUND
  qerror: Clean up QERR_ macros to expand into a single string
  tpm: Avoid qerror_report() outside QMP command handlers
  qmp: Wean off qerror_report()
  qerror: Finally unused, clean up
  qerror: Move #include out of qerror.h
  Include qapi/qmp/qerror.h exactly where needed
  Include monitor/monitor.h exactly where needed

 audio/spiceaudio.c               |   1 +
 audio/wavcapture.c               |   1 +
 backends/hostmem.c               |   1 -
 backends/rng-egd.c               |  11 +--
 backends/rng-random.c            |   6 +-
 backends/rng.c                   |   2 +-
 backends/tpm.c                   |   2 +-
 balloon.c                        |   5 +-
 block.c                          |   4 +-
 block/backup.c                   |   5 +-
 block/commit.c                   |   3 +-
 block/curl.c                     |   1 +
 block/dmg.c                      |   1 +
 block/io.c                       |   1 +
 block/iscsi.c                    |   1 +
 block/mirror.c                   |   9 +--
 block/qapi.c                     |   6 --
 block/qcow.c                     |   5 +-
 block/qcow2-snapshot.c           |   1 +
 block/qcow2.c                    |   4 +-
 block/qed.c                      |   4 +-
 block/quorum.c                   |   5 +-
 block/raw-posix.c                |   2 +
 block/snapshot.c                 |   5 +-
 block/ssh.c                      |   2 +
 block/stream.c                   |   5 +-
 block/vhdx-log.c                 |   1 +
 block/vmdk.c                     |  14 ++--
 block/vvfat.c                    |   1 +
 blockdev-nbd.c                   |   6 +-
 blockdev.c                       |  80 ++++++++++++---------
 blockjob.c                       |   9 +--
 cpus.c                           |   9 +--
 dump.c                           |  13 ++--
 hmp.c                            |  24 ++++---
 hw/9pfs/virtio-9p.c              |   1 +
 hw/char/serial-pci.c             |   1 -
 hw/char/virtio-serial-bus.c      |   1 +
 hw/core/nmi.c                    |   2 +-
 hw/core/platform-bus.c           |   1 -
 hw/core/qdev-properties-system.c |   3 +-
 hw/core/qdev-properties.c        |  12 ++--
 hw/core/qdev.c                   |   9 +--
 hw/display/g364fb.c              |   1 +
 hw/display/qxl.c                 |   1 -
 hw/display/tcx.c                 |   1 +
 hw/dma/xilinx_axidma.c           |   1 -
 hw/i386/pc.c                     |   2 +-
 hw/ide/ahci.c                    |   2 +-
 hw/intc/openpic.c                |   6 +-
 hw/misc/ivshmem.c                |   2 +-
 hw/net/xilinx_axienet.c          |   1 -
 hw/pci/pci-stub.c                |   3 +-
 hw/pci/pci.c                     |   1 +
 hw/pci/pcie.c                    |   1 -
 hw/pci/shpc.c                    |   1 -
 hw/ppc/spapr_pci.c               |   8 +--
 hw/ppc/spapr_vio.c               |   1 -
 hw/ppc/virtex_ml507.c            |   2 +-
 hw/s390x/event-facility.c        |   1 -
 hw/s390x/s390-virtio-bus.c       |   1 -
 hw/s390x/s390-virtio.c           |   4 +-
 hw/s390x/virtio-ccw.c            |   2 +-
 hw/scsi/vhost-scsi.c             |   1 +
 hw/timer/hpet.c                  |   1 +
 hw/tpm/tpm_passthrough.c         |   1 +
 hw/usb/bus.c                     |   1 +
 hw/usb/ccid-card-emulated.c      |   1 -
 hw/usb/ccid-card-passthru.c      |   2 +-
 hw/usb/dev-network.c             |   2 +-
 hw/usb/dev-serial.c              |   2 +-
 hw/usb/dev-smartcard-reader.c    |   1 -
 hw/usb/dev-storage.c             |   1 +
 hw/usb/hcd-ehci.h                |   1 -
 hw/usb/host-libusb.c             |   1 +
 hw/usb/redirect.c                |   9 +--
 hw/virtio/virtio-rng.c           |   1 -
 include/block/block_int.h        |   2 -
 include/monitor/monitor.h        |   9 +--
 include/monitor/qdev.h           |   5 +-
 include/net/net.h                |   2 +-
 include/qapi/qmp/qerror.h        |  85 +++++++++-------------
 include/qapi/qmp/qobject.h       |   1 -
 include/qemu/option.h            |   5 +-
 include/qemu/sockets.h           |   1 -
 include/sysemu/balloon.h         |   1 -
 include/ui/console.h             |   4 +-
 include/ui/qemu-spice.h          |   2 -
 migration/migration.c            |  38 +++++-----
 migration/qemu-file-buf.c        |   1 +
 migration/qemu-file.c            |   1 +
 migration/rdma.c                 |   1 +
 migration/savevm.c               |   4 +-
 monitor.c                        | 104 +++++++++++----------------
 net/l2tpv3.c                     |   1 -
 net/net.c                        |  41 +++++------
 net/slirp.c                      |   1 +
 numa.c                           |   1 -
 qapi/opts-visitor.c              |  24 +++----
 qapi/qapi-visit-core.c           |  28 ++++----
 qapi/qmp-dispatch.c              |  12 ++--
 qapi/qmp-input-visitor.c         |  28 ++++----
 qapi/qmp-output-visitor.c        |   1 -
 qapi/string-input-visitor.c      |  24 +++----
 qapi/string-output-visitor.c     |   1 -
 qdev-monitor.c                   |  37 +++++-----
 qemu-char.c                      |   1 +
 qemu-img.c                       |   6 +-
 qemu-io-cmds.c                   |   1 +
 qemu-io.c                        |   4 +-
 qemu-nbd.c                       |   4 +-
 qga/commands-posix.c             |  40 +++++------
 qga/commands-win32.c             |  66 ++++++++---------
 qga/main.c                       |   4 +-
 qmp-commands.hx                  |   4 +-
 qmp.c                            |  97 ++++++++++---------------
 qobject/Makefile.objs            |   1 -
 qobject/json-parser.c            |   1 -
 qobject/qerror.c                 | 148 ---------------------------------------
 qobject/qjson.c                  |   3 -
 qom/object.c                     |  18 ++---
 scripts/qapi-commands.py         |  42 ++---------
 slirp/misc.c                     |   1 +
 stubs/Makefile.objs              |   1 -
 stubs/arch-query-cpu-def.c       |   2 +-
 stubs/dump.c                     |   1 -
 stubs/mon-is-qmp.c               |   2 +
 stubs/mon-set-error.c            |   8 ---
 target-arm/cpu.c                 |   1 -
 target-i386/cpu.c                |  20 +++---
 target-i386/kvm.c                |   1 -
 target-s390x/kvm.c               |   1 -
 tests/test-opts-visitor.c        |   3 +-
 tests/test-qemu-opts.c           |   2 +-
 tpm.c                            |  12 ++--
 ui/input-legacy.c                |   1 -
 ui/input.c                       |   4 +-
 ui/spice-core.c                  |   1 +
 ui/spice-display.c               |   1 -
 ui/vnc.c                         |  10 +--
 util/osdep.c                     |   1 +
 util/qemu-config.c               |   1 -
 util/qemu-error.c                |   5 +-
 util/qemu-option.c               |  47 ++++++++-----
 vl.c                             | 143 +++++++++++++++++++++----------------
 145 files changed, 676 insertions(+), 845 deletions(-)
 delete mode 100644 qobject/qerror.c
 delete mode 100644 stubs/mon-set-error.c

-- 
1.9.3

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

* [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err()
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-14  2:57   ` Eric Blake
  2015-06-15 16:19   ` Stefan Hajnoczi
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers Markus Armbruster
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

qerror_report_err() is a transitional interface to help with
converting existing monitor commands to QMP.  It should not be used
elsewhere.

The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
used in QMP context?  If not, we can simply replace
qerror_report_err() by error_report_err().

The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are
clearly not in QMP context.

The uses in vl.c aren't either, because the only QMP command handlers
there are qmp_query_status() and qmp_query_machines(), and they don't
call it.

Remaining uses:

* drive_def(): Command line -drive and such, HMP drive_add and pci_add

* hmp_chardev_add(): HMP chardev-add

* monitor_parse_command(): HMP core

* tmp_config_parse(): Command line -tpmdev

* net_host_device_add(): HMP host_net_add

* net_client_parse(): Command line -net and -netdev

* qemu_global_option(): Command line -global

* vnc_parse_func(): Command line -display, -vnc, default display, HMP
  change, QMP change.  Bummer.

* qemu_pci_hot_add_nic(): HMP pci_add

* usb_net_init(): Command line -usbdevice, HMP usb_add

Propoagate errors through qemu_opts_parse().  Create a convenience
function qemu_opts_parse_noisily() that passes errors to
error_report_err().  Switch all non-QMP users outside tests to it.

That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
touching it anyway, rename it to vnc_parse().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 blockdev.c                |   2 +-
 hmp.c                     |   2 +-
 hw/usb/dev-network.c      |   2 +-
 include/qemu/option.h     |   5 ++-
 include/ui/console.h      |   2 +-
 monitor.c                 |   2 +-
 net/net.c                 |   5 ++-
 qdev-monitor.c            |   2 +-
 qemu-img.c                |   3 +-
 qemu-io.c                 |   2 +-
 qemu-nbd.c                |   3 +-
 qmp.c                     |   2 +-
 tests/test-opts-visitor.c |   3 +-
 tests/test-qemu-opts.c    |   2 +-
 tpm.c                     |   2 +-
 ui/vnc.c                  |   4 +-
 util/qemu-option.c        |  25 ++++++++---
 vl.c                      | 103 +++++++++++++++++++++++++++++-----------------
 18 files changed, 109 insertions(+), 62 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index de94a8b..a88ea76 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -173,7 +173,7 @@ static int drive_index_to_unit_id(BlockInterfaceType type, int index)
 
 QemuOpts *drive_def(const char *optstr)
 {
-    return qemu_opts_parse(qemu_find_opts("drive"), optstr, 0);
+    return qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, false);
 }
 
 QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
diff --git a/hmp.c b/hmp.c
index 1e7cac0..05e4927 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1835,7 +1835,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
     QemuOpts *opts;
 
-    opts = qemu_opts_parse(qemu_find_opts("chardev"), args, 1);
+    opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true);
     if (opts == NULL) {
         error_setg(&err, "Parsing chardev args failed");
     } else {
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 743c231..5eeb4c6 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1397,7 +1397,7 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
     QemuOpts *opts;
     int idx;
 
-    opts = qemu_opts_parse(qemu_find_opts("net"), cmdline, 0);
+    opts = qemu_opts_parse_noisily(qemu_find_opts("net"), cmdline, false);
     if (!opts) {
         return NULL;
     }
diff --git a/include/qemu/option.h b/include/qemu/option.h
index ac0e43b..57e51c9 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -119,7 +119,10 @@ void qemu_opts_del(QemuOpts *opts);
 void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp);
 void qemu_opts_do_parse(QemuOpts *opts, const char *params,
                         const char *firstname, Error **errp);
-QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev);
+QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
+                                  bool permit_abbrev);
+QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
+                          bool permit_abbrev, Error **errp);
 void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
                             int permit_abbrev);
 QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
diff --git a/include/ui/console.h b/include/ui/console.h
index de92523..9ad6c17 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -369,7 +369,7 @@ char *vnc_display_local_addr(const char *id);
 #ifdef CONFIG_VNC
 int vnc_display_password(const char *id, const char *password);
 int vnc_display_pw_expire(const char *id, time_t expires);
-QemuOpts *vnc_parse_func(const char *str);
+QemuOpts *vnc_parse(const char *str, Error **errp);
 int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
 #else
 static inline int vnc_display_password(const char *id, const char *password)
diff --git a/monitor.c b/monitor.c
index 6a46424..627f5d4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3753,7 +3753,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 if (get_str(buf, sizeof(buf), &p) < 0) {
                     goto fail;
                 }
-                opts = qemu_opts_parse(opts_list, buf, 1);
+                opts = qemu_opts_parse_noisily(opts_list, buf, true);
                 if (!opts) {
                     goto fail;
                 }
diff --git a/net/net.c b/net/net.c
index 25c2ef3..429012f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1031,7 +1031,8 @@ void hmp_host_net_add(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
+    opts = qemu_opts_parse_noisily(qemu_find_opts("net"),
+                                   opts_str ? opts_str : "", false);
     if (!opts) {
         return;
     }
@@ -1394,7 +1395,7 @@ int net_client_parse(QemuOptsList *opts_list, const char *optarg)
     }
 #endif
 
-    if (!qemu_opts_parse(opts_list, optarg, 1)) {
+    if (!qemu_opts_parse_noisily(opts_list, optarg, true)) {
         return -1;
     }
 
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 686c9df..e1dd367 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -853,7 +853,7 @@ int qemu_global_option(const char *str)
         return 0;
     }
 
-    opts = qemu_opts_parse(&qemu_global_opts, str, false);
+    opts = qemu_opts_parse_noisily(&qemu_global_opts, str, false);
     if (!opts) {
         return -1;
     }
diff --git a/qemu-img.c b/qemu-img.c
index 60c820d..ea964fe 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1590,7 +1590,8 @@ static int img_convert(int argc, char **argv)
             break;
         case 'l':
             if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
-                sn_opts = qemu_opts_parse(&internal_snapshot_opts, optarg, 0);
+                sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
+                                                  optarg, false);
                 if (!sn_opts) {
                     error_report("Failed in parsing snapshot param '%s'",
                                  optarg);
diff --git a/qemu-io.c b/qemu-io.c
index 9bc83c6..c24f6be 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -153,7 +153,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
             readonly = 1;
             break;
         case 'o':
-            if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
+            if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) {
                 printf("could not parse option list -- %s\n", optarg);
                 qemu_opts_reset(&empty_opts);
                 return 0;
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 5af6d11..7a4bf1b 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -549,7 +549,8 @@ int main(int argc, char **argv)
             break;
         case 'l':
             if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
-                sn_opts = qemu_opts_parse(&internal_snapshot_opts, optarg, 0);
+                sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
+                                                  optarg, false);
                 if (!sn_opts) {
                     errx(EXIT_FAILURE, "Failed in parsing snapshot param `%s'",
                          optarg);
diff --git a/qmp.c b/qmp.c
index 3f5dfe3..60658b4 100644
--- a/qmp.c
+++ b/qmp.c
@@ -387,7 +387,7 @@ static void qmp_change_vnc_listen(const char *target, Error **errp)
     if (opts) {
         qemu_opts_del(opts);
     }
-    opts = vnc_parse_func(target);
+    opts = vnc_parse(target, errp);
     if (!opts) {
         return;
     }
diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c
index ebeee5d..1c753d9 100644
--- a/tests/test-opts-visitor.c
+++ b/tests/test-opts-visitor.c
@@ -39,7 +39,8 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_data)
     QemuOpts *opts;
     OptsVisitor *ov;
 
-    opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, 0);
+    opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, false,
+                           NULL);
     g_assert(opts != NULL);
 
     ov = opts_visitor_new(opts);
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index da56492..0c1136d 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -323,7 +323,7 @@ static void test_qemu_opt_unset(void)
     int ret;
 
     /* dynamically initialized (parsed) opts */
-    opts = qemu_opts_parse(&opts_list_03, "key=value", 0);
+    opts = qemu_opts_parse(&opts_list_03, "key=value", false, NULL);
     g_assert(opts != NULL);
 
     /* check default/parsed value */
diff --git a/tpm.c b/tpm.c
index a3f3b7f..b8b0664 100644
--- a/tpm.c
+++ b/tpm.c
@@ -228,7 +228,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
         tpm_display_backend_drivers();
         return -1;
     }
-    opts = qemu_opts_parse(opts_list, optarg, 1);
+    opts = qemu_opts_parse_noisily(opts_list, optarg, true);
     if (!opts) {
         return -1;
     }
diff --git a/ui/vnc.c b/ui/vnc.c
index 69b605c..7f0ce7a 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3749,10 +3749,10 @@ static void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts)
     qemu_opts_set_id(opts, id);
 }
 
-QemuOpts *vnc_parse_func(const char *str)
+QemuOpts *vnc_parse(const char *str, Error **errp)
 {
     QemuOptsList *olist = qemu_find_opts("vnc");
-    QemuOpts *opts = qemu_opts_parse(olist, str, 1);
+    QemuOpts *opts = qemu_opts_parse(olist, str, true, errp);
     const char *id;
 
     if (!opts) {
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 840f5f7..e2f789f 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -820,7 +820,7 @@ void qemu_opts_do_parse(QemuOpts *opts, const char *params,
 }
 
 static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
-                            int permit_abbrev, bool defaults, Error **errp)
+                            bool permit_abbrev, bool defaults, Error **errp)
 {
     const char *firstname;
     char value[1024], *id = NULL;
@@ -867,19 +867,32 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
  * Create a QemuOpts in @list and with options parsed from @params.
  * If @permit_abbrev, the first key=value in @params may omit key=,
  * and is treated as if key was @list->implied_opt_name.
- * Report errors with qerror_report_err().
+ * On error, store an error object through @errp if non-null.
  * Return the new QemuOpts on success, null pointer on error.
  */
 QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
-                          int permit_abbrev)
+                          bool permit_abbrev, Error **errp)
+{
+    return opts_parse(list, params, permit_abbrev, false, errp);
+}
+
+/**
+ * Create a QemuOpts in @list and with options parsed from @params.
+ * If @permit_abbrev, the first key=value in @params may omit key=,
+ * and is treated as if key was @list->implied_opt_name.
+ * Report errors with error_report_err().  This is inappropriate in
+ * QMP context.  Do not use this function there!
+ * Return the new QemuOpts on success, null pointer on error.
+ */
+QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
+                                  bool permit_abbrev)
 {
     Error *err = NULL;
     QemuOpts *opts;
 
     opts = opts_parse(list, params, permit_abbrev, false, &err);
-    if (!opts) {
-        qerror_report_err(err);
-        error_free(err);
+    if (err) {
+        error_report_err(err);
     }
     return opts;
 }
diff --git a/vl.c b/vl.c
index f0dcb6b..f4985a3 100644
--- a/vl.c
+++ b/vl.c
@@ -1955,6 +1955,7 @@ static void select_vgahw (const char *p)
 
 static DisplayType select_display(const char *p)
 {
+    Error *err = NULL;
     const char *opts;
     DisplayType display = DT_DEFAULT;
 
@@ -2023,7 +2024,8 @@ static DisplayType select_display(const char *p)
     } else if (strstart(p, "vnc", &opts)) {
 #ifdef CONFIG_VNC
         if (*opts == '=') {
-            if (vnc_parse_func(opts+1) == NULL) {
+            if (vnc_parse(opts + 1, &err) == NULL) {
+                error_report_err(err);
                 exit(1);
             }
         } else {
@@ -2097,7 +2099,8 @@ static int balloon_parse(const char *arg)
     if (!strncmp(arg, "virtio", 6)) {
         if (arg[6] == ',') {
             /* have params -> parse them */
-            opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
+            opts = qemu_opts_parse_noisily(qemu_find_opts("device"), arg + 7,
+                                           false);
             if (!opts)
                 return  -1;
         } else {
@@ -2945,7 +2948,7 @@ int main(int argc, char **argv, char **envp)
             switch(popt->index) {
             case QEMU_OPTION_no_kvm_irqchip: {
                 olist = qemu_find_opts("machine");
-                qemu_opts_parse(olist, "kernel_irqchip=off", 0);
+                qemu_opts_parse_noisily(olist, "kernel_irqchip=off", false);
                 break;
             }
             case QEMU_OPTION_cpu:
@@ -3062,7 +3065,8 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_numa:
-                opts = qemu_opts_parse(qemu_find_opts("numa"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3113,7 +3117,8 @@ int main(int argc, char **argv, char **envp)
                 drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
                 break;
             case QEMU_OPTION_boot:
-                opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3138,7 +3143,8 @@ int main(int argc, char **argv, char **envp)
                 break;
 #ifdef CONFIG_LIBISCSI
             case QEMU_OPTION_iscsi:
-                opts = qemu_opts_parse(qemu_find_opts("iscsi"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
+                                               optarg, false);
                 if (!opts) {
                     exit(1);
                 }
@@ -3174,8 +3180,8 @@ int main(int argc, char **argv, char **envp)
                 exit(0);
                 break;
             case QEMU_OPTION_m:
-                opts = qemu_opts_parse(qemu_find_opts("memory"),
-                                       optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("memory"),
+                                               optarg, true);
                 if (!opts) {
                     exit(EXIT_FAILURE);
                 }
@@ -3287,14 +3293,16 @@ int main(int argc, char **argv, char **envp)
                 default_monitor = 0;
                 break;
             case QEMU_OPTION_mon:
-                opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
+                                               true);
                 if (!opts) {
                     exit(1);
                 }
                 default_monitor = 0;
                 break;
             case QEMU_OPTION_chardev:
-                opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3305,7 +3313,7 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "fsdev is not supported by this qemu build.\n");
                     exit(1);
                 }
-                opts = qemu_opts_parse(olist, optarg, 1);
+                opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3320,7 +3328,7 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "virtfs is not supported by this qemu build.\n");
                     exit(1);
                 }
-                opts = qemu_opts_parse(olist, optarg, 1);
+                opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3480,40 +3488,43 @@ int main(int argc, char **argv, char **envp)
                 break;
             }
             case QEMU_OPTION_acpitable:
-                opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
                 do_acpitable_option(opts);
                 break;
             case QEMU_OPTION_smbios:
-                opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
+                                               optarg, false);
                 if (!opts) {
                     exit(1);
                 }
                 do_smbios_option(opts);
                 break;
             case QEMU_OPTION_fwcfg:
-                opts = qemu_opts_parse(qemu_find_opts("fw_cfg"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
+                                               optarg, true);
                 if (opts == NULL) {
                     exit(1);
                 }
                 break;
             case QEMU_OPTION_enable_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_parse(olist, "accel=kvm", 0);
+                qemu_opts_parse_noisily(olist, "accel=kvm", false);
                 break;
             case QEMU_OPTION_M:
             case QEMU_OPTION_machine:
                 olist = qemu_find_opts("machine");
-                opts = qemu_opts_parse(olist, optarg, 1);
+                opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
              case QEMU_OPTION_no_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_parse(olist, "accel=tcg", 0);
+                qemu_opts_parse_noisily(olist, "accel=tcg", false);
                 break;
             case QEMU_OPTION_no_kvm_pit: {
                 fprintf(stderr, "Warning: KVM PIT can no longer be disabled "
@@ -3537,26 +3548,32 @@ int main(int argc, char **argv, char **envp)
             }
             case QEMU_OPTION_usb:
                 olist = qemu_find_opts("machine");
-                qemu_opts_parse(olist, "usb=on", 0);
+                qemu_opts_parse_noisily(olist, "usb=on", false);
                 break;
             case QEMU_OPTION_usbdevice:
                 olist = qemu_find_opts("machine");
-                qemu_opts_parse(olist, "usb=on", 0);
+                qemu_opts_parse_noisily(olist, "usb=on", false);
                 add_device_config(DEV_USB, optarg);
                 break;
             case QEMU_OPTION_device:
-                if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
+                if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
+                                             optarg, true)) {
                     exit(1);
                 }
                 break;
             case QEMU_OPTION_smp:
-                if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
+                if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"),
+                                             optarg, true)) {
                     exit(1);
                 }
                 break;
             case QEMU_OPTION_vnc:
+            {
 #ifdef CONFIG_VNC
-                if (vnc_parse_func(optarg) == NULL) {
+                Error *local_err = NULL;
+
+                if (vnc_parse(optarg, &local_err) == NULL) {
+                    error_report_err(local_err);
                     exit(1);
                 }
 #else
@@ -3564,6 +3581,7 @@ int main(int argc, char **argv, char **envp)
                 exit(1);
 #endif
                 break;
+            }
             case QEMU_OPTION_no_acpi:
                 acpi_enabled = 0;
                 break;
@@ -3598,7 +3616,8 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "Too many option ROMs\n");
                     exit(1);
                 }
-                opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3617,8 +3636,8 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_semihosting_config:
                 semihosting_enabled = 1;
-                opts = qemu_opts_parse(qemu_find_opts("semihosting-config"),
-                                           optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("semihosting-config"),
+                                               optarg, false);
                 if (opts != NULL) {
                     semihosting_enabled = qemu_opt_get_bool(opts, "enable",
                                                             true);
@@ -3650,7 +3669,8 @@ int main(int argc, char **argv, char **envp)
                                 "is no longer supported.\n");
                 break;
             case QEMU_OPTION_name:
-                opts = qemu_opts_parse(qemu_find_opts("name"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("name"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3675,7 +3695,8 @@ int main(int argc, char **argv, char **envp)
                 configure_rtc_date_offset(optarg, 1);
                 break;
             case QEMU_OPTION_rtc:
-                opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
+                                               false);
                 if (!opts) {
                     exit(1);
                 }
@@ -3688,8 +3709,8 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_icount:
-                icount_opts = qemu_opts_parse(qemu_find_opts("icount"),
-                                              optarg, 1);
+                icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"),
+                                                      optarg, true);
                 if (!icount_opts) {
                     exit(1);
                 }
@@ -3726,7 +3747,8 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_trace:
             {
-                opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
+                                               optarg, false);
                 if (!opts) {
                     exit(1);
                 }
@@ -3750,7 +3772,7 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "spice is not supported by this qemu build.\n");
                     exit(1);
                 }
-                opts = qemu_opts_parse(olist, optarg, 0);
+                opts = qemu_opts_parse_noisily(olist, optarg, false);
                 if (!opts) {
                     exit(1);
                 }
@@ -3781,14 +3803,16 @@ int main(int argc, char **argv, char **envp)
                 qtest_log = optarg;
                 break;
             case QEMU_OPTION_sandbox:
-                opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
             case QEMU_OPTION_add_fd:
 #ifndef _WIN32
-                opts = qemu_opts_parse(qemu_find_opts("add-fd"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
+                                               optarg, false);
                 if (!opts) {
                     exit(1);
                 }
@@ -3799,20 +3823,23 @@ int main(int argc, char **argv, char **envp)
 #endif
                 break;
             case QEMU_OPTION_object:
-                opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
             case QEMU_OPTION_realtime:
-                opts = qemu_opts_parse(qemu_find_opts("realtime"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
+                                               optarg, false);
                 if (!opts) {
                     exit(1);
                 }
                 enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
                 break;
             case QEMU_OPTION_msg:
-                opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
+                opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg,
+                                               false);
                 if (!opts) {
                     exit(1);
                 }
@@ -4067,7 +4094,7 @@ int main(int argc, char **argv, char **envp)
 #elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
         display_type = DT_SDL;
 #elif defined(CONFIG_VNC)
-        vnc_parse_func("localhost:0,to=99,id=default");
+        vnc_parse("localhost:0,to=99,id=default", &error_abort);
         show_vnc_port = 1;
 #else
         display_type = DT_NONE;
-- 
1.9.3

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

* [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-14  3:09   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors Markus Armbruster
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

qerror_report() is a transitional interface to help with converting
existing monitor commands to QMP.  It should not be used elsewhere.
Replace by error_report() in initial startup helpers parse_sandbox()
and parse_add_fd().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/vl.c b/vl.c
index f4985a3..3a6de4d 100644
--- a/vl.c
+++ b/vl.c
@@ -986,13 +986,13 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
     if (qemu_opt_get_bool(opts, "enable", false)) {
 #ifdef CONFIG_SECCOMP
         if (seccomp_start() < 0) {
-            qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                          "failed to install seccomp syscall filter in the kernel");
+            error_report("failed to install seccomp syscall filter "
+                         "in the kernel");
             return -1;
         }
 #else
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "sandboxing request but seccomp is not compiled into this build");
+        error_report("sandboxing request but seccomp is not compiled "
+                     "into this build");
         return -1;
 #endif
     }
@@ -1040,14 +1040,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
     fd_opaque = qemu_opt_get(opts, "opaque");
 
     if (fd < 0) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "fd option is required and must be non-negative");
+        error_report("fd option is required and must be non-negative");
         return -1;
     }
 
     if (fd <= STDERR_FILENO) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "fd cannot be a standard I/O stream");
+        error_report("fd cannot be a standard I/O stream");
         return -1;
     }
 
@@ -1057,14 +1055,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
      */
     flags = fcntl(fd, F_GETFD);
     if (flags == -1 || (flags & FD_CLOEXEC)) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "fd is not valid or already in use");
+        error_report("fd is not valid or already in use");
         return -1;
     }
 
     if (fdset_id < 0) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "set option is required and must be non-negative");
+        error_report("set option is required and must be non-negative");
         return -1;
     }
 
@@ -1077,8 +1073,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
     }
 #endif
     if (dupfd == -1) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "Error duplicating fd: %s", strerror(errno));
+        error_report("Error duplicating fd: %s", strerror(errno));
         return -1;
     }
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 12:49   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

Results in nicer error messages.  Before this patch:

    Invalid GTK option string: gtk,lirum-larum

After:

    qemu-system-x86_64: -display gtk,lirum-larum: Invalid GTK option string

Of course, the thing ought to use QemuOpts instead of parsing by hand.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/vl.c b/vl.c
index 3a6de4d..10c2cfc 100644
--- a/vl.c
+++ b/vl.c
@@ -2007,13 +2007,13 @@ static DisplayType select_display(const char *p)
                 }
             } else {
             invalid_sdl_args:
-                fprintf(stderr, "Invalid SDL option string: %s\n", p);
+                error_report("Invalid SDL option string");
                 exit(1);
             }
             opts = nextopt;
         }
 #else
-        fprintf(stderr, "SDL support is disabled\n");
+        error_report("SDL support is disabled");
         exit(1);
 #endif
     } else if (strstart(p, "vnc", &opts)) {
@@ -2024,18 +2024,18 @@ static DisplayType select_display(const char *p)
                 exit(1);
             }
         } else {
-            fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
+            error_report("VNC requires a display argument vnc=<display>");
             exit(1);
         }
 #else
-        fprintf(stderr, "VNC support is disabled\n");
+        error_report("VNC support is disabled");
         exit(1);
 #endif
     } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
         display = DT_CURSES;
 #else
-        fprintf(stderr, "Curses support is disabled\n");
+        error_report("Curses support is disabled");
         exit(1);
 #endif
     } else if (strstart(p, "gtk", &opts)) {
@@ -2064,19 +2064,19 @@ static DisplayType select_display(const char *p)
                 }
             } else {
             invalid_gtk_args:
-                fprintf(stderr, "Invalid GTK option string: %s\n", p);
+                error_report("Invalid GTK option string");
                 exit(1);
             }
             opts = nextopt;
         }
 #else
-        fprintf(stderr, "GTK support is disabled\n");
+        error_report("GTK support is disabled");
         exit(1);
 #endif
     } else if (strstart(p, "none", &opts)) {
         display = DT_NONE;
     } else {
-        fprintf(stderr, "Unknown display type: %s\n", p);
+        error_report("Unknown display type");
         exit(1);
     }
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (2 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 13:59   ` Eric Blake
                     ` (2 more replies)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
                   ` (7 subsequent siblings)
  11 siblings, 3 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
Fortunately, there's just one such macro left.  Eliminate it with this
coccinelle semantic patch:

    @@
    expression EP, E;
    @@
    -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
    +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 backends/rng-egd.c        |  3 ++-
 blockdev-nbd.c            |  3 ++-
 blockdev.c                | 33 ++++++++++++++++++++++-----------
 hmp.c                     |  6 ++++--
 include/qapi/qmp/qerror.h |  3 ---
 net/net.c                 |  6 ++++--
 qdev-monitor.c            |  6 ++++--
 qmp.c                     | 12 ++++++++----
 qom/object.c              |  6 ++++--
 ui/input.c                |  3 ++-
 10 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 2962795..849bd7a 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -147,7 +147,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
 
     s->chr = qemu_chr_find(s->chr_name);
     if (s->chr == NULL) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", s->chr_name);
         return;
     }
 
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 0d9df47..128e810 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -91,7 +91,8 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     if (!blk_is_inserted(blk)) {
diff --git a/blockdev.c b/blockdev.c
index a88ea76..8dec0cc 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1102,7 +1102,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return NULL;
     }
     bs = blk_bs(blk);
@@ -1291,7 +1292,8 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
     /* 2. check for validation */
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -1571,7 +1573,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
 
     blk = blk_by_name(backup->device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", backup->device);
         return;
     }
     bs = blk_bs(blk);
@@ -1841,7 +1844,8 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
 
@@ -1901,7 +1905,8 @@ void qmp_change_blockdev(const char *device, const char *filename,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -1960,7 +1965,8 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -2275,7 +2281,8 @@ void qmp_block_stream(const char *device,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -2349,7 +2356,8 @@ void qmp_block_commit(const char *device,
      *  scenario in which all optional arguments are omitted. */
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -2461,7 +2469,8 @@ void qmp_drive_backup(const char *device, const char *target,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -2675,7 +2684,8 @@ void qmp_drive_mirror(const char *device, const char *target,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
@@ -2941,7 +2951,8 @@ void qmp_change_backing_file(const char *device,
 
     blk = blk_by_name(device);
     if (!blk) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
         return;
     }
     bs = blk_bs(blk);
diff --git a/hmp.c b/hmp.c
index 05e4927..6f63927 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1863,7 +1863,8 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
     if (blk) {
         qemuio_command(blk, command);
     } else {
-        error_set(&err, QERR_DEVICE_NOT_FOUND, device);
+        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device);
     }
 
     hmp_handle_error(mon, &err);
@@ -1991,7 +1992,8 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
 
     obj = object_resolve_path(path, &ambiguous);
     if (obj == NULL) {
-        error_set(&err, QERR_DEVICE_NOT_FOUND, path);
+        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", path);
     } else {
         if (ambiguous) {
             monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 6468e40..2841344 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -55,9 +55,6 @@ void qerror_report_err(Error *err);
 #define QERR_DEVICE_NO_HOTPLUG \
     ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
 
-#define QERR_DEVICE_NOT_FOUND \
-    ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
-
 #define QERR_FD_NOT_FOUND \
     ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
 
diff --git a/net/net.c b/net/net.c
index 429012f..212762d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1109,7 +1109,8 @@ void qmp_netdev_del(const char *id, Error **errp)
 
     nc = qemu_find_netdev(id);
     if (!nc) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, id);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", id);
         return;
     }
 
@@ -1220,7 +1221,8 @@ void qmp_set_link(const char *name, bool up, Error **errp)
                                           MAX_QUEUE_NUM);
 
     if (queues == 0) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, name);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", name);
         return;
     }
     nc = ncs[0];
diff --git a/qdev-monitor.c b/qdev-monitor.c
index e1dd367..7bd7d25 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -457,7 +457,8 @@ static BusState *qbus_find(const char *path, Error **errp)
         pos += len;
         dev = qbus_find_dev(bus, elem);
         if (!dev) {
-            error_set(errp, QERR_DEVICE_NOT_FOUND, elem);
+            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                      "Device '%s' not found", elem);
 #if 0 /* conversion from qerror_report() to error_set() broke this: */
             if (!monitor_cur_is_qmp()) {
                 qbus_list_dev(bus);
@@ -793,7 +794,8 @@ void qmp_device_del(const char *id, Error **errp)
     g_free(path);
 
     if (!obj) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, id);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", id);
         return;
     }
 
diff --git a/qmp.c b/qmp.c
index 60658b4..14f7536 100644
--- a/qmp.c
+++ b/qmp.c
@@ -206,7 +206,8 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
         if (ambiguous) {
             error_setg(errp, "Path '%s' is ambiguous", path);
         } else {
-            error_set(errp, QERR_DEVICE_NOT_FOUND, path);
+            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                      "Device '%s' not found", path);
         }
         return NULL;
     }
@@ -236,7 +237,8 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
 
     obj = object_resolve_path(path, NULL);
     if (!obj) {
-        error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
+        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", path);
         goto out;
     }
 
@@ -261,7 +263,8 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)
 
     obj = object_resolve_path(path, NULL);
     if (!obj) {
-        error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
+        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", path);
         goto out;
     }
 
@@ -518,7 +521,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
 
     klass = object_class_by_name(typename);
     if (klass == NULL) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, typename);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", typename);
         return NULL;
     }
 
diff --git a/qom/object.c b/qom/object.c
index 96abd34..62fa44e 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -890,7 +890,8 @@ Object *object_property_get_link(Object *obj, const char *name,
     if (str && *str) {
         target = object_resolve_path(str, NULL);
         if (!target) {
-            error_set(errp, QERR_DEVICE_NOT_FOUND, str);
+            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                      "Device '%s' not found", str);
         }
     }
 
@@ -1170,7 +1171,8 @@ static Object *object_resolve_link(Object *obj, const char *name,
         if (target || ambiguous) {
             error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
         } else {
-            error_set(errp, QERR_DEVICE_NOT_FOUND, path);
+            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                      "Device '%s' not found", path);
         }
         target = NULL;
     }
diff --git a/ui/input.c b/ui/input.c
index eeeabe8..e96e1ea 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -84,7 +84,8 @@ void qemu_input_handler_bind(QemuInputHandlerState *s,
 
     dev = qdev_find_recursive(sysbus_get_default(), device_id);
     if (dev == NULL) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, device_id);
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device_id);
         return;
     }
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (3 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 15:12   ` Stefan Hajnoczi
  2015-06-15 16:09   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers Markus Armbruster
                   ` (6 subsequent siblings)
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

These macros expand into error class enumeration constant, comma,
string.  Unclean.  Has been that way since commit 13f59ae.

The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
commit.

Clean up as follows:

* Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
  delete it from the QERR_ macro.  No change after preprocessing.

* Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
  error_setg(...).  Again, no change after preprocessing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 backends/rng-egd.c               |  8 ++---
 backends/rng-random.c            |  6 ++--
 backends/rng.c                   |  2 +-
 backends/tpm.c                   |  2 +-
 balloon.c                        |  2 +-
 block.c                          |  2 +-
 block/backup.c                   |  4 +--
 block/commit.c                   |  2 +-
 block/mirror.c                   |  8 ++---
 block/qcow.c                     |  4 +--
 block/qcow2.c                    |  4 +--
 block/qed.c                      |  4 +--
 block/quorum.c                   |  4 +--
 block/snapshot.c                 |  4 +--
 block/stream.c                   |  4 +--
 block/vmdk.c                     | 12 ++++----
 blockdev-nbd.c                   |  2 +-
 blockdev.c                       | 43 +++++++++++++-------------
 blockjob.c                       |  8 ++---
 cpus.c                           |  8 ++---
 dump.c                           | 12 ++++----
 hmp.c                            | 10 +++---
 hw/core/nmi.c                    |  2 +-
 hw/core/qdev-properties-system.c |  3 +-
 hw/core/qdev-properties.c        | 12 ++++----
 hw/core/qdev.c                   |  8 ++---
 hw/intc/openpic.c                |  6 ++--
 hw/pci/pci-stub.c                |  2 +-
 hw/ppc/spapr_pci.c               |  8 ++---
 hw/s390x/s390-virtio.c           |  2 +-
 hw/usb/redirect.c                |  6 ++--
 include/qapi/qmp/qerror.h        | 60 ++++++++++++++++++------------------
 migration/migration.c            | 35 ++++++++++-----------
 migration/savevm.c               |  2 +-
 monitor.c                        | 66 ++++++++++++++++++++--------------------
 net/net.c                        | 12 ++++----
 qapi/opts-visitor.c              | 24 +++++++--------
 qapi/qapi-visit-core.c           | 28 ++++++++---------
 qapi/qmp-dispatch.c              | 12 ++++----
 qapi/qmp-input-visitor.c         | 28 ++++++++---------
 qapi/string-input-visitor.c      | 24 +++++++--------
 qdev-monitor.c                   | 12 ++++----
 qemu-img.c                       |  2 +-
 qga/commands-posix.c             | 40 ++++++++++++------------
 qga/commands-win32.c             | 66 ++++++++++++++++++++--------------------
 qga/main.c                       |  4 +--
 qmp.c                            | 34 ++++++++++-----------
 qom/object.c                     | 12 ++++----
 stubs/arch-query-cpu-def.c       |  2 +-
 target-i386/cpu.c                | 19 ++++++------
 tpm.c                            |  8 +++--
 ui/vnc.c                         |  4 +--
 util/qemu-option.c               | 22 ++++++++------
 53 files changed, 362 insertions(+), 358 deletions(-)

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 849bd7a..225221e 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -140,8 +140,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
     RngEgd *s = RNG_EGD(b);
 
     if (s->chr_name == NULL) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "chardev", "a valid character device");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "chardev",
+                   "a valid character device");
         return;
     }
 
@@ -153,7 +153,7 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
     }
 
     if (qemu_chr_fe_claim(s->chr) != 0) {
-        error_set(errp, QERR_DEVICE_IN_USE, s->chr_name);
+        error_setg(errp, QERR_DEVICE_IN_USE, s->chr_name);
         return;
     }
 
@@ -168,7 +168,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
     RngEgd *s = RNG_EGD(b);
 
     if (b->opened) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
     } else {
         g_free(s->chr_name);
         s->chr_name = g_strdup(value);
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 4f85a8e..b595a1c 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -74,8 +74,8 @@ static void rng_random_opened(RngBackend *b, Error **errp)
     RndRandom *s = RNG_RANDOM(b);
 
     if (s->filename == NULL) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "filename", "a valid filename");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "filename",
+                   "a valid filename");
     } else {
         s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK);
         if (s->fd == -1) {
@@ -98,7 +98,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
     RndRandom *s = RNG_RANDOM(obj);
 
     if (b->opened) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
diff --git a/backends/rng.c b/backends/rng.c
index 0f2fc11..5065fdc 100644
--- a/backends/rng.c
+++ b/backends/rng.c
@@ -57,7 +57,7 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
     }
 
     if (!value && s->opened) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
diff --git a/backends/tpm.c b/backends/tpm.c
index f3ab3b3..a512693 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -133,7 +133,7 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp)
     }
 
     if (!value && s->opened) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
diff --git a/balloon.c b/balloon.c
index c7033e3..5f5202c 100644
--- a/balloon.c
+++ b/balloon.c
@@ -96,7 +96,7 @@ void qmp_balloon(int64_t target, Error **errp)
     }
 
     if (target <= 0) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
         return;
     }
 
diff --git a/block.c b/block.c
index 2b9ceae..b642d9f 100644
--- a/block.c
+++ b/block.c
@@ -2518,7 +2518,7 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
             error_setg(errp, "Node '%s' is not encrypted",
                       bdrv_get_device_or_node_name(bs));
         } else if (bdrv_set_key(bs, key) < 0) {
-            error_set(errp, QERR_INVALID_PASSWORD);
+            error_setg(errp, QERR_INVALID_PASSWORD);
         }
     } else {
         if (bdrv_key_required(bs)) {
diff --git a/block/backup.c b/block/backup.c
index d3f648d..35145cb 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -197,7 +197,7 @@ static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
     BackupBlockJob *s = container_of(job, BackupBlockJob, common);
 
     if (speed < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER, "speed");
+        error_setg(errp, QERR_INVALID_PARAMETER, "speed");
         return;
     }
     ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -472,7 +472,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
     if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
          on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
         !bdrv_iostatus_is_enabled(bs)) {
-        error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
+        error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
         return;
     }
 
diff --git a/block/commit.c b/block/commit.c
index cfa2bbe..6c01fea 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -186,7 +186,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
     CommitBlockJob *s = container_of(job, CommitBlockJob, common);
 
     if (speed < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER, "speed");
+        error_setg(errp, QERR_INVALID_PARAMETER, "speed");
         return;
     }
     ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
diff --git a/block/mirror.c b/block/mirror.c
index 58f391a..e3e51a2 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -573,7 +573,7 @@ static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp)
     MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
 
     if (speed < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER, "speed");
+        error_setg(errp, QERR_INVALID_PARAMETER, "speed");
         return;
     }
     ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -598,8 +598,8 @@ static void mirror_complete(BlockJob *job, Error **errp)
         return;
     }
     if (!s->synced) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_READY,
-                  bdrv_get_device_name(job->bs));
+        error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
+                   bdrv_get_device_name(job->bs));
         return;
     }
 
@@ -667,7 +667,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
     if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
          on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
         !bdrv_iostatus_is_enabled(bs)) {
-        error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
+        error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
         return;
     }
 
diff --git a/block/qcow.c b/block/qcow.c
index 911e59f..54152f9 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -123,8 +123,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
         char version[64];
         snprintf(version, sizeof(version), "QCOW version %" PRIu32,
                  header.version);
-        error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
-                  bdrv_get_device_or_node_name(bs), "qcow", version);
+        error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+                   bdrv_get_device_or_node_name(bs), "qcow", version);
         ret = -ENOTSUP;
         goto fail;
     }
diff --git a/block/qcow2.c b/block/qcow2.c
index f7b4cc6..c4e1f94 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -207,8 +207,8 @@ static void GCC_FMT_ATTR(3, 4) report_unsupported(BlockDriverState *bs,
     vsnprintf(msg, sizeof(msg), fmt, ap);
     va_end(ap);
 
-    error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
-              bdrv_get_device_or_node_name(bs), "qcow2", msg);
+    error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+               bdrv_get_device_or_node_name(bs), "qcow2", msg);
 }
 
 static void report_unsupported_feature(BlockDriverState *bs,
diff --git a/block/qed.c b/block/qed.c
index 5bbe069..954ed00 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -407,8 +407,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
         char buf[64];
         snprintf(buf, sizeof(buf), "%" PRIx64,
             s->header.features & ~QED_FEATURE_MASK);
-        error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
-            bdrv_get_device_or_node_name(bs), "QED", buf);
+        error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+                   bdrv_get_device_or_node_name(bs), "QED", buf);
         return -ENOTSUP;
     }
     if (!qed_is_cluster_size_valid(s->header.cluster_size)) {
diff --git a/block/quorum.c b/block/quorum.c
index f91ef75..3582538 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -800,8 +800,8 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp)
 {
 
     if (threshold < 1) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "vote-threshold", "value >= 1");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "vote-threshold",
+                   "value >= 1");
         return -ERANGE;
     }
 
diff --git a/block/snapshot.c b/block/snapshot.c
index 50ae610..7cd960c 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -229,7 +229,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
 {
     BlockDriver *drv = bs->drv;
     if (!drv) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
         return -ENOMEDIUM;
     }
     if (!snapshot_id && !name) {
@@ -315,7 +315,7 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs,
     BlockDriver *drv = bs->drv;
 
     if (!drv) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
         return -ENOMEDIUM;
     }
     if (!snapshot_id && !name) {
diff --git a/block/stream.c b/block/stream.c
index a628901..f17efdb 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -227,7 +227,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
     StreamBlockJob *s = container_of(job, StreamBlockJob, common);
 
     if (speed < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER, "speed");
+        error_setg(errp, QERR_INVALID_PARAMETER, "speed");
         return;
     }
     ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -250,7 +250,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
     if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
          on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
         !bdrv_iostatus_is_enabled(bs)) {
-        error_set(errp, QERR_INVALID_PARAMETER, "on-error");
+        error_setg(errp, QERR_INVALID_PARAMETER, "on-error");
         return;
     }
 
diff --git a/block/vmdk.c b/block/vmdk.c
index b66745d..e08bb69 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -669,8 +669,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
         char buf[64];
         snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
                  le32_to_cpu(header.version));
-        error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
-                  bdrv_get_device_or_node_name(bs), "vmdk", buf);
+        error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+                   bdrv_get_device_or_node_name(bs), "vmdk", buf);
         return -ENOTSUP;
     } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
         /* VMware KB 2064959 explains that version 3 added support for
@@ -1700,12 +1700,12 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
     /* write all the data */
     ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic));
     if (ret < 0) {
-        error_set(errp, QERR_IO_ERROR);
+        error_setg(errp, QERR_IO_ERROR);
         goto exit;
     }
     ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header));
     if (ret < 0) {
-        error_set(errp, QERR_IO_ERROR);
+        error_setg(errp, QERR_IO_ERROR);
         goto exit;
     }
 
@@ -1725,7 +1725,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
     ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
                       gd_buf, gd_buf_size);
     if (ret < 0) {
-        error_set(errp, QERR_IO_ERROR);
+        error_setg(errp, QERR_IO_ERROR);
         goto exit;
     }
 
@@ -1737,7 +1737,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
     ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
                       gd_buf, gd_buf_size);
     if (ret < 0) {
-        error_set(errp, QERR_IO_ERROR);
+        error_setg(errp, QERR_IO_ERROR);
         goto exit;
     }
 
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 128e810..944c1b6 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -96,7 +96,7 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
         return;
     }
     if (!blk_is_inserted(blk)) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         return;
     }
 
diff --git a/blockdev.c b/blockdev.c
index 8dec0cc..35008d9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1303,7 +1303,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
     aio_context_acquire(state->aio_context);
 
     if (!bdrv_is_inserted(bs)) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         return;
     }
 
@@ -1444,7 +1444,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
     /* start processing */
     drv = bdrv_find_format(format);
     if (!drv) {
-        error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+        error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
         return;
     }
 
@@ -1471,7 +1471,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
     aio_context_acquire(state->aio_context);
 
     if (!bdrv_is_inserted(state->old_bs)) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         return;
     }
 
@@ -1482,13 +1482,13 @@ static void external_snapshot_prepare(BlkTransactionState *common,
 
     if (!bdrv_is_read_only(state->old_bs)) {
         if (bdrv_flush(state->old_bs)) {
-            error_set(errp, QERR_IO_ERROR);
+            error_setg(errp, QERR_IO_ERROR);
             return;
         }
     }
 
     if (!bdrv_is_first_non_filter(state->old_bs)) {
-        error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
+        error_setg(errp, QERR_FEATURE_DISABLED, "snapshot");
         return;
     }
 
@@ -1917,7 +1917,7 @@ void qmp_change_blockdev(const char *device, const char *filename,
     if (format) {
         drv = bdrv_find_whitelisted_format(format, bs->read_only);
         if (!drv) {
-            error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+            error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
             goto out;
         }
     }
@@ -2192,17 +2192,17 @@ void qmp_block_resize(bool has_device, const char *device,
     aio_context_acquire(aio_context);
 
     if (!bdrv_is_first_non_filter(bs)) {
-        error_set(errp, QERR_FEATURE_DISABLED, "resize");
+        error_setg(errp, QERR_FEATURE_DISABLED, "resize");
         goto out;
     }
 
     if (size < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
         goto out;
     }
 
     if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
-        error_set(errp, QERR_DEVICE_IN_USE, device);
+        error_setg(errp, QERR_DEVICE_IN_USE, device);
         goto out;
     }
 
@@ -2214,16 +2214,16 @@ void qmp_block_resize(bool has_device, const char *device,
     case 0:
         break;
     case -ENOMEDIUM:
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         break;
     case -ENOTSUP:
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         break;
     case -EACCES:
         error_setg(errp, "Device '%s' is read only", device);
         break;
     case -EBUSY:
-        error_set(errp, QERR_DEVICE_IN_USE, device);
+        error_setg(errp, QERR_DEVICE_IN_USE, device);
         break;
     default:
         error_setg_errno(errp, -ret, "Could not resize");
@@ -2297,7 +2297,7 @@ void qmp_block_stream(const char *device,
     if (has_base) {
         base_bs = bdrv_find_backing_image(bs, base);
         if (base_bs == NULL) {
-            error_set(errp, QERR_BASE_NOT_FOUND, base);
+            error_setg(errp, QERR_BASE_NOT_FOUND, base);
             goto out;
         }
         assert(bdrv_get_aio_context(base_bs) == aio_context);
@@ -2395,7 +2395,7 @@ void qmp_block_commit(const char *device,
     }
 
     if (base_bs == NULL) {
-        error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
+        error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
         goto out;
     }
 
@@ -2481,7 +2481,7 @@ void qmp_drive_backup(const char *device, const char *target,
     /* Although backup_run has this check too, we need to use bs->drv below, so
      * do an early check redundantly. */
     if (!bdrv_is_inserted(bs)) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         goto out;
     }
 
@@ -2491,7 +2491,7 @@ void qmp_drive_backup(const char *device, const char *target,
     if (format) {
         drv = bdrv_find_format(format);
         if (!drv) {
-            error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+            error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
             goto out;
         }
     }
@@ -2673,12 +2673,13 @@ void qmp_drive_mirror(const char *device, const char *target,
     }
 
     if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
-                  "a value in range [512B, 64MB]");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
+                   "a value in range [512B, 64MB]");
         return;
     }
     if (granularity & (granularity - 1)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
+                   "power of 2");
         return;
     }
 
@@ -2694,7 +2695,7 @@ void qmp_drive_mirror(const char *device, const char *target,
     aio_context_acquire(aio_context);
 
     if (!bdrv_is_inserted(bs)) {
-        error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+        error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         goto out;
     }
 
@@ -2704,7 +2705,7 @@ void qmp_drive_mirror(const char *device, const char *target,
     if (format) {
         drv = bdrv_find_format(format);
         if (!drv) {
-            error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+            error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
             goto out;
         }
     }
diff --git a/blockjob.c b/blockjob.c
index 2755465..b033f68 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -42,7 +42,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
     BlockJob *job;
 
     if (bs->job) {
-        error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
+        error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
         return NULL;
     }
     bdrv_ref(bs);
@@ -93,7 +93,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
     Error *local_err = NULL;
 
     if (!job->driver->set_speed) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         return;
     }
     job->driver->set_speed(job, speed, &local_err);
@@ -108,8 +108,8 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
 void block_job_complete(BlockJob *job, Error **errp)
 {
     if (job->pause_count || job->cancelled || !job->driver->complete) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_READY,
-                  bdrv_get_device_name(job->bs));
+        error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
+                   bdrv_get_device_name(job->bs));
         return;
     }
 
diff --git a/cpus.c b/cpus.c
index b85fb5f..a928f49 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1512,8 +1512,8 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
 
     cpu = qemu_get_cpu(cpu_index);
     if (cpu == NULL) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
-                  "a CPU number");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+                   "a CPU number");
         return;
     }
 
@@ -1533,7 +1533,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
             goto exit;
         }
         if (fwrite(buf, 1, l, f) != l) {
-            error_set(errp, QERR_IO_ERROR);
+            error_setg(errp, QERR_IO_ERROR);
             goto exit;
         }
         addr += l;
@@ -1563,7 +1563,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
             l = size;
         cpu_physical_memory_read(addr, buf, l);
         if (fwrite(buf, 1, l, f) != l) {
-            error_set(errp, QERR_IO_ERROR);
+            error_setg(errp, QERR_IO_ERROR);
             goto exit;
         }
         addr += l;
diff --git a/dump.c b/dump.c
index 9c7dad8..9a02b51 100644
--- a/dump.c
+++ b/dump.c
@@ -1474,7 +1474,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
 
     s->start = get_start_block(s);
     if (s->start == -1) {
-        error_set(errp, QERR_INVALID_PARAMETER, "begin");
+        error_setg(errp, QERR_INVALID_PARAMETER, "begin");
         goto cleanup;
     }
 
@@ -1484,14 +1484,14 @@ static void dump_init(DumpState *s, int fd, bool has_format,
      */
     ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
     if (ret < 0) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         goto cleanup;
     }
 
     s->note_size = cpu_get_note_size(s->dump_info.d_class,
                                      s->dump_info.d_machine, nr_cpus);
     if (s->note_size < 0) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         goto cleanup;
     }
 
@@ -1615,11 +1615,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
         return;
     }
     if (has_begin && !has_length) {
-        error_set(errp, QERR_MISSING_PARAMETER, "length");
+        error_setg(errp, QERR_MISSING_PARAMETER, "length");
         return;
     }
     if (!has_begin && has_length) {
-        error_set(errp, QERR_MISSING_PARAMETER, "begin");
+        error_setg(errp, QERR_MISSING_PARAMETER, "begin");
         return;
     }
 
@@ -1656,7 +1656,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
     }
 
     if (fd == -1) {
-        error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+        error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
         return;
     }
 
diff --git a/hmp.c b/hmp.c
index 6f63927..2b734ea 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1043,7 +1043,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     if (!filename) {
-        error_set(&err, QERR_MISSING_PARAMETER, "target");
+        error_setg(&err, QERR_MISSING_PARAMETER, "target");
         hmp_handle_error(mon, &err);
         return;
     }
@@ -1073,7 +1073,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     if (!filename) {
-        error_set(&err, QERR_MISSING_PARAMETER, "target");
+        error_setg(&err, QERR_MISSING_PARAMETER, "target");
         hmp_handle_error(mon, &err);
         return;
     }
@@ -1103,7 +1103,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
     if (!filename) {
         /* In the future, if 'snapshot-file' is not specified, the snapshot
            will be taken internally. Today it's actually required. */
-        error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file");
+        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
         hmp_handle_error(mon, &err);
         return;
     }
@@ -1198,7 +1198,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
     }
 
     if (i == MIGRATION_CAPABILITY_MAX) {
-        error_set(&err, QERR_INVALID_PARAMETER, cap);
+        error_setg(&err, QERR_INVALID_PARAMETER, cap);
     }
 
     qapi_free_MigrationCapabilityStatusList(caps);
@@ -1242,7 +1242,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
     }
 
     if (i == MIGRATION_PARAMETER_MAX) {
-        error_set(&err, QERR_INVALID_PARAMETER, param);
+        error_setg(&err, QERR_INVALID_PARAMETER, param);
     }
 
     if (err) {
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 3dff020..0c0d252 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -66,7 +66,7 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
     if (ns.handled) {
         error_propagate(errp, ns.errp);
     } else {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
     }
 }
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 0309fe5..31ac213 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -326,8 +326,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
 
     hubport = net_hub_port_find(id);
     if (!hubport) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  name, prop->info->name);
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, prop->info->name);
         return;
     }
     *ptr = hubport;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a1606de..efec933 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -570,8 +570,8 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
         if (local_err) {
             error_propagate(errp, local_err);
         } else if (value < -1 || value > 255) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "pci_devfn");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "pci_devfn");
         } else {
             *ptr = value;
         }
@@ -640,8 +640,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
     }
     /* value of 0 means "unset" */
     if (value && (value < min || value > max)) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, (int64_t)value, min, max);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, dev->id ? : "",
+                   name, (int64_t)value, min, max);
         return;
     }
 
@@ -923,8 +923,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
         break;
     default:
     case -EINVAL:
-        error_set(errp, QERR_PROPERTY_VALUE_BAD,
-                  object_get_typename(OBJECT(dev)), prop->name, value);
+        error_setg(errp, QERR_PROPERTY_VALUE_BAD,
+                   object_get_typename(OBJECT(dev)), prop->name, value);
         break;
     case -ENOENT:
         error_setg(errp, "Property '%s.%s' can't find value '%s'",
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d433675..fa85735 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -276,13 +276,13 @@ void qdev_unplug(DeviceState *dev, Error **errp)
     HotplugHandlerClass *hdc;
 
     if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
-        error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
+        error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
         return;
     }
 
     if (!dc->hotpluggable) {
-        error_set(errp, QERR_DEVICE_NO_HOTPLUG,
-                  object_get_typename(OBJECT(dev)));
+        error_setg(errp, QERR_DEVICE_NO_HOTPLUG,
+                   object_get_typename(OBJECT(dev)));
         return;
     }
 
@@ -1024,7 +1024,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
     Error *local_err = NULL;
 
     if (dev->hotplugged && !dc->hotpluggable) {
-        error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
+        error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
         return;
     }
 
diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index 87fe2e8..78b7672 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -1556,9 +1556,9 @@ static void openpic_realize(DeviceState *dev, Error **errp)
     };
 
     if (opp->nb_cpus > MAX_CPU) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  TYPE_OPENPIC, "nb_cpus", (uint64_t)opp->nb_cpus,
-                  (uint64_t)0, (uint64_t)MAX_CPU);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, TYPE_OPENPIC,
+                   "nb_cpus", (uint64_t)opp->nb_cpus, (uint64_t)0,
+                   (uint64_t)MAX_CPU);
         return;
     }
 
diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index f8f237e..9b51d37 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -25,7 +25,7 @@
 
 PciInfoList *qmp_query_pci(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 4df3a33..d4a6150 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1062,8 +1062,8 @@ static void spapr_phb_hot_plug_child(HotplugHandler *plug_handler,
          * we need to let them know it's not enabled
          */
         if (plugged_dev->hotplugged) {
-            error_set(errp, QERR_BUS_NO_HOTPLUG,
-                      object_get_typename(OBJECT(phb)));
+            error_setg(errp, QERR_BUS_NO_HOTPLUG,
+                       object_get_typename(OBJECT(phb)));
         }
         return;
     }
@@ -1090,8 +1090,8 @@ static void spapr_phb_hot_unplug_child(HotplugHandler *plug_handler,
     Error *local_err = NULL;
 
     if (!phb->dr_enabled) {
-        error_set(errp, QERR_BUS_NO_HOTPLUG,
-                  object_get_typename(OBJECT(phb)));
+        error_setg(errp, QERR_BUS_NO_HOTPLUG,
+                   object_get_typename(OBJECT(phb)));
         return;
     }
 
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 59750db..d20b27f 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -324,7 +324,7 @@ void s390_nmi(NMIState *n, int cpu_index, Error **errp)
     CPUState *cs = qemu_get_cpu(cpu_index);
 
     if (s390_cpu_restart(S390_CPU(cs))) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
     }
 }
 
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 6b4218c..2322067 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1369,7 +1369,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
     int i;
 
     if (dev->cs == NULL) {
-        error_set(errp, QERR_MISSING_PARAMETER, "chardev");
+        error_setg(errp, QERR_MISSING_PARAMETER, "chardev");
         return;
     }
 
@@ -1378,8 +1378,8 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
                                            &dev->filter_rules,
                                            &dev->filter_rules_count);
         if (i) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "filter",
-                      "a usb device filter string");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "filter",
+                       "a usb device filter string");
             return;
         }
     }
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 2841344..e34741e 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -35,93 +35,93 @@ void qerror_report_err(Error *err);
  * Use scripts/check-qerror.sh to check.
  */
 #define QERR_BASE_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
+    "Base '%s' not found"
 
 #define QERR_BLOCK_JOB_NOT_READY \
-    ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed"
+    "The active block job for device '%s' cannot be completed"
 
 #define QERR_BUS_NO_HOTPLUG \
-    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
+    "Bus '%s' does not support hotplugging"
 
 #define QERR_DEVICE_HAS_NO_MEDIUM \
-    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
+    "Device '%s' has no medium"
 
 #define QERR_DEVICE_INIT_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
+    "Device '%s' could not be initialized"
 
 #define QERR_DEVICE_IN_USE \
-    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
+    "Device '%s' is in use"
 
 #define QERR_DEVICE_NO_HOTPLUG \
-    ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
+    "Device '%s' does not support hotplugging"
 
 #define QERR_FD_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
+    "File descriptor named '%s' not found"
 
 #define QERR_FD_NOT_SUPPLIED \
-    ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
+    "No file descriptor supplied via SCM_RIGHTS"
 
 #define QERR_FEATURE_DISABLED \
-    ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
+    "The feature '%s' is not enabled"
 
 #define QERR_INVALID_BLOCK_FORMAT \
-    ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
+    "Invalid block format '%s'"
 
 #define QERR_INVALID_PARAMETER \
-    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
+    "Invalid parameter '%s'"
 
 #define QERR_INVALID_PARAMETER_TYPE \
-    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
+    "Invalid parameter type for '%s', expected: %s"
 
 #define QERR_INVALID_PARAMETER_VALUE \
-    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
+    "Parameter '%s' expects %s"
 
 #define QERR_INVALID_PASSWORD \
-    ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
+    "Password incorrect"
 
 #define QERR_IO_ERROR \
-    ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
+    "An IO error has occurred"
 
 #define QERR_JSON_PARSING \
-    ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
+    "Invalid JSON syntax"
 
 #define QERR_MIGRATION_ACTIVE \
-    ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
+    "There's a migration process in progress"
 
 #define QERR_MISSING_PARAMETER \
-    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
+    "Parameter '%s' is missing"
 
 #define QERR_PERMISSION_DENIED \
-    ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
+    "Insufficient permission to perform this operation"
 
 #define QERR_PROPERTY_VALUE_BAD \
-    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
+    "Property '%s.%s' doesn't take value '%s'"
 
 #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
-    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
+    "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
 
 #define QERR_QGA_COMMAND_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
+    "Guest agent command failed, error was '%s'"
 
 #define QERR_QMP_BAD_INPUT_OBJECT \
-    ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
+    "Expected '%s' in QMP input"
 
 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
-    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
+    "QMP input object member '%s' expects '%s'"
 
 #define QERR_QMP_EXTRA_MEMBER \
-    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
+    "QMP input object member '%s' is unexpected"
 
 #define QERR_SET_PASSWD_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "Could not set password"
+    "Could not set password"
 
 #define QERR_UNDEFINED_ERROR \
-    ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
+    "An undefined error has occurred"
 
 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
-    ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
+    "'%s' uses a %s feature which is not supported by this qemu version: %s"
 
 #define QERR_UNSUPPORTED \
-    ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
+    "this feature or command is not currently supported"
 
 #endif /* QERROR_H */
diff --git a/migration/migration.c b/migration/migration.c
index b04b457..a46deb2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -337,7 +337,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
 
     if (s->state == MIGRATION_STATUS_ACTIVE ||
         s->state == MIGRATION_STATUS_SETUP) {
-        error_set(errp, QERR_MIGRATION_ACTIVE);
+        error_setg(errp, QERR_MIGRATION_ACTIVE);
         return;
     }
 
@@ -356,22 +356,22 @@ void qmp_migrate_set_parameters(bool has_compress_level,
     MigrationState *s = migrate_get_current();
 
     if (has_compress_level && (compress_level < 0 || compress_level > 9)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
-                  "is invalid, it should be in the range of 0 to 9");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
+                   "is invalid, it should be in the range of 0 to 9");
         return;
     }
     if (has_compress_threads &&
             (compress_threads < 1 || compress_threads > 255)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "compress_threads",
-                  "is invalid, it should be in the range of 1 to 255");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                   "compress_threads",
+                   "is invalid, it should be in the range of 1 to 255");
         return;
     }
     if (has_decompress_threads &&
             (decompress_threads < 1 || decompress_threads > 255)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "decompress_threads",
-                  "is invalid, it should be in the range of 1 to 255");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                   "decompress_threads",
+                   "is invalid, it should be in the range of 1 to 255");
         return;
     }
 
@@ -573,7 +573,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     if (s->state == MIGRATION_STATUS_ACTIVE ||
         s->state == MIGRATION_STATUS_SETUP ||
         s->state == MIGRATION_STATUS_CANCELLING) {
-        error_set(errp, QERR_MIGRATION_ACTIVE);
+        error_setg(errp, QERR_MIGRATION_ACTIVE);
         return;
     }
 
@@ -608,7 +608,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
         fd_start_outgoing_migration(s, p, &local_err);
 #endif
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri",
+                   "a valid migration protocol");
         s->state = MIGRATION_STATUS_FAILED;
         return;
     }
@@ -632,22 +633,22 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
 
     /* Check for truncation */
     if (value != (size_t)value) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
-                  "exceeding address space");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+                   "exceeding address space");
         return;
     }
 
     /* Cache should not be larger than guest ram size */
     if (value > ram_bytes_total()) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
-                  "exceeds guest ram size ");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+                   "exceeds guest ram size ");
         return;
     }
 
     new_size = xbzrle_cache_resize(value);
     if (new_size < 0) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
-                  "is smaller than page size");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+                   "is smaller than page size");
         return;
     }
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 2091882..1acf6ff 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1307,7 +1307,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     ret = qemu_save_device_state(f);
     qemu_fclose(f);
     if (ret < 0) {
-        error_set(errp, QERR_IO_ERROR);
+        error_setg(errp, QERR_IO_ERROR);
     }
 
  the_end:
diff --git a/monitor.c b/monitor.c
index 627f5d4..92e48d4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -607,8 +607,8 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
         int ret = monitor_set_cpu(cpu_index);
         if (ret < 0) {
             cur_mon = old_mon;
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
-                      "a CPU number");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+                       "a CPU number");
             goto out;
         }
     }
@@ -1030,7 +1030,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
         }
 
         if (!has_port && !has_tls_port) {
-            error_set(errp, QERR_MISSING_PARAMETER, "port/tls-port");
+            error_setg(errp, QERR_MISSING_PARAMETER, "port/tls-port");
             return;
         }
 
@@ -1038,13 +1038,13 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
                                     has_port ? port : -1,
                                     has_tls_port ? tls_port : -1,
                                     cert_subject)) {
-            error_set(errp, QERR_UNDEFINED_ERROR);
+            error_setg(errp, QERR_UNDEFINED_ERROR);
             return;
         }
         return;
     }
 
-    error_set(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "spice");
+    error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "spice");
 }
 
 static void hmp_logfile(Monitor *mon, const QDict *qdict)
@@ -2111,14 +2111,14 @@ void qmp_getfd(const char *fdname, Error **errp)
 
     fd = qemu_chr_fe_get_msgfd(cur_mon->chr);
     if (fd == -1) {
-        error_set(errp, QERR_FD_NOT_SUPPLIED);
+        error_setg(errp, QERR_FD_NOT_SUPPLIED);
         return;
     }
 
     if (qemu_isdigit(fdname[0])) {
         close(fd);
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
-                  "a name not starting with a digit");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
+                   "a name not starting with a digit");
         return;
     }
 
@@ -2155,7 +2155,7 @@ void qmp_closefd(const char *fdname, Error **errp)
         return;
     }
 
-    error_set(errp, QERR_FD_NOT_FOUND, fdname);
+    error_setg(errp, QERR_FD_NOT_FOUND, fdname);
 }
 
 static void hmp_loadvm(Monitor *mon, const QDict *qdict)
@@ -2236,7 +2236,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
 
     fd = qemu_chr_fe_get_msgfd(mon->chr);
     if (fd == -1) {
-        error_set(errp, QERR_FD_NOT_SUPPLIED);
+        error_setg(errp, QERR_FD_NOT_SUPPLIED);
         goto error;
     }
 
@@ -2288,7 +2288,7 @@ error:
     } else {
         snprintf(fd_str, sizeof(fd_str), "fdset-id:%" PRId64, fdset_id);
     }
-    error_set(errp, QERR_FD_NOT_FOUND, fd_str);
+    error_setg(errp, QERR_FD_NOT_FOUND, fd_str);
 }
 
 FdsetInfoList *qmp_query_fdsets(Error **errp)
@@ -2356,8 +2356,8 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
 
         if (has_fdset_id) {
             if (fdset_id < 0) {
-                error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
-                          "a non-negative value");
+                error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
+                           "a non-negative value");
                 return NULL;
             }
             /* Use specified fdset ID */
@@ -4779,7 +4779,7 @@ static void check_client_args_type(const QDict *client_args,
                 continue;
             }
             /* client arg doesn't exist */
-            error_set(errp, QERR_INVALID_PARAMETER, client_arg_name);
+            error_setg(errp, QERR_INVALID_PARAMETER, client_arg_name);
             return;
         }
 
@@ -4792,8 +4792,8 @@ static void check_client_args_type(const QDict *client_args,
         case 'B':
         case 's':
             if (qobject_type(client_arg) != QTYPE_QSTRING) {
-                error_set(errp, QERR_INVALID_PARAMETER_TYPE,
-                          client_arg_name, "string");
+                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+                           client_arg_name, "string");
                 return;
             }
         break;
@@ -4802,24 +4802,24 @@ static void check_client_args_type(const QDict *client_args,
         case 'M':
         case 'o':
             if (qobject_type(client_arg) != QTYPE_QINT) {
-                error_set(errp, QERR_INVALID_PARAMETER_TYPE,
-                          client_arg_name, "int");
+                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+                           client_arg_name, "int");
                 return;
             }
             break;
         case 'T':
             if (qobject_type(client_arg) != QTYPE_QINT &&
                 qobject_type(client_arg) != QTYPE_QFLOAT) {
-                error_set(errp, QERR_INVALID_PARAMETER_TYPE,
-                          client_arg_name, "number");
+                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+                           client_arg_name, "number");
                 return;
             }
             break;
         case 'b':
         case '-':
             if (qobject_type(client_arg) != QTYPE_QBOOL) {
-                error_set(errp, QERR_INVALID_PARAMETER_TYPE,
-                          client_arg_name, "bool");
+                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+                           client_arg_name, "bool");
                 return;
             }
             break;
@@ -4862,7 +4862,7 @@ static void check_mandatory_args(const QDict *cmd_args,
         } else if (qstring_get_str(type)[0] != '-' &&
                    qstring_get_str(type)[1] != '?' &&
                    !qdict_haskey(client_args, cmd_arg_name)) {
-            error_set(errp, QERR_MISSING_PARAMETER, cmd_arg_name);
+            error_setg(errp, QERR_MISSING_PARAMETER, cmd_arg_name);
             return;
         }
     }
@@ -4960,7 +4960,7 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
     QDict *input_dict;
 
     if (qobject_type(input_obj) != QTYPE_QDICT) {
-        error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
+        error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
         return NULL;
     }
 
@@ -4972,27 +4972,27 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
 
         if (!strcmp(arg_name, "execute")) {
             if (qobject_type(arg_obj) != QTYPE_QSTRING) {
-                error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
-                          "execute", "string");
+                error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
+                           "string");
                 return NULL;
             }
             has_exec_key = 1;
         } else if (!strcmp(arg_name, "arguments")) {
             if (qobject_type(arg_obj) != QTYPE_QDICT) {
-                error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
-                          "arguments", "object");
+                error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
+                           "arguments", "object");
                 return NULL;
             }
         } else if (!strcmp(arg_name, "id")) {
             /* Any string is acceptable as "id", so nothing to check */
         } else {
-            error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
+            error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
             return NULL;
         }
     }
 
     if (!has_exec_key) {
-        error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
+        error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
         return NULL;
     }
 
@@ -5014,7 +5014,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
     obj = json_parser_parse(tokens, NULL);
     if (!obj) {
         // FIXME: should be triggered in json_parser_parse()
-        error_set(&local_err, QERR_JSON_PARSING);
+        error_setg(&local_err, QERR_JSON_PARSING);
         goto err_out;
     }
 
@@ -5056,7 +5056,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
         /* Command failed... */
         if (!mon->error) {
             /* ... without setting an error, so make one up */
-            error_set(&local_err, QERR_UNDEFINED_ERROR);
+            error_setg(&local_err, QERR_UNDEFINED_ERROR);
         }
     }
     if (mon->error) {
@@ -5393,6 +5393,6 @@ QemuOptsList qemu_mon_opts = {
 #ifndef TARGET_I386
 void qmp_rtc_reset_reinjection(Error **errp)
 {
-    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
+    error_setg(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
 }
 #endif
diff --git a/net/net.c b/net/net.c
index 212762d..2089df2 100644
--- a/net/net.c
+++ b/net/net.c
@@ -927,16 +927,16 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
             break;
 
         default:
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
-                      "a netdev backend type");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
+                       "a netdev backend type");
             return -1;
         }
     } else {
         u.net = object;
         opts = u.net->opts;
         if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
-                      "a net type");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
+                       "a net type");
             return -1;
         }
         /* missing optional values have been initialized to "all bits zero" */
@@ -957,8 +957,8 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
         if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
             /* FIXME drop when all init functions store an Error */
             if (errp && !*errp) {
-                error_set(errp, QERR_DEVICE_INIT_FAILED,
-                          NetClientOptionsKind_lookup[opts->kind]);
+                error_setg(errp, QERR_DEVICE_INIT_FAILED,
+                           NetClientOptionsKind_lookup[opts->kind]);
             }
             return -1;
         }
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index f2ad6d7..7ae33b3 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -173,7 +173,7 @@ opts_end_struct(Visitor *v, Error **errp)
         const QemuOpt *first;
 
         first = g_queue_peek_head(any);
-        error_set(errp, QERR_INVALID_PARAMETER, first->name);
+        error_setg(errp, QERR_INVALID_PARAMETER, first->name);
     }
     g_hash_table_destroy(ov->unprocessed_opts);
     ov->unprocessed_opts = NULL;
@@ -193,7 +193,7 @@ lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
 
     list = g_hash_table_lookup(ov->unprocessed_opts, name);
     if (!list) {
-        error_set(errp, QERR_MISSING_PARAMETER, name);
+        error_setg(errp, QERR_MISSING_PARAMETER, name);
     }
     return list;
 }
@@ -341,8 +341,8 @@ opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
             strcmp(opt->str, "n") == 0) {
             *obj = false;
         } else {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
-                "on|yes|y|off|no|n");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+                       "on|yes|y|off|no|n");
             return;
         }
     } else {
@@ -403,9 +403,9 @@ opts_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
             }
         }
     }
-    error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
-              (ov->list_mode == LM_NONE) ? "an int64 value" :
-                                           "an int64 value or range");
+    error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+               (ov->list_mode == LM_NONE) ? "an int64 value" :
+                                            "an int64 value or range");
 }
 
 
@@ -455,9 +455,9 @@ opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
             }
         }
     }
-    error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
-              (ov->list_mode == LM_NONE) ? "a uint64 value" :
-                                           "a uint64 value or range");
+    error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+               (ov->list_mode == LM_NONE) ? "a uint64 value" :
+                                            "a uint64 value or range");
 }
 
 
@@ -477,8 +477,8 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
     val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
                          STRTOSZ_DEFSUFFIX_B);
     if (val < 0 || *endptr) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
-                  "a size value representible as a non-negative int64");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+                   "a size value representible as a non-negative int64");
         return;
     }
 
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index b66b93a..a938b7a 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -110,8 +110,8 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < 0 || value > UINT8_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "uint8_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "uint8_t");
             return;
         }
         *obj = value;
@@ -128,8 +128,8 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < 0 || value > UINT16_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "uint16_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "uint16_t");
             return;
         }
         *obj = value;
@@ -146,8 +146,8 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < 0 || value > UINT32_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "uint32_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "uint32_t");
             return;
         }
         *obj = value;
@@ -177,8 +177,8 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < INT8_MIN || value > INT8_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "int8_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "int8_t");
             return;
         }
         *obj = value;
@@ -195,8 +195,8 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < INT16_MIN || value > INT16_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "int16_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "int16_t");
             return;
         }
         *obj = value;
@@ -213,8 +213,8 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
         value = *obj;
         v->type_int(v, &value, name, errp);
         if (value < INT32_MIN || value > INT32_MAX) {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
-                      "int32_t");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "int32_t");
             return;
         }
         *obj = value;
@@ -271,7 +271,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],
     assert(strings);
     while (strings[i++] != NULL);
     if (value < 0 || value >= i - 1) {
-        error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
+        error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
         return;
     }
 
@@ -303,7 +303,7 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[],
     }
 
     if (strings[value] == NULL) {
-        error_set(errp, QERR_INVALID_PARAMETER, enum_str);
+        error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
         g_free(enum_str);
         return;
     }
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 2227420..7bcc860 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -27,8 +27,8 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
     QDict *dict = NULL;
 
     if (qobject_type(request) != QTYPE_QDICT) {
-        error_set(errp, QERR_QMP_BAD_INPUT_OBJECT,
-                  "request is not a dictionary");
+        error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT,
+                   "request is not a dictionary");
         return NULL;
     }
 
@@ -41,19 +41,19 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
 
         if (!strcmp(arg_name, "execute")) {
             if (qobject_type(arg_obj) != QTYPE_QSTRING) {
-                error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
-                          "string");
+                error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
+                           "string");
                 return NULL;
             }
             has_exec_key = true;
         } else if (strcmp(arg_name, "arguments")) {
-            error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
+            error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
             return NULL;
         }
     }
 
     if (!has_exec_key) {
-        error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
+        error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
         return NULL;
     }
 
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index d861206..572b3a4 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -105,7 +105,7 @@ static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
             if (g_hash_table_size(top_ht)) {
                 const char *key;
                 g_hash_table_find(top_ht, always_true, &key);
-                error_set(errp, QERR_QMP_EXTRA_MEMBER, key);
+                error_setg(errp, QERR_QMP_EXTRA_MEMBER, key);
             }
             g_hash_table_unref(top_ht);
         }
@@ -122,8 +122,8 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
     Error *err = NULL;
 
     if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "QDict");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "QDict");
         return;
     }
 
@@ -163,8 +163,8 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp)
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
     if (!qobj || qobject_type(qobj) != QTYPE_QLIST) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "list");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "list");
         return;
     }
 
@@ -215,7 +215,7 @@ static void qmp_input_get_next_type(Visitor *v, int *kind, const int *qobjects,
     QObject *qobj = qmp_input_get_object(qiv, name, false);
 
     if (!qobj) {
-        error_set(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
         return;
     }
     *kind = qobjects[qobject_type(qobj)];
@@ -228,8 +228,8 @@ static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name,
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
     if (!qobj || qobject_type(qobj) != QTYPE_QINT) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "integer");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "integer");
         return;
     }
 
@@ -243,8 +243,8 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
     if (!qobj || qobject_type(qobj) != QTYPE_QBOOL) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "boolean");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "boolean");
         return;
     }
 
@@ -258,8 +258,8 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
     if (!qobj || qobject_type(qobj) != QTYPE_QSTRING) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "string");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "string");
         return;
     }
 
@@ -274,8 +274,8 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
 
     if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT &&
         qobject_type(qobj) != QTYPE_QINT)) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "number");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "number");
         return;
     }
 
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index d8a8db0..bbd6a54 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -185,8 +185,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
     StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
 
     if (!siv->string) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "integer");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "integer");
         return;
     }
 
@@ -217,8 +217,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
     return;
 
 error:
-    error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
-              "an int64 value or range");
+    error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
+               "an int64 value or range");
 }
 
 static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
@@ -231,8 +231,8 @@ static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
     if (siv->string) {
         parse_option_size(name, siv->string, &val, &err);
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "size");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "size");
         return;
     }
     if (err) {
@@ -263,8 +263,8 @@ static void parse_type_bool(Visitor *v, bool *obj, const char *name,
         }
     }
 
-    error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-              "boolean");
+    error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+               "boolean");
 }
 
 static void parse_type_str(Visitor *v, char **obj, const char *name,
@@ -274,8 +274,8 @@ static void parse_type_str(Visitor *v, char **obj, const char *name,
     if (siv->string) {
         *obj = g_strdup(siv->string);
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "string");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "string");
     }
 }
 
@@ -291,8 +291,8 @@ static void parse_type_number(Visitor *v, double *obj, const char *name,
         val = strtod(siv->string, &endp);
     }
     if (!siv->string || errno || endp == siv->string || *endp) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
-                  "number");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+                   "number");
         return;
     }
 
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 7bd7d25..2b3fd54 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -201,16 +201,16 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
     }
 
     if (object_class_is_abstract(oc)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
-                  "non-abstract device type");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
+                   "non-abstract device type");
         return NULL;
     }
 
     dc = DEVICE_CLASS(oc);
     if (dc->cannot_instantiate_with_device_add_yet ||
         (qdev_hotplug && !dc->hotpluggable)) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
-                  "pluggable device type");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
+                   "pluggable device type");
         return NULL;
     }
 
@@ -527,7 +527,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
 
     driver = qemu_opt_get(opts, "driver");
     if (!driver) {
-        error_set(errp, QERR_MISSING_PARAMETER, "driver");
+        error_setg(errp, QERR_MISSING_PARAMETER, "driver");
         return NULL;
     }
 
@@ -558,7 +558,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
         }
     }
     if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
-        error_set(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+        error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
         return NULL;
     }
 
diff --git a/qemu-img.c b/qemu-img.c
index ea964fe..6d1b136 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -739,7 +739,7 @@ static int img_commit(int argc, char **argv)
     if (base) {
         base_bs = bdrv_find_backing_image(bs, base);
         if (!base_bs) {
-            error_set(&local_err, QERR_BASE_NOT_FOUND, base);
+            error_setg(&local_err, QERR_BASE_NOT_FOUND, base);
             goto done;
         }
     } else {
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ba8de62..befd00b 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -382,15 +382,15 @@ static int guest_file_toggle_flags(int fd, int flags, bool set, Error **err)
 
     old_flags = fcntl(fd, F_GETFL);
     if (old_flags == -1) {
-        error_set_errno(err, errno, QERR_QGA_COMMAND_FAILED,
-                        "failed to fetch filehandle flags");
+        error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED,
+                         "failed to fetch filehandle flags");
         return -1;
     }
 
     ret = fcntl(fd, F_SETFL, set ? (old_flags | flags) : (old_flags & ~flags));
     if (ret == -1) {
-        error_set_errno(err, errno, QERR_QGA_COMMAND_FAILED,
-                        "failed to set filehandle flags");
+        error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED,
+                         "failed to set filehandle flags");
         return -1;
     }
 
@@ -2302,34 +2302,34 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
 
 void qmp_guest_suspend_disk(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 void qmp_guest_suspend_ram(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 void qmp_guest_suspend_hybrid(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return -1;
 }
 
@@ -2338,25 +2338,25 @@ void qmp_guest_set_user_password(const char *username,
                                  bool crypted,
                                  Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestMemoryBlockResponseList *
 qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
@@ -2366,20 +2366,20 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
 
 GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 
     return 0;
 }
 
 int64_t qmp_guest_fsfreeze_freeze(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 
     return 0;
 }
@@ -2388,14 +2388,14 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
                                        strList *mountpoints,
                                        Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 
     return 0;
 }
 
 int64_t qmp_guest_fsfreeze_thaw(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 
     return 0;
 }
@@ -2404,7 +2404,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
 #if !defined(CONFIG_FSTRIM)
 void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 #endif
 
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 3ef0549..a8fbd02 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -182,8 +182,8 @@ static void acquire_privilege(const char *name, Error **errp)
         TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
     {
         if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
-            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                      "no luid for requested privilege");
+            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                       "no luid for requested privilege");
             goto out;
         }
 
@@ -191,14 +191,14 @@ static void acquire_privilege(const char *name, Error **errp)
         priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
         if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
-            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                      "unable to acquire requested privilege");
+            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                       "unable to acquire requested privilege");
             goto out;
         }
 
     } else {
-        error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                  "failed to open privilege token");
+        error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                   "failed to open privilege token");
     }
 
 out:
@@ -217,8 +217,8 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
 
     HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
     if (!thread) {
-        error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                  "failed to dispatch asynchronous command");
+        error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                   "failed to dispatch asynchronous command");
         error_propagate(errp, local_err);
     }
 }
@@ -237,8 +237,8 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
     } else if (strcmp(mode, "reboot") == 0) {
         shutdown_flag |= EWX_REBOOT;
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
-                  "halt|powerdown|reboot");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
+                   "halt|powerdown|reboot");
         return;
     }
 
@@ -252,7 +252,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 
     if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
         slog("guest-shutdown failed: %lu", GetLastError());
-        error_set(errp, QERR_UNDEFINED_ERROR);
+        error_setg(errp, QERR_UNDEFINED_ERROR);
     }
 }
 
@@ -384,7 +384,7 @@ static void guest_file_init(void)
 
 GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
@@ -394,7 +394,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
 GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
 {
     if (!vss_initialized()) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         return 0;
     }
 
@@ -415,7 +415,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **errp)
     Error *local_err = NULL;
 
     if (!vss_initialized()) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         return 0;
     }
 
@@ -446,7 +446,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
                                        strList *mountpoints,
                                        Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 
     return 0;
 }
@@ -459,7 +459,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
     int i;
 
     if (!vss_initialized()) {
-        error_set(errp, QERR_UNSUPPORTED);
+        error_setg(errp, QERR_UNSUPPORTED);
         return 0;
     }
 
@@ -495,7 +495,7 @@ static void guest_fsfreeze_cleanup(void)
  */
 void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 typedef enum {
@@ -510,27 +510,27 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
 
     ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
     if (!GetPwrCapabilities(&sys_pwr_caps)) {
-        error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                  "failed to determine guest suspend capabilities");
+        error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                   "failed to determine guest suspend capabilities");
         goto out;
     }
 
     switch (mode) {
     case GUEST_SUSPEND_MODE_DISK:
         if (!sys_pwr_caps.SystemS4) {
-            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                      "suspend-to-disk not supported by OS");
+            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                       "suspend-to-disk not supported by OS");
         }
         break;
     case GUEST_SUSPEND_MODE_RAM:
         if (!sys_pwr_caps.SystemS3) {
-            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-                      "suspend-to-ram not supported by OS");
+            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+                       "suspend-to-ram not supported by OS");
         }
         break;
     default:
-        error_set(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
-                  "GuestSuspendMode");
+        error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
+                   "GuestSuspendMode");
     }
 
 out:
@@ -586,12 +586,12 @@ void qmp_guest_suspend_ram(Error **errp)
 
 void qmp_guest_suspend_hybrid(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
@@ -666,13 +666,13 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 
 GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return -1;
 }
 
@@ -681,25 +681,25 @@ void qmp_guest_set_user_password(const char *username,
                                  bool crypted,
                                  Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
 }
 
 GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestMemoryBlockResponseList *
 qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
 GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
 
diff --git a/qga/main.c b/qga/main.c
index 9939a2b..9e61260 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -578,7 +578,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)
         qdict = qdict_new();
         if (!err) {
             g_warning("failed to parse event: unknown error");
-            error_set(&err, QERR_JSON_PARSING);
+            error_setg(&err, QERR_JSON_PARSING);
         } else {
             g_warning("failed to parse event: %s", error_get_pretty(err));
         }
@@ -598,7 +598,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)
             QDECREF(qdict);
             qdict = qdict_new();
             g_warning("unrecognized payload format");
-            error_set(&err, QERR_UNSUPPORTED);
+            error_setg(&err, QERR_UNSUPPORTED);
             qdict_put_obj(qdict, "error", qmp_build_error_object(err));
             error_free(err);
         }
diff --git a/qmp.c b/qmp.c
index 14f7536..c13a5d2 100644
--- a/qmp.c
+++ b/qmp.c
@@ -132,13 +132,13 @@ void qmp_cpu_add(int64_t id, Error **errp)
    defined in the VNC subsystem */
 VncInfo *qmp_query_vnc(Error **errp)
 {
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+    error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
     return NULL;
 };
 
 VncInfo2List *qmp_query_vnc_servers(Error **errp)
 {
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+    error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
     return NULL;
 };
 #endif
@@ -295,7 +295,7 @@ void qmp_set_password(const char *protocol, const char *password,
         } else if (strcmp(connected, "keep") == 0) {
             /* nothing */
         } else {
-            error_set(errp, QERR_INVALID_PARAMETER, "connected");
+            error_setg(errp, QERR_INVALID_PARAMETER, "connected");
             return;
         }
     }
@@ -307,7 +307,7 @@ void qmp_set_password(const char *protocol, const char *password,
         rc = qemu_spice_set_passwd(password, fail_if_connected,
                                    disconnect_if_connected);
         if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
+            error_setg(errp, QERR_SET_PASSWD_FAILED);
         }
         return;
     }
@@ -315,19 +315,19 @@ void qmp_set_password(const char *protocol, const char *password,
     if (strcmp(protocol, "vnc") == 0) {
         if (fail_if_connected || disconnect_if_connected) {
             /* vnc supports "connected=keep" only */
-            error_set(errp, QERR_INVALID_PARAMETER, "connected");
+            error_setg(errp, QERR_INVALID_PARAMETER, "connected");
             return;
         }
         /* Note that setting an empty password will not disable login through
          * this interface. */
         rc = vnc_display_password(NULL, password);
         if (rc < 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
+            error_setg(errp, QERR_SET_PASSWD_FAILED);
         }
         return;
     }
 
-    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+    error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
 }
 
 void qmp_expire_password(const char *protocol, const char *whenstr,
@@ -352,7 +352,7 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
         }
         rc = qemu_spice_set_pw_expire(when);
         if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
+            error_setg(errp, QERR_SET_PASSWD_FAILED);
         }
         return;
     }
@@ -360,19 +360,19 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
     if (strcmp(protocol, "vnc") == 0) {
         rc = vnc_display_pw_expire(NULL, when);
         if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
+            error_setg(errp, QERR_SET_PASSWD_FAILED);
         }
         return;
     }
 
-    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+    error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
 }
 
 #ifdef CONFIG_VNC
 void qmp_change_vnc_password(const char *password, Error **errp)
 {
     if (vnc_display_password(NULL, password) < 0) {
-        error_set(errp, QERR_SET_PASSWD_FAILED);
+        error_setg(errp, QERR_SET_PASSWD_FAILED);
     }
 }
 
@@ -403,7 +403,7 @@ static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
 {
     if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
         if (!has_arg) {
-            error_set(errp, QERR_MISSING_PARAMETER, "password");
+            error_setg(errp, QERR_MISSING_PARAMETER, "password");
         } else {
             qmp_change_vnc_password(arg, errp);
         }
@@ -414,12 +414,12 @@ static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
 #else
 void qmp_change_vnc_password(const char *password, Error **errp)
 {
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+    error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
 }
 static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
                            Error **errp)
 {
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+    error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
 }
 #endif /* !CONFIG_VNC */
 
@@ -528,8 +528,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
 
     klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
     if (klass == NULL) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
-                  "name", TYPE_DEVICE);
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name", TYPE_DEVICE);
         return NULL;
     }
 
@@ -686,7 +685,8 @@ int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret)
     if (props) {
         pdict = qobject_to_qdict(props);
         if (!pdict) {
-            error_set(&local_err, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
+            error_setg(&local_err, QERR_INVALID_PARAMETER_TYPE, "props",
+                       "dict");
             goto out;
         }
     }
diff --git a/qom/object.c b/qom/object.c
index 62fa44e..f081915 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -817,7 +817,7 @@ void object_property_get(Object *obj, Visitor *v, const char *name,
     }
 
     if (!prop->get) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
     } else {
         prop->get(obj, v, prop->opaque, name, errp);
     }
@@ -832,7 +832,7 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
     }
 
     if (!prop->set) {
-        error_set(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, QERR_PERMISSION_DENIED);
     } else {
         prop->set(obj, v, prop->opaque, name, errp);
     }
@@ -859,7 +859,7 @@ char *object_property_get_str(Object *obj, const char *name,
     }
     qstring = qobject_to_qstring(ret);
     if (!qstring) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
         retval = NULL;
     } else {
         retval = g_strdup(qstring_get_str(qstring));
@@ -920,7 +920,7 @@ bool object_property_get_bool(Object *obj, const char *name,
     }
     qbool = qobject_to_qbool(ret);
     if (!qbool) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
         retval = false;
     } else {
         retval = qbool_get_int(qbool);
@@ -951,7 +951,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
     }
     qint = qobject_to_qint(ret);
     if (!qint) {
-        error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
         retval = -1;
     } else {
         retval = qint_get_int(qint);
@@ -1169,7 +1169,7 @@ static Object *object_resolve_link(Object *obj, const char *name,
     } else if (!target) {
         target = object_resolve_path(path, &ambiguous);
         if (target || ambiguous) {
-            error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
+            error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
         } else {
             error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                       "Device '%s' not found", path);
diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c
index 22e0b43..a975ab4 100644
--- a/stubs/arch-query-cpu-def.c
+++ b/stubs/arch-query-cpu-def.c
@@ -4,6 +4,6 @@
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
 {
-    error_set(errp, QERR_UNSUPPORTED);
+    error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4e7cdaa..d4f4c8d 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1524,8 +1524,8 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,
         return;
     }
     if (value < min || value > max) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
-                  name ? name : "null", value, min, max);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+                   name ? name : "null", value, min, max);
         return;
     }
 
@@ -1565,8 +1565,8 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque,
         return;
     }
     if (value < min || value > max) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
-                  name ? name : "null", value, min, max);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+                   name ? name : "null", value, min, max);
         return;
     }
 
@@ -1603,8 +1603,8 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
         return;
     }
     if (value < min || value > max) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
-                  name ? name : "null", value, min, max);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+                   name ? name : "null", value, min, max);
         return;
     }
 
@@ -1632,8 +1632,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,
     int i;
 
     if (strlen(value) != CPUID_VENDOR_SZ) {
-        error_set(errp, QERR_PROPERTY_VALUE_BAD, "",
-                  "vendor", value);
+        error_setg(errp, QERR_PROPERTY_VALUE_BAD, "", "vendor", value);
         return;
     }
 
@@ -1709,8 +1708,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
         return;
     }
     if (value < min || value > max) {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
-                  name ? name : "null", value, min, max);
+        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+                   name ? name : "null", value, min, max);
         return;
     }
 
diff --git a/tpm.c b/tpm.c
index b8b0664..99a9895 100644
--- a/tpm.c
+++ b/tpm.c
@@ -140,20 +140,22 @@ static int configure_tpm(QemuOpts *opts)
 
     id = qemu_opts_id(opts);
     if (id == NULL) {
-        qerror_report(QERR_MISSING_PARAMETER, "id");
+        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
         return 1;
     }
 
     value = qemu_opt_get(opts, "type");
     if (!value) {
-        qerror_report(QERR_MISSING_PARAMETER, "type");
+        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER,
+                      "type");
         tpm_display_backend_drivers();
         return 1;
     }
 
     be = tpm_get_backend_driver(value);
     if (be == NULL) {
-        qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
+        qerror_report(ERROR_CLASS_GENERIC_ERROR,
+                      QERR_INVALID_PARAMETER_VALUE, "type",
                       "a TPM backend type");
         tpm_display_backend_drivers();
         return 1;
diff --git a/ui/vnc.c b/ui/vnc.c
index 7f0ce7a..b5e7906 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -427,7 +427,7 @@ VncInfo *qmp_query_vnc(Error **errp)
 
         if (getsockname(vd->lsock, (struct sockaddr *)&sa,
                         &salen) == -1) {
-            error_set(errp, QERR_UNDEFINED_ERROR);
+            error_setg(errp, QERR_UNDEFINED_ERROR);
             goto out_error;
         }
 
@@ -435,7 +435,7 @@ VncInfo *qmp_query_vnc(Error **errp)
                         host, sizeof(host),
                         serv, sizeof(serv),
                         NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
-            error_set(errp, QERR_UNDEFINED_ERROR);
+            error_setg(errp, QERR_UNDEFINED_ERROR);
             goto out_error;
         }
 
diff --git a/util/qemu-option.c b/util/qemu-option.c
index e2f789f..9a954ba 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -132,7 +132,8 @@ static void parse_option_bool(const char *name, const char *value, bool *ret,
         } else if (!strcmp(value, "off")) {
             *ret = 0;
         } else {
-            error_set(errp,QERR_INVALID_PARAMETER_VALUE, name, "'on' or 'off'");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
+                       "'on' or 'off'");
         }
     } else {
         *ret = 1;
@@ -148,12 +149,12 @@ static void parse_option_number(const char *name, const char *value,
     if (value != NULL) {
         number = strtoull(value, &postfix, 0);
         if (*postfix != '\0') {
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
             return;
         }
         *ret = number;
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
     }
 }
 
@@ -198,7 +199,7 @@ void parse_option_size(const char *name, const char *value,
             *ret = (uint64_t) sizef;
             break;
         default:
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
 #if 0 /* conversion from qerror_report() to error_set() broke this: */
             error_printf_unless_qmp("You may use k, M, G or T suffixes for "
                     "kilobytes, megabytes, gigabytes and terabytes.\n");
@@ -206,7 +207,7 @@ void parse_option_size(const char *name, const char *value,
             return;
         }
     } else {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
     }
 }
 
@@ -527,7 +528,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
 
     desc = find_desc_by_name(opts->list->desc, name);
     if (!desc && !opts_accepts_any(opts)) {
-        error_set(errp, QERR_INVALID_PARAMETER, name);
+        error_setg(errp, QERR_INVALID_PARAMETER, name);
         return;
     }
 
@@ -563,7 +564,7 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
     opt = g_malloc0(sizeof(*opt));
     opt->desc = find_desc_by_name(desc, name);
     if (!opt->desc && !opts_accepts_any(opts)) {
-        error_set(errp, QERR_INVALID_PARAMETER, name);
+        error_setg(errp, QERR_INVALID_PARAMETER, name);
         g_free(opt);
         return;
     }
@@ -584,7 +585,7 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
     opt = g_malloc0(sizeof(*opt));
     opt->desc = find_desc_by_name(desc, name);
     if (!opt->desc && !opts_accepts_any(opts)) {
-        error_set(errp, QERR_INVALID_PARAMETER, name);
+        error_setg(errp, QERR_INVALID_PARAMETER, name);
         g_free(opt);
         return;
     }
@@ -640,7 +641,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
 
     if (id) {
         if (!id_wellformed(id)) {
-            error_set(errp,QERR_INVALID_PARAMETER_VALUE, "id", "an identifier");
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
+                       "an identifier");
 #if 0 /* conversion from qerror_report() to error_set() broke this: */
             error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n");
 #endif
@@ -1055,7 +1057,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
     QTAILQ_FOREACH(opt, &opts->head, next) {
         opt->desc = find_desc_by_name(desc, opt->name);
         if (!opt->desc) {
-            error_set(errp, QERR_INVALID_PARAMETER, opt->name);
+            error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
             return;
         }
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (4 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 20:37   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report() Markus Armbruster
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

qerror_report() is a transitional interface to help with converting
existing monitor commands to QMP.  It should not be used elsewhere.
Replace by error_report().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tpm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tpm.c b/tpm.c
index 99a9895..224e65e 100644
--- a/tpm.c
+++ b/tpm.c
@@ -140,23 +140,21 @@ static int configure_tpm(QemuOpts *opts)
 
     id = qemu_opts_id(opts);
     if (id == NULL) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
+        error_report(QERR_MISSING_PARAMETER, "id");
         return 1;
     }
 
     value = qemu_opt_get(opts, "type");
     if (!value) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER,
-                      "type");
+        error_report(QERR_MISSING_PARAMETER, "type");
         tpm_display_backend_drivers();
         return 1;
     }
 
     be = tpm_get_backend_driver(value);
     if (be == NULL) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      QERR_INVALID_PARAMETER_VALUE, "type",
-                      "a TPM backend type");
+        error_report(QERR_INVALID_PARAMETER_VALUE, "type",
+                     "a TPM backend type");
         tpm_display_backend_drivers();
         return 1;
     }
-- 
1.9.3

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

* [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report()
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (5 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 15:08   ` Stefan Hajnoczi
  2015-06-15 20:56   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up Markus Armbruster
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

The traditional QMP command handler interface

    int qmp_FOO(Monitor *mon, const QDict *params, QObject **ret_data);

doesn't provide for returning an Error object.  Instead, the handler
is expected to stash it in the monitor with qerror_report().

When we rebased QMP on top of QAPI, we didn't change this interface.
Instead, commit 776574d introduced "middle mode" as a temporary aid
for converting existing QMP commands to QAPI one by one.  More than
three years later, we're still using it.

Middle mode has two effects:

* Instead of the native input marshallers

      static void qmp_marshal_input_FOO(QDict *, QObject **, Error **)

  it generates input marshallers conforming to the traditional QMP
  command handler interface.

* It suppresses generation of code to register them with
  qmp_register_command()

  This permits giving them internal linkage.

As long as we need qmp-commands.hx, we can't use the registry behind
qmp_register_command(), so the latter has to stay for now.

The former has to go to get rid of qerror_report().  Changing all QMP
commands to fit the QAPI mold in one go was impractical back when we
started, but by now there are just a few stragglers left:
do_qmp_capabilities(), qmp_qom_set(), qmp_qom_get(), qmp_object_add(),
qmp_netdev_add(), do_device_add().

Switch middle mode to generate native input marshallers, and adapt the
stragglers.  Simplifies both the monitor code and the stragglers.

Rename do_qmp_capabilities() to qmp_capabilities(), and
do_device_add() to qmp_device_add, because that's how QMP command
handlers are named today.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hmp.c                     |  5 ++++-
 include/monitor/monitor.h |  7 +++---
 include/monitor/qdev.h    |  3 ++-
 include/net/net.h         |  2 +-
 monitor.c                 | 24 ++++++---------------
 net/net.c                 | 16 ++++++--------
 qdev-monitor.c            | 15 ++++++-------
 qmp-commands.hx           |  4 ++--
 qmp.c                     | 55 +++++++++++------------------------------------
 scripts/qapi-commands.py  | 41 ++++++-----------------------------
 util/qemu-error.c         |  4 ++--
 11 files changed, 50 insertions(+), 126 deletions(-)

diff --git a/hmp.c b/hmp.c
index 2b734ea..de934bd 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1503,7 +1503,10 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
 
 void hmp_device_add(Monitor *mon, const QDict *qdict)
 {
-    do_device_add(mon, qdict, NULL);
+    Error *err = NULL;
+
+    qmp_device_add((QDict *)qdict, NULL, &err);
+    hmp_handle_error(mon, &err);
 }
 
 void hmp_device_del(Monitor *mon, const QDict *qdict)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 57f8394..1955d11 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -45,10 +45,9 @@ void monitor_read_command(Monitor *mon, int show_prompt);
 int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
                           void *opaque);
 
-int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
-
-int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
-int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret);
+void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp);
+void qmp_qom_get(QDict *qdict, QObject **ret, Error **errp);
+void qmp_object_add(QDict *qdict, QObject **ret, Error **errp);
 void object_add(const char *type, const char *id, const QDict *qdict,
                 Visitor *v, Error **errp);
 
diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
index 2ce8578..dc796c8 100644
--- a/include/monitor/qdev.h
+++ b/include/monitor/qdev.h
@@ -9,7 +9,8 @@
 void hmp_info_qtree(Monitor *mon, const QDict *qdict);
 void hmp_info_qdm(Monitor *mon, const QDict *qdict);
 void hmp_info_qom_tree(Monitor *mon, const QDict *dict);
-int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
+void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp);
+
 int qdev_device_help(QemuOpts *opts);
 DeviceState *qdev_device_add(QemuOpts *opts, Error **errp);
 
diff --git a/include/net/net.h b/include/net/net.h
index e66ca03..9084287 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -191,7 +191,7 @@ void net_cleanup(void);
 void hmp_host_net_add(Monitor *mon, const QDict *qdict);
 void hmp_host_net_remove(Monitor *mon, const QDict *qdict);
 void netdev_add(QemuOpts *opts, Error **errp);
-int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret);
+void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp);
 
 int net_hub_id_for_client(NetClientState *nc, int *id);
 NetClientState *net_hub_port_find(int hub_id);
diff --git a/monitor.c b/monitor.c
index 92e48d4..6719dc3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -125,7 +125,7 @@ typedef struct mon_cmd_t {
     const char *help;
     union {
         void (*cmd)(Monitor *mon, const QDict *qdict);
-        int  (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret_data);
+        void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
     } mhandler;
     /* @sub_table is a list of 2nd level of commands. If it do not exist,
      * mhandler should be used. If it exist, sub_table[?].mhandler should be
@@ -567,11 +567,9 @@ static void monitor_qapi_event_init(void)
     qmp_event_set_func_emit(monitor_qapi_event_queue);
 }
 
-static int do_qmp_capabilities(Monitor *mon, const QDict *params,
-                               QObject **ret_data)
+static void qmp_capabilities(QDict *params, QObject **ret_data, Error **errp)
 {
-    mon->qmp.in_command_mode = true;
-    return 0;
+    cur_mon->qmp.in_command_mode = true;
 }
 
 static void handle_hmp_command(Monitor *mon, const char *cmdline);
@@ -4733,7 +4731,7 @@ static int monitor_can_read(void *opaque)
 static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
+    bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities;
 
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
@@ -5052,17 +5050,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
         goto err_out;
     }
 
-    if (cmd->mhandler.cmd_new(mon, args, &data)) {
-        /* Command failed... */
-        if (!mon->error) {
-            /* ... without setting an error, so make one up */
-            error_setg(&local_err, QERR_UNDEFINED_ERROR);
-        }
-    }
-    if (mon->error) {
-        error_set(&local_err, mon->error->err_class, "%s",
-                  mon->error->err_msg);
-    }
+    cmd->mhandler.cmd_new(args, &data, &local_err);
 
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
@@ -5134,7 +5122,7 @@ static QObject *get_qmp_greeting(void)
 {
     QObject *ver = NULL;
 
-    qmp_marshal_input_query_version(NULL, NULL, &ver);
+    qmp_marshal_input_query_version(NULL, &ver, NULL);
     return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
 }
 
diff --git a/net/net.c b/net/net.c
index 2089df2..a18b8c3 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1072,7 +1072,7 @@ void netdev_add(QemuOpts *opts, Error **errp)
     net_client_init(opts, 1, errp);
 }
 
-int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp)
 {
     Error *local_err = NULL;
     QemuOptsList *opts_list;
@@ -1080,26 +1080,22 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret)
 
     opts_list = qemu_find_opts_err("netdev", &local_err);
     if (local_err) {
-        goto exit_err;
+        goto out;
     }
 
     opts = qemu_opts_from_qdict(opts_list, qdict, &local_err);
     if (local_err) {
-        goto exit_err;
+        goto out;
     }
 
     netdev_add(opts, &local_err);
     if (local_err) {
         qemu_opts_del(opts);
-        goto exit_err;
+        goto out;
     }
 
-    return 0;
-
-exit_err:
-    qerror_report_err(local_err);
-    error_free(local_err);
-    return -1;
+out:
+    error_propagate(errp, local_err);
 }
 
 void qmp_netdev_del(const char *id, Error **errp)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 2b3fd54..4447307 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -756,7 +756,7 @@ void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
     print_qom_composition(mon, obj, 0);
 }
 
-int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
 {
     Error *local_err = NULL;
     QemuOpts *opts;
@@ -764,23 +764,20 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 
     opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
     if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return -1;
+        error_propagate(errp, local_err);
+        return;
     }
     if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
         qemu_opts_del(opts);
-        return 0;
+        return;
     }
     dev = qdev_device_add(opts, &local_err);
     if (!dev) {
-        qerror_report_err(local_err);
-        error_free(local_err);
+        error_propagate(errp, local_err);
         qemu_opts_del(opts);
-        return -1;
+        return;
     }
     object_unref(OBJECT(dev));
-    return 0;
 }
 
 void qmp_device_del(const char *id, Error **errp)
diff --git a/qmp-commands.hx b/qmp-commands.hx
index c97d0d7..0576939 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -276,7 +276,7 @@ EQMP
         .args_type  = "device:O",
         .params     = "driver[,prop=value][,...]",
         .help       = "add device, like -device on the command line",
-        .mhandler.cmd_new = do_device_add,
+        .mhandler.cmd_new = qmp_device_add,
     },
 
 SQMP
@@ -1982,7 +1982,7 @@ EQMP
         .args_type  = "",
         .params     = "",
         .help       = "enable QMP capabilities",
-        .mhandler.cmd_new = do_qmp_capabilities,
+        .mhandler.cmd_new = qmp_capabilities,
     },
 
 SQMP
diff --git a/qmp.c b/qmp.c
index c13a5d2..4acc222 100644
--- a/qmp.c
+++ b/qmp.c
@@ -227,57 +227,37 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
 }
 
 /* FIXME: teach qapi about how to pass through Visitors */
-int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp)
 {
     const char *path = qdict_get_str(qdict, "path");
     const char *property = qdict_get_str(qdict, "property");
     QObject *value = qdict_get(qdict, "value");
-    Error *local_err = NULL;
     Object *obj;
 
     obj = object_resolve_path(path, NULL);
     if (!obj) {
-        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                   "Device '%s' not found", path);
-        goto out;
+        return;
     }
 
-    object_property_set_qobject(obj, value, property, &local_err);
-
-out:
-    if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return -1;
-    }
-
-    return 0;
+    object_property_set_qobject(obj, value, property, errp);
 }
 
-int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_qom_get(QDict *qdict, QObject **ret, Error **errp)
 {
     const char *path = qdict_get_str(qdict, "path");
     const char *property = qdict_get_str(qdict, "property");
-    Error *local_err = NULL;
     Object *obj;
 
     obj = object_resolve_path(path, NULL);
     if (!obj) {
-        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                   "Device '%s' not found", path);
-        goto out;
+        return;
     }
 
-    *ret = object_property_get_qobject(obj, property, &local_err);
-
-out:
-    if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return -1;
-    }
-
-    return 0;
+    *ret = object_property_get_qobject(obj, property, errp);
 }
 
 void qmp_set_password(const char *protocol, const char *password,
@@ -673,36 +653,25 @@ out:
     object_unref(obj);
 }
 
-int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_object_add(QDict *qdict, QObject **ret, Error **errp)
 {
     const char *type = qdict_get_str(qdict, "qom-type");
     const char *id = qdict_get_str(qdict, "id");
     QObject *props = qdict_get(qdict, "props");
     const QDict *pdict = NULL;
-    Error *local_err = NULL;
     QmpInputVisitor *qiv;
 
     if (props) {
         pdict = qobject_to_qdict(props);
         if (!pdict) {
-            error_setg(&local_err, QERR_INVALID_PARAMETER_TYPE, "props",
-                       "dict");
-            goto out;
+            error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
+            return;
         }
     }
 
     qiv = qmp_input_visitor_new(props);
-    object_add(type, id, pdict, qmp_input_get_visitor(qiv), &local_err);
+    object_add(type, id, pdict, qmp_input_get_visitor(qiv), errp);
     qmp_input_visitor_cleanup(qiv);
-
-out:
-    if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return -1;
-    }
-
-    return 0;
 }
 
 void qmp_object_del(const char *id, Error **errp)
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 1c1d3aa..a451a51 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -195,12 +195,10 @@ out:
     return ret
 
 def gen_marshal_input_decl(name, args, ret_type, middle_mode):
-    if middle_mode:
-        return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_name(name)
-    else:
-        return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-
-
+    ret = 'void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
+    if not middle_mode:
+        ret = "static " + ret
+    return ret
 
 def gen_marshal_input(name, args, ret_type, middle_mode):
     hdr = gen_marshal_input_decl(name, args, ret_type, middle_mode)
@@ -212,11 +210,6 @@ def gen_marshal_input(name, args, ret_type, middle_mode):
 ''',
                 header=hdr)
 
-    if middle_mode:
-        ret += mcgen('''
-    QDict *args = (QDict *)qdict;
-''')
-
     if ret_type:
         if is_c_ptr(ret_type):
             retval = "    %s retval = NULL;" % c_type(ret_type)
@@ -253,35 +246,13 @@ def gen_marshal_input(name, args, ret_type, middle_mode):
 
 out:
 ''')
-    if not middle_mode:
-        ret += mcgen('''
-    error_propagate(errp, local_err);
-''')
     ret += mcgen('''
+    error_propagate(errp, local_err);
 %(visitor_input_block_cleanup)s
+}
 ''',
                  visitor_input_block_cleanup=gen_visitor_input_block(args,
                                                                      dealloc=True))
-
-    if middle_mode:
-        ret += mcgen('''
-
-    if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return -1;
-    }
-    return 0;
-''')
-    else:
-        ret += mcgen('''
-    return;
-''')
-
-    ret += mcgen('''
-}
-''')
-
     return ret
 
 def gen_registry(commands):
diff --git a/util/qemu-error.c b/util/qemu-error.c
index 9bba5f5..16d2d07 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -202,7 +202,7 @@ bool enable_timestamp_msg;
  * Format arguments like vsprintf().  The result should not contain
  * newlines.
  * Prepend the current location and append a newline.
- * It's wrong to call this in a QMP monitor.  Use qerror_report() there.
+ * It's wrong to call this in a QMP monitor.  Use error_setg() there.
  */
 void error_vreport(const char *fmt, va_list ap)
 {
@@ -226,7 +226,7 @@ void error_vreport(const char *fmt, va_list ap)
  * Format arguments like sprintf().  The result should not contain
  * newlines.
  * Prepend the current location and append a newline.
- * It's wrong to call this in a QMP monitor.  Use qerror_report() there.
+ * It's wrong to call this in a QMP monitor.  Use error_setg() there.
  */
 void error_report(const char *fmt, ...)
 {
-- 
1.9.3

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

* [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (6 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report() Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 21:05   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h Markus Armbruster
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

Remove it except for two things in qerror.h:

* Two #include to be cleaned up separately to avoid cluttering this
  patch.

* The QERR_ macros.  Mark as obsolete.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/qapi.c               |   6 --
 include/monitor/monitor.h  |   1 -
 include/qapi/qmp/qerror.h  |  19 +-----
 include/qapi/qmp/qobject.h |   1 -
 monitor.c                  |  13 ----
 qobject/Makefile.objs      |   1 -
 qobject/qerror.c           | 148 ---------------------------------------------
 qobject/qjson.c            |   3 -
 stubs/Makefile.objs        |   1 -
 stubs/mon-is-qmp.c         |   2 +
 stubs/mon-set-error.c      |   8 ---
 11 files changed, 4 insertions(+), 199 deletions(-)
 delete mode 100644 qobject/qerror.c
 delete mode 100644 stubs/mon-set-error.c

diff --git a/block/qapi.c b/block/qapi.c
index 18d2b95..07e05d5 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -517,12 +517,6 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
             func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false");
             break;
         }
-        case QTYPE_QERROR: {
-            QString *value = qerror_human((QError *)obj);
-            func_fprintf(f, "%s", qstring_get_str(value));
-            QDECREF(value);
-            break;
-        }
         default:
             abort();
     }
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 1955d11..01c9d57 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -40,7 +40,6 @@ void monitor_flush(Monitor *mon);
 int monitor_set_cpu(int cpu_index);
 int monitor_get_cpu_index(void);
 
-void monitor_set_error(Monitor *mon, QError *qerror);
 void monitor_read_command(Monitor *mon, int show_prompt);
 int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
                           void *opaque);
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index e34741e..f8182c7 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -14,25 +14,10 @@
 
 #include "qapi/qmp/qstring.h"
 #include "qemu/error-report.h"
-#include "qapi/error.h"
-#include "qapi-types.h"
-#include <stdarg.h>
-
-typedef struct QError {
-    QObject_HEAD;
-    Location loc;
-    char *err_msg;
-    ErrorClass err_class;
-} QError;
-
-QString *qerror_human(const QError *qerror);
-void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
-void qerror_report_err(Error *err);
 
 /*
- * QError class list
- * Please keep the definitions in alphabetical order.
- * Use scripts/check-qerror.sh to check.
+ * These macros will go away, please don't use in new code, and do not
+ * add new ones!
  */
 #define QERR_BASE_NOT_FOUND \
     "Base '%s' not found"
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index 84b2d9f..260d2ed 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -44,7 +44,6 @@ typedef enum {
     QTYPE_QLIST,
     QTYPE_QFLOAT,
     QTYPE_QBOOL,
-    QTYPE_QERROR,
     QTYPE_MAX,
 } qtype_code;
 
diff --git a/monitor.c b/monitor.c
index 6719dc3..356409e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -205,7 +205,6 @@ struct Monitor {
     BlockCompletionFunc *password_completion_cb;
     void *password_opaque;
     mon_cmd_t *cmd_table;
-    QError *error;
     QLIST_HEAD(,mon_fd_t) fds;
     QLIST_ENTRY(Monitor) entry;
 };
@@ -4041,16 +4040,6 @@ fail:
     return NULL;
 }
 
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
-    /* report only the first error */
-    if (!mon->error) {
-        mon->error = qerror;
-    } else {
-        QDECREF(qerror);
-    }
-}
-
 static void handle_hmp_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
@@ -5055,8 +5044,6 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
     qobject_decref(data);
-    QDECREF(mon->error);
-    mon->error = NULL;
     QDECREF(input);
     QDECREF(args);
 }
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index f7595f5..0031e8b 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,3 +1,2 @@
 util-obj-y = qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
 util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
-util-obj-y += qerror.o
diff --git a/qobject/qerror.c b/qobject/qerror.c
deleted file mode 100644
index e3608e2..0000000
--- a/qobject/qerror.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * QError Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- *  Luiz Capitulino <lcapitulino@redhat.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-
-#include "monitor/monitor.h"
-#include "qapi/qmp/qjson.h"
-#include "qapi/qmp/qerror.h"
-#include "qemu-common.h"
-
-static void qerror_destroy_obj(QObject *obj);
-
-static const QType qerror_type = {
-    .code = QTYPE_QERROR,
-    .destroy = qerror_destroy_obj,
-};
-
-/**
- * qerror_new(): Create a new QError
- *
- * Return strong reference.
- */
-static QError *qerror_new(void)
-{
-    QError *qerr;
-
-    qerr = g_malloc0(sizeof(*qerr));
-    QOBJECT_INIT(qerr, &qerror_type);
-
-    return qerr;
-}
-
-/**
- * qerror_from_info(): Create a new QError from error information
- *
- * Return strong reference.
- */
-static QError * GCC_FMT_ATTR(2, 0)
-qerror_from_info(ErrorClass err_class, const char *fmt, va_list *va)
-{
-    QError *qerr;
-
-    qerr = qerror_new();
-    loc_save(&qerr->loc);
-
-    qerr->err_msg = g_strdup_vprintf(fmt, *va);
-    qerr->err_class = err_class;
-
-    return qerr;
-}
-
-/**
- * qerror_human(): Format QError data into human-readable string.
- */
-QString *qerror_human(const QError *qerror)
-{
-    return qstring_from_str(qerror->err_msg);
-}
-
-/**
- * qerror_print(): Print QError data
- *
- * This function will print the member 'desc' of the specified QError object,
- * it uses error_report() for this, so that the output is routed to the right
- * place (ie. stderr or Monitor's device).
- */
-static void qerror_print(QError *qerror)
-{
-    QString *qstring = qerror_human(qerror);
-    loc_push_restore(&qerror->loc);
-    error_report("%s", qstring_get_str(qstring));
-    loc_pop(&qerror->loc);
-    QDECREF(qstring);
-}
-
-void qerror_report(ErrorClass eclass, const char *fmt, ...)
-{
-    va_list va;
-    QError *qerror;
-
-    va_start(va, fmt);
-    qerror = qerror_from_info(eclass, fmt, &va);
-    va_end(va);
-
-    if (monitor_cur_is_qmp()) {
-        monitor_set_error(cur_mon, qerror);
-    } else {
-        qerror_print(qerror);
-        QDECREF(qerror);
-    }
-}
-
-/* Evil... */
-struct Error
-{
-    char *msg;
-    ErrorClass err_class;
-};
-
-void qerror_report_err(Error *err)
-{
-    QError *qerr;
-
-    qerr = qerror_new();
-    loc_save(&qerr->loc);
-    qerr->err_msg = g_strdup(err->msg);
-    qerr->err_class = err->err_class;
-
-    if (monitor_cur_is_qmp()) {
-        monitor_set_error(cur_mon, qerr);
-    } else {
-        qerror_print(qerr);
-        QDECREF(qerr);
-    }
-}
-
-/**
- * qobject_to_qerror(): Convert a QObject into a QError
- */
-static QError *qobject_to_qerror(const QObject *obj)
-{
-    if (qobject_type(obj) != QTYPE_QERROR) {
-        return NULL;
-    }
-
-    return container_of(obj, QError, base);
-}
-
-/**
- * qerror_destroy_obj(): Free all memory allocated by a QError
- */
-static void qerror_destroy_obj(QObject *obj)
-{
-    QError *qerr;
-
-    assert(obj != NULL);
-    qerr = qobject_to_qerror(obj);
-
-    g_free(qerr->err_msg);
-    g_free(qerr);
-}
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 846733d..3657c04 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -261,9 +261,6 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
         }
         break;
     }
-    case QTYPE_QERROR:
-        /* XXX: should QError be emitted? */
-        break;
     default:
         abort();
     }
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 8beff4c..9937a12 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -21,7 +21,6 @@ stub-obj-y += machine-init-done.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += mon-is-qmp.o
 stub-obj-y += mon-printf.o
-stub-obj-y += mon-set-error.o
 stub-obj-y += monitor-init.o
 stub-obj-y += notify-event.o
 stub-obj-$(CONFIG_SPICE) += qemu-chr-open-spice.o
diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
index 1ef136a..dd26f19 100644
--- a/stubs/mon-is-qmp.c
+++ b/stubs/mon-is-qmp.c
@@ -1,6 +1,8 @@
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
+Monitor *cur_mon;
+
 bool monitor_cur_is_qmp(void)
 {
     return false;
diff --git a/stubs/mon-set-error.c b/stubs/mon-set-error.c
deleted file mode 100644
index d0411f9..0000000
--- a/stubs/mon-set-error.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu-common.h"
-#include "monitor/monitor.h"
-
-Monitor *cur_mon;
-
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
-}
-- 
1.9.3

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

* [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (7 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 15:08   ` Stefan Hajnoczi
  2015-06-15 21:37   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
                   ` (2 subsequent siblings)
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 audio/spiceaudio.c          | 1 +
 audio/wavcapture.c          | 1 +
 block.c                     | 1 +
 block/curl.c                | 1 +
 block/dmg.c                 | 1 +
 block/io.c                  | 1 +
 block/iscsi.c               | 1 +
 block/qcow2-snapshot.c      | 1 +
 block/raw-posix.c           | 2 ++
 block/ssh.c                 | 2 ++
 block/vhdx-log.c            | 1 +
 block/vmdk.c                | 1 +
 block/vvfat.c               | 1 +
 blockdev.c                  | 1 +
 cpus.c                      | 1 +
 hw/9pfs/virtio-9p.c         | 1 +
 hw/char/virtio-serial-bus.c | 1 +
 hw/core/qdev.c              | 1 +
 hw/display/g364fb.c         | 1 +
 hw/display/tcx.c            | 1 +
 hw/i386/pc.c                | 1 +
 hw/ide/ahci.c               | 1 +
 hw/misc/ivshmem.c           | 1 +
 hw/pci/pci.c                | 1 +
 hw/ppc/virtex_ml507.c       | 1 +
 hw/s390x/virtio-ccw.c       | 1 +
 hw/scsi/vhost-scsi.c        | 1 +
 hw/timer/hpet.c             | 1 +
 hw/tpm/tpm_passthrough.c    | 1 +
 hw/usb/bus.c                | 1 +
 hw/usb/ccid-card-passthru.c | 1 +
 hw/usb/dev-serial.c         | 1 +
 hw/usb/dev-storage.c        | 1 +
 hw/usb/host-libusb.c        | 1 +
 hw/usb/redirect.c           | 1 +
 include/qapi/qmp/qerror.h   | 3 ---
 migration/migration.c       | 1 +
 migration/qemu-file-buf.c   | 1 +
 migration/qemu-file.c       | 1 +
 migration/rdma.c            | 1 +
 migration/savevm.c          | 1 +
 net/net.c                   | 1 +
 net/slirp.c                 | 1 +
 qdev-monitor.c              | 1 +
 qemu-char.c                 | 1 +
 qemu-io-cmds.c              | 1 +
 qemu-io.c                   | 2 ++
 qemu-nbd.c                  | 1 +
 slirp/misc.c                | 1 +
 target-i386/cpu.c           | 1 +
 tpm.c                       | 1 +
 ui/input.c                  | 1 +
 ui/spice-core.c             | 1 +
 ui/vnc.c                    | 1 +
 util/osdep.c                | 1 +
 util/qemu-error.c           | 1 +
 vl.c                        | 1 +
 57 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index 7b79bed..2a27fe1 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -18,6 +18,7 @@
  */
 
 #include "hw/hw.h"
+#include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "ui/qemu-spice.h"
 
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 6f6d792..86e9056 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -1,5 +1,6 @@
 #include "hw/hw.h"
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "audio.h"
 
 typedef struct {
diff --git a/block.c b/block.c
index b642d9f..a1b7203 100644
--- a/block.c
+++ b/block.c
@@ -26,6 +26,7 @@
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "qapi/qmp/qjson.h"
 #include "sysemu/block-backend.h"
diff --git a/block/curl.c b/block/curl.c
index bbee3ca..3a2b63e 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "block/block_int.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qstring.h"
 #include <curl/curl.h>
 
 // #define DEBUG_CURL
diff --git a/block/dmg.c b/block/dmg.c
index 825c49d..9f25281 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "block/block_int.h"
 #include "qemu/bswap.h"
+#include "qemu/error-report.h"
 #include "qemu/module.h"
 #include <zlib.h>
 #ifdef CONFIG_BZIP2
diff --git a/block/io.c b/block/io.c
index e394d92..4f371fb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -26,6 +26,7 @@
 #include "sysemu/qtest.h"
 #include "block/blockjob.h"
 #include "block/block_int.h"
+#include "qemu/error-report.h"
 
 #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
 
diff --git a/block/iscsi.c b/block/iscsi.c
index 14e97a6..5f7b60c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -38,6 +38,7 @@
 #include "qemu/iov.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
+#include "qapi/qmp/qstring.h"
 
 #include <iscsi/iscsi.h>
 #include <iscsi/scsi-lowlevel.h>
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 17bb211..b6f58c1 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -25,6 +25,7 @@
 #include "qemu-common.h"
 #include "block/block_int.h"
 #include "block/qcow2.h"
+#include "qemu/error-report.h"
 
 void qcow2_free_snapshots(BlockDriverState *bs)
 {
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 2990e95..a617ea1 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "qemu/log.h"
 #include "block/block_int.h"
@@ -31,6 +32,7 @@
 #include "qemu/iov.h"
 #include "raw-aio.h"
 #include "qapi/util.h"
+#include "qapi/qmp/qstring.h"
 
 #if defined(__APPLE__) && (__MACH__)
 #include <paths.h>
diff --git a/block/ssh.c b/block/ssh.c
index f466cbf..aebb18c 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -30,9 +30,11 @@
 #include <libssh2_sftp.h>
 
 #include "block/block_int.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/uri.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/qstring.h"
 
 /* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in
  * this block driver code.
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 6547bec..47fec63 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -19,6 +19,7 @@
  */
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "block/vhdx.h"
 
diff --git a/block/vmdk.c b/block/vmdk.c
index e08bb69..1c67b26 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -25,6 +25,7 @@
 
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
 #include <zlib.h>
diff --git a/block/vvfat.c b/block/vvfat.c
index e803589..72c64f6 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -30,6 +30,7 @@
 #include "migration/migration.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qstring.h"
 
 #ifndef S_IWGRP
 #define S_IWGRP 0
diff --git a/blockdev.c b/blockdev.c
index 35008d9..89e3f42 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -35,6 +35,7 @@
 #include "hw/block/block.h"
 #include "block/blockjob.h"
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qapi/qmp/types.h"
diff --git a/cpus.c b/cpus.c
index a928f49..4f0e54d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -27,6 +27,7 @@
 
 #include "monitor/monitor.h"
 #include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 #include "exec/gdbstub.h"
 #include "sysemu/dma.h"
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 4964da0..6ef8af3 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -13,6 +13,7 @@
 
 #include "hw/virtio/virtio.h"
 #include "hw/i386/pc.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "virtio-9p.h"
 #include "fsdev/qemu-fsdev.h"
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index d451b22..78c73e5 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -20,6 +20,7 @@
 
 #include "qemu/iov.h"
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "qemu/queue.h"
 #include "hw/sysbus.h"
 #include "trace.h"
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index fa85735..664e0c3 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -32,6 +32,7 @@
 #include "qapi/qmp/qerror.h"
 #include "qapi/visitor.h"
 #include "qapi/qmp/qjson.h"
+#include "qemu/error-report.h"
 #include "hw/hotplug.h"
 #include "hw/boards.h"
 #include "qapi-event.h"
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 52a9733..7f83a00 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -18,6 +18,7 @@
  */
 
 #include "hw/hw.h"
+#include "qemu/error-report.h"
 #include "ui/console.h"
 #include "ui/pixel_ops.h"
 #include "trace.h"
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index f3faf78..a0b6bc5 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -27,6 +27,7 @@
 #include "ui/pixel_ops.h"
 #include "hw/loader.h"
 #include "hw/sysbus.h"
+#include "qemu/error-report.h"
 
 #define TCX_ROM_FILE "QEMU,tcx.bin"
 #define FCODE_MAX_ROM_SIZE 0x10000
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3f0d435..e715f7a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -57,6 +57,7 @@
 #include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/cpu_hotplug.h"
 #include "hw/cpu/icc_bus.h"
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 9e5d862..215c33f 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -27,6 +27,7 @@
 #include <hw/pci/pci.h>
 #include <hw/sysbus.h>
 
+#include "qemu/error-report.h"
 #include "monitor/monitor.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/dma.h"
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 5d272c8..e0c2758 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -23,6 +23,7 @@
 #include "sysemu/kvm.h"
 #include "migration/migration.h"
 #include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
 #include "qemu/event_notifier.h"
 #include "qemu/fifo8.h"
 #include "sysemu/char.h"
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 750f3da..ec88c83 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -30,6 +30,7 @@
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
+#include "qemu/error-report.h"
 #include "qemu/range.h"
 #include "qmp-commands.h"
 #include "trace.h"
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index 6ebd5be..6feb3c7 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -32,6 +32,7 @@
 #include "sysemu/device_tree.h"
 #include "hw/loader.h"
 #include "elf.h"
+#include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "exec/address-spaces.h"
 
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index b7a88d6..2c16538 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -21,6 +21,7 @@
 #include "hw/virtio/virtio-net.h"
 #include "hw/sysbus.h"
 #include "qemu/bitops.h"
+#include "qemu/error-report.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/s390x/adapter.h"
 #include "hw/s390x/s390_flic.h"
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 1941aa1..3af5080 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -16,6 +16,7 @@
 
 #include <sys/ioctl.h>
 #include "config.h"
+#include "qemu/error-report.h"
 #include "qemu/queue.h"
 #include "monitor/monitor.h"
 #include "migration/migration.h"
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index b50071e..2bb6221 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -27,6 +27,7 @@
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "ui/console.h"
+#include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "hw/timer/hpet.h"
 #include "hw/sysbus.h"
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 8d8523a..79a8f98 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -26,6 +26,7 @@
 
 #include "qemu-common.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "sysemu/tpm_backend.h"
 #include "tpm_int.h"
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 3751675..5f39e1e 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -1,6 +1,7 @@
 #include "hw/hw.h"
 #include "hw/usb.h"
 #include "hw/qdev.h"
+#include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "trace.h"
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 10f1d30..51f3e6a 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -9,6 +9,7 @@
  */
 
 #include "sysemu/char.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "monitor/monitor.h"
 #include "ccid.h"
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 6ca3da9..9c591f3 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "monitor/monitor.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index abe0e1d..9a4e7dc 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -8,6 +8,7 @@
  */
 
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "hw/usb.h"
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 10f4735..bc2944c 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -38,6 +38,7 @@
 
 #include "qemu-common.h"
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 #include "trace.h"
 
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 2322067..110e014 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -29,6 +29,7 @@
 #include "qemu/timer.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
+#include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "sysemu/char.h"
 
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index f8182c7..842b27a 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -12,9 +12,6 @@
 #ifndef QERROR_H
 #define QERROR_H
 
-#include "qapi/qmp/qstring.h"
-#include "qemu/error-report.h"
-
 /*
  * These macros will go away, please don't use in new code, and do not
  * add new ones!
diff --git a/migration/migration.c b/migration/migration.c
index a46deb2..25f6830 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -14,6 +14,7 @@
  */
 
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "migration/migration.h"
 #include "monitor/monitor.h"
diff --git a/migration/qemu-file-buf.c b/migration/qemu-file-buf.c
index 16a51a1..2de9330 100644
--- a/migration/qemu-file-buf.c
+++ b/migration/qemu-file-buf.c
@@ -26,6 +26,7 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
 #include "block/coroutine.h"
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 965a757..557c1c1 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -23,6 +23,7 @@
  */
 #include <zlib.h>
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
 #include "block/coroutine.h"
diff --git a/migration/rdma.c b/migration/rdma.c
index cf5de7e..b777273 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -15,6 +15,7 @@
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "exec/cpu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/sockets.h"
 #include "qemu/bitmap.h"
diff --git a/migration/savevm.c b/migration/savevm.c
index 1acf6ff..2b4e02f 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -37,6 +37,7 @@
 #include "qemu/timer.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/queue.h"
 #include "sysemu/cpus.h"
diff --git a/net/net.c b/net/net.c
index a18b8c3..306cb8d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -32,6 +32,7 @@
 
 #include "monitor/monitor.h"
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/config-file.h"
 #include "qmp-commands.h"
diff --git a/net/slirp.c b/net/slirp.c
index 3533837..7657b38 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -33,6 +33,7 @@
 #include "clients.h"
 #include "hub.h"
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "slirp/libslirp.h"
 #include "sysemu/char.h"
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 4447307..6fdef91 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -24,6 +24,7 @@
 #include "qmp-commands.h"
 #include "sysemu/arch_init.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
 
 /*
  * Aliases were a bad idea from the start.  Let's keep them
diff --git a/qemu-char.c b/qemu-char.c
index d0c1564..617e034 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
+#include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "sysemu/char.h"
 #include "hw/usb.h"
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 52dc611..53477e1 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -13,6 +13,7 @@
 #include "block/block.h"
 #include "block/block_int.h" /* for info_f() */
 #include "block/qapi.h"
+#include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
 #include "sysemu/block-backend.h"
diff --git a/qemu-io.c b/qemu-io.c
index c24f6be..f1e3a67 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -15,10 +15,12 @@
 #include <libgen.h>
 
 #include "qemu-io.h"
+#include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qemu/readline.h"
+#include "qapi/qmp/qstring.h"
 #include "sysemu/block-backend.h"
 #include "block/block_int.h"
 #include "trace/control.h"
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 7a4bf1b..5106b80 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -25,6 +25,7 @@
 #include "qemu/error-report.h"
 #include "block/snapshot.h"
 #include "qapi/util.h"
+#include "qapi/qmp/qstring.h"
 
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/slirp/misc.c b/slirp/misc.c
index 6543dc7..578e8b2 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -9,6 +9,7 @@
 #include <libslirp.h>
 
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 
 #ifdef DEBUG
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d4f4c8d..36b07f9 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -26,6 +26,7 @@
 #include "sysemu/cpus.h"
 #include "kvm_i386.h"
 
+#include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qapi/qmp/qerror.h"
diff --git a/tpm.c b/tpm.c
index 224e65e..2044932 100644
--- a/tpm.c
+++ b/tpm.c
@@ -18,6 +18,7 @@
 #include "sysemu/tpm_backend.h"
 #include "sysemu/tpm.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
 #include "qmp-commands.h"
 
 static QLIST_HEAD(, TPMBackend) tpm_backends =
diff --git a/ui/input.c b/ui/input.c
index e96e1ea..1a552d1 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -1,6 +1,7 @@
 #include "hw/qdev.h"
 #include "sysemu/sysemu.h"
 #include "qapi-types.h"
+#include "qemu/error-report.h"
 #include "qmp-commands.h"
 #include "trace.h"
 #include "ui/input.h"
diff --git a/ui/spice-core.c b/ui/spice-core.c
index a30da3c..bf4fd07 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -22,6 +22,7 @@
 
 #include "qemu-common.h"
 #include "ui/qemu-spice.h"
+#include "qemu/error-report.h"
 #include "qemu/thread.h"
 #include "qemu/timer.h"
 #include "qemu/queue.h"
diff --git a/ui/vnc.c b/ui/vnc.c
index b5e7906..af16584 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -29,6 +29,7 @@
 #include "trace.h"
 #include "hw/qdev.h"
 #include "sysemu/sysemu.h"
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/timer.h"
 #include "qemu/acl.h"
diff --git a/util/osdep.c b/util/osdep.c
index f938b69..0092bb6 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -47,6 +47,7 @@ extern int madvise(caddr_t, size_t, int);
 
 #include "qemu-common.h"
 #include "qemu/sockets.h"
+#include "qemu/error-report.h"
 #include "monitor/monitor.h"
 
 static bool fips_enabled = false;
diff --git a/util/qemu-error.c b/util/qemu-error.c
index 16d2d07..77ea6c6 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -12,6 +12,7 @@
 
 #include <stdio.h>
 #include "monitor/monitor.h"
+#include "qemu/error-report.h"
 
 /*
  * Print to current monitor if we have one, else to stderr.
diff --git a/vl.c b/vl.c
index 10c2cfc..87d3d54 100644
--- a/vl.c
+++ b/vl.c
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
-- 
1.9.3

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

* [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (8 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 15:09   ` Stefan Hajnoczi
  2015-06-15 21:38   ` Eric Blake
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h " Markus Armbruster
  2015-06-15 16:03 ` [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Luiz Capitulino
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

In particular, don't include it into headers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 backends/hostmem.c           | 1 -
 balloon.c                    | 1 +
 block.c                      | 1 +
 block/backup.c               | 1 +
 block/commit.c               | 1 +
 block/mirror.c               | 1 +
 block/qcow.c                 | 1 +
 block/quorum.c               | 1 +
 block/snapshot.c             | 1 +
 block/stream.c               | 1 +
 block/vmdk.c                 | 1 +
 blockdev.c                   | 1 +
 blockjob.c                   | 1 +
 dump.c                       | 1 +
 hmp.c                        | 1 +
 hw/char/serial-pci.c         | 1 -
 hw/dma/xilinx_axidma.c       | 1 -
 hw/misc/ivshmem.c            | 1 -
 hw/net/xilinx_axienet.c      | 1 -
 hw/pci/pci-stub.c            | 1 +
 hw/pci/pcie.c                | 1 -
 hw/pci/shpc.c                | 1 -
 hw/ppc/virtex_ml507.c        | 1 -
 hw/s390x/s390-virtio.c       | 1 +
 hw/usb/redirect.c            | 1 +
 hw/virtio/virtio-rng.c       | 1 -
 include/block/block_int.h    | 1 -
 include/monitor/monitor.h    | 1 -
 include/qemu/sockets.h       | 1 -
 migration/migration.c        | 1 +
 migration/savevm.c           | 1 +
 monitor.c                    | 1 +
 net/net.c                    | 1 +
 numa.c                       | 1 -
 qapi/qmp-output-visitor.c    | 1 -
 qapi/string-output-visitor.c | 1 -
 qdev-monitor.c               | 1 +
 qemu-img.c                   | 1 +
 qmp.c                        | 1 +
 qobject/json-parser.c        | 1 -
 scripts/qapi-commands.py     | 1 -
 stubs/dump.c                 | 1 -
 target-arm/cpu.c             | 1 -
 target-i386/kvm.c            | 1 -
 ui/vnc.c                     | 1 +
 util/qemu-config.c           | 1 -
 46 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index b7b6cf8..2661a04 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -13,7 +13,6 @@
 #include "qapi/visitor.h"
 #include "qapi-types.h"
 #include "qapi-visit.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/config-file.h"
 #include "qom/object_interfaces.h"
 
diff --git a/balloon.c b/balloon.c
index 5f5202c..617187a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -30,6 +30,7 @@
 #include "sysemu/balloon.h"
 #include "trace.h"
 #include "qmp-commands.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
 
 static QEMUBalloonEvent *balloon_event_fn;
diff --git a/block.c b/block.c
index a1b7203..e8d68ec 100644
--- a/block.c
+++ b/block.c
@@ -28,6 +28,7 @@
 #include "block/blockjob.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/sysemu.h"
diff --git a/block/backup.c b/block/backup.c
index 35145cb..4a1af68 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -19,6 +19,7 @@
 #include "block/block.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 
 #define BACKUP_CLUSTER_BITS 16
diff --git a/block/commit.c b/block/commit.c
index 6c01fea..7312a5b 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -15,6 +15,7 @@
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 
 enum {
diff --git a/block/mirror.c b/block/mirror.c
index e3e51a2..048e452 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -14,6 +14,7 @@
 #include "trace.h"
 #include "block/blockjob.h"
 #include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 #include "qemu/bitmap.h"
 
diff --git a/block/qcow.c b/block/qcow.c
index 54152f9..733627f 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -25,6 +25,7 @@
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include <zlib.h>
+#include "qapi/qmp/qerror.h"
 #include "qemu/aes.h"
 #include "migration/migration.h"
 
diff --git a/block/quorum.c b/block/quorum.c
index 3582538..2e04404 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -18,6 +18,7 @@
 #include "block/block_int.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qlist.h"
diff --git a/block/snapshot.c b/block/snapshot.c
index 7cd960c..19395ae 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -24,6 +24,7 @@
 
 #include "block/snapshot.h"
 #include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
 
 QemuOptsList internal_snapshot_opts = {
     .name = "snapshot",
diff --git a/block/stream.c b/block/stream.c
index f17efdb..ab0bd05 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -14,6 +14,7 @@
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 
 enum {
diff --git a/block/vmdk.c b/block/vmdk.c
index 1c67b26..19a5d58 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -25,6 +25,7 @@
 
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
diff --git a/blockdev.c b/blockdev.c
index 89e3f42..4f71f19 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -40,6 +40,7 @@
 #include "qemu/config-file.h"
 #include "qapi/qmp/types.h"
 #include "qapi-visit.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp-output-visitor.h"
 #include "qapi/util.h"
 #include "sysemu/sysemu.h"
diff --git a/blockjob.c b/blockjob.c
index b033f68..ec46fad 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -29,6 +29,7 @@
 #include "block/block.h"
 #include "block/blockjob.h"
 #include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
 #include "block/coroutine.h"
 #include "qmp-commands.h"
diff --git a/dump.c b/dump.c
index 9a02b51..78b7d84 100644
--- a/dump.c
+++ b/dump.c
@@ -23,6 +23,7 @@
 #include "sysemu/memory_mapping.h"
 #include "sysemu/cpus.h"
 #include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
 
 #include <zlib.h>
diff --git a/hmp.c b/hmp.c
index de934bd..149ada4 100644
--- a/hmp.c
+++ b/hmp.c
@@ -25,6 +25,7 @@
 #include "monitor/monitor.h"
 #include "monitor/qdev.h"
 #include "qapi/opts-visitor.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/string-output-visitor.h"
 #include "qapi-visit.h"
 #include "ui/console.h"
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 653064f..1c8b9be 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -27,7 +27,6 @@
 
 #include "hw/char/serial.h"
 #include "hw/pci/pci.h"
-#include "qapi/qmp/qerror.h"
 
 #define PCI_SERIAL_MAX_PORTS 4
 
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index d06002d..cf842a3 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -26,7 +26,6 @@
 #include "qemu/timer.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/main-loop.h"
 
 #include "hw/stream.h"
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index e0c2758..c34d30c 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -22,7 +22,6 @@
 #include "hw/pci/msix.h"
 #include "sysemu/kvm.h"
 #include "migration/migration.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/event_notifier.h"
 #include "qemu/fifo8.h"
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 21efedf..9205770 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -26,7 +26,6 @@
 #include "qemu/log.h"
 #include "net/net.h"
 #include "net/checksum.h"
-#include "qapi/qmp/qerror.h"
 
 #include "hw/stream.h"
 
diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index 9b51d37..063a7c2 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -20,6 +20,7 @@
 
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
+#include "qapi/qmp/qerror.h"
 #include "hw/pci/pci.h"
 #include "qmp-commands.h"
 
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 1463e65..14c7711 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -26,7 +26,6 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "qemu/range.h"
-#include "qapi/qmp/qerror.h"
 
 //#define DEBUG_PCIE
 #ifdef DEBUG_PCIE
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index a706486..bfb4d31 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -7,7 +7,6 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/msi.h"
-#include "qapi/qmp/qerror.h"
 
 /* TODO: model power only and disabled slot states. */
 /* TODO: handle SERR and wakeups */
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index 6feb3c7..439732f 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -41,7 +41,6 @@
 #include "ppc405.h"
 
 #include "sysemu/block-backend.h"
-#include "qapi/qmp/qerror.h"
 
 #define EPAPR_MAGIC    (0x45504150)
 #define FLASH_SIZE     (16 * 1024 * 1024)
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index d20b27f..9eb20b7 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -22,6 +22,7 @@
  */
 
 #include "hw/hw.h"
+#include "qapi/qmp/qerror.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 110e014..4e9528e 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -29,6 +29,7 @@
 #include "qemu/timer.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "sysemu/char.h"
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 22b1d87..740ed31 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -11,7 +11,6 @@
 
 #include "qemu/iov.h"
 #include "hw/qdev.h"
-#include "qapi/qmp/qerror.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-rng.h"
 #include "sysemu/rng.h"
diff --git a/include/block/block_int.h b/include/block/block_int.h
index f004378..459af80 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -31,7 +31,6 @@
 #include "block/coroutine.h"
 #include "qemu/timer.h"
 #include "qapi-types.h"
-#include "qapi/qmp/qerror.h"
 #include "monitor/monitor.h"
 #include "qemu/hbitmap.h"
 #include "block/snapshot.h"
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 01c9d57..cc8a359 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -2,7 +2,6 @@
 #define MONITOR_H
 
 #include "qemu-common.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qdict.h"
 #include "block/block.h"
 #include "qemu/readline.h"
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 7992ece..c174b5c 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -28,7 +28,6 @@ int inet_aton(const char *cp, struct in_addr *ia);
 
 #include "qemu/option.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi-types.h"
 
 extern QemuOptsList socket_optslist;
diff --git a/migration/migration.c b/migration/migration.c
index 25f6830..d7056d7 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -21,6 +21,7 @@
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/sockets.h"
 #include "migration/block.h"
 #include "qemu/thread.h"
diff --git a/migration/savevm.c b/migration/savevm.c
index 2b4e02f..9e0e286 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -37,6 +37,7 @@
 #include "qemu/timer.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/queue.h"
diff --git a/monitor.c b/monitor.c
index 356409e..2927a2d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -49,6 +49,7 @@
 #include "sysemu/kvm.h"
 #include "qemu/acl.h"
 #include "sysemu/tpm.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qfloat.h"
 #include "qapi/qmp/qlist.h"
diff --git a/net/net.c b/net/net.c
index 306cb8d..df29cb7 100644
--- a/net/net.c
+++ b/net/net.c
@@ -32,6 +32,7 @@
 
 #include "monitor/monitor.h"
 #include "qemu-common.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "qemu/config-file.h"
diff --git a/numa.c b/numa.c
index d227ccc..5b9fca0 100644
--- a/numa.c
+++ b/numa.c
@@ -31,7 +31,6 @@
 #include "qapi-visit.h"
 #include "qapi/opts-visitor.h"
 #include "qapi/dealloc-visitor.h"
-#include "qapi/qmp/qerror.h"
 #include "hw/boards.h"
 #include "sysemu/hostmem.h"
 #include "qmp-commands.h"
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index 96b3384..edfb178 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -16,7 +16,6 @@
 #include "qemu/queue.h"
 #include "qemu-common.h"
 #include "qapi/qmp/types.h"
-#include "qapi/qmp/qerror.h"
 
 typedef struct QStackEntry
 {
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 1ab8574..b86ce2c 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -13,7 +13,6 @@
 #include "qemu-common.h"
 #include "qapi/string-output-visitor.h"
 #include "qapi/visitor-impl.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/host-utils.h"
 #include <math.h>
 #include "qemu/range.h"
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 6fdef91..95ea4e2 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -23,6 +23,7 @@
 #include "monitor/qdev.h"
 #include "qmp-commands.h"
 #include "sysemu/arch_init.h"
+#include "qapi/qmp/qerror.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 
diff --git a/qemu-img.c b/qemu-img.c
index 6d1b136..75f4ee4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -23,6 +23,7 @@
  */
 #include "qapi-visit.h"
 #include "qapi/qmp-output-visitor.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
 #include "qemu-common.h"
 #include "qemu/option.h"
diff --git a/qmp.c b/qmp.c
index 4acc222..3dde771 100644
--- a/qmp.c
+++ b/qmp.c
@@ -24,6 +24,7 @@
 #include "hw/qdev.h"
 #include "sysemu/blockdev.h"
 #include "qom/qom-qobject.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp-input-visitor.h"
 #include "hw/boards.h"
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 717cb8f..a022ee6 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -22,7 +22,6 @@
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/json-lexer.h"
-#include "qapi/qmp/qerror.h"
 
 typedef struct JSONParserContext
 {
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index a451a51..ca22acc 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -329,7 +329,6 @@ h_comment = '''
 fdef.write(mcgen('''
 #include "qemu-common.h"
 #include "qemu/module.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/types.h"
 #include "qapi/qmp/dispatch.h"
 #include "qapi/visitor.h"
diff --git a/stubs/dump.c b/stubs/dump.c
index fac7019..8c24eda 100644
--- a/stubs/dump.c
+++ b/stubs/dump.c
@@ -13,7 +13,6 @@
 
 #include "qemu-common.h"
 #include "sysemu/dump-arch.h"
-#include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
 
 int cpu_get_dump_info(ArchDumpInfo *info,
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 4a888ab..dce4f57 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -22,7 +22,6 @@
 #include "internals.h"
 #include "qemu-common.h"
 #include "hw/qdev-properties.h"
-#include "qapi/qmp/qerror.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #endif
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 5a236e3..daced5c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -36,7 +36,6 @@
 #include <asm/hyperv.h>
 #include "hw/pci/pci.h"
 #include "migration/migration.h"
-#include "qapi/qmp/qerror.h"
 #include "exec/memattrs.h"
 
 //#define DEBUG_KVM
diff --git a/ui/vnc.c b/ui/vnc.c
index af16584..2ffd9e5 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -34,6 +34,7 @@
 #include "qemu/timer.h"
 #include "qemu/acl.h"
 #include "qemu/config-file.h"
+#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/types.h"
 #include "qmp-commands.h"
 #include "qemu/osdep.h"
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 6cfdd72..5fcfd0e 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -2,7 +2,6 @@
 #include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/error.h"
 #include "qmp-commands.h"
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h exactly where needed
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (9 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
@ 2015-06-13 14:20 ` Markus Armbruster
  2015-06-15 15:09   ` Stefan Hajnoczi
  2015-06-15 21:40   ` Eric Blake
  2015-06-15 16:03 ` [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Luiz Capitulino
  11 siblings, 2 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-13 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

In particular, don't include it into headers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 balloon.c                     | 2 +-
 blockdev-nbd.c                | 1 -
 hw/core/platform-bus.c        | 1 -
 hw/display/qxl.c              | 1 -
 hw/i386/pc.c                  | 1 -
 hw/ide/ahci.c                 | 1 -
 hw/ppc/spapr_vio.c            | 1 -
 hw/s390x/event-facility.c     | 1 -
 hw/s390x/s390-virtio-bus.c    | 1 -
 hw/s390x/s390-virtio.c        | 1 -
 hw/s390x/virtio-ccw.c         | 1 -
 hw/usb/ccid-card-emulated.c   | 1 -
 hw/usb/ccid-card-passthru.c   | 1 -
 hw/usb/dev-serial.c           | 1 -
 hw/usb/dev-smartcard-reader.c | 1 -
 hw/usb/hcd-ehci.h             | 1 -
 hw/usb/redirect.c             | 1 -
 include/block/block_int.h     | 1 -
 include/monitor/qdev.h        | 2 +-
 include/sysemu/balloon.h      | 1 -
 include/ui/console.h          | 2 +-
 include/ui/qemu-spice.h       | 2 --
 migration/migration.c         | 1 -
 net/l2tpv3.c                  | 1 -
 qmp.c                         | 1 +
 target-s390x/kvm.c            | 1 -
 tpm.c                         | 1 -
 ui/input-legacy.c             | 1 -
 ui/spice-display.c            | 1 -
 29 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/balloon.c b/balloon.c
index 617187a..5d69e8a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "monitor/monitor.h"
+#include "qemu-common.h"
 #include "exec/cpu-common.h"
 #include "sysemu/kvm.h"
 #include "sysemu/balloon.h"
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 944c1b6..bcdd18b 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -12,7 +12,6 @@
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 #include "hw/block/block.h"
-#include "monitor/monitor.h"
 #include "qapi/qmp/qerror.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 0f052b3..70e0518 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -20,7 +20,6 @@
  */
 
 #include "hw/platform-bus.h"
-#include "monitor/monitor.h"
 #include "exec/address-spaces.h"
 #include "sysemu/sysemu.h"
 
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 722146e..f87a5ee 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -25,7 +25,6 @@
 #include "qemu/timer.h"
 #include "qemu/queue.h"
 #include "qemu/atomic.h"
-#include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "trace.h"
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e715f7a..7072930 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -31,7 +31,6 @@
 #include "hw/ide.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
-#include "monitor/monitor.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/timer/hpet.h"
 #include "hw/i386/smbios.h"
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 215c33f..b4b65c1 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -28,7 +28,6 @@
 #include <hw/sysbus.h>
 
 #include "qemu/error-report.h"
-#include "monitor/monitor.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/dma.h"
 #include "internal.h"
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 174033d..8b59b64 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -22,7 +22,6 @@
 #include "hw/hw.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "monitor/monitor.h"
 #include "hw/loader.h"
 #include "elf.h"
 #include "hw/sysbus.h"
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 1cb116a..0c700ef 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -15,7 +15,6 @@
  *
  */
 
-#include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 
 #include "hw/s390x/sclp.h"
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 8a6e27e..77aec8a 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -21,7 +21,6 @@
 #include "sysemu/block-backend.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "monitor/monitor.h"
 #include "hw/loader.h"
 #include "elf.h"
 #include "hw/virtio/virtio.h"
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 9eb20b7..87d8d79 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -28,7 +28,6 @@
 #include "sysemu/sysemu.h"
 #include "net/net.h"
 #include "hw/boards.h"
-#include "monitor/monitor.h"
 #include "hw/loader.h"
 #include "hw/virtio/virtio.h"
 #include "hw/sysbus.h"
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 2c16538..9d31a0a 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -15,7 +15,6 @@
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
 #include "net/net.h"
-#include "monitor/monitor.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-serial.h"
 #include "hw/virtio/virtio-net.h"
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index aa1c37a..72329ed 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -33,7 +33,6 @@
 
 #include "qemu/thread.h"
 #include "sysemu/char.h"
-#include "monitor/monitor.h"
 #include "ccid.h"
 
 #define DPRINTF(card, lvl, fmt, ...) \
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 51f3e6a..85a4fc3 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -11,7 +11,6 @@
 #include "sysemu/char.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
-#include "monitor/monitor.h"
 #include "ccid.h"
 #include "libcacard/vscard_common.h"
 
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 9c591f3..a6a6600 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -10,7 +10,6 @@
 
 #include "qemu-common.h"
 #include "qemu/error-report.h"
-#include "monitor/monitor.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
 #include "sysemu/char.h"
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 2d29367..de534ba 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -38,7 +38,6 @@
 #include "qemu/error-report.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
-#include "monitor/monitor.h"
 
 #include "ccid.h"
 
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 87b240f..3021842 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -20,7 +20,6 @@
 #include "hw/hw.h"
 #include "qemu/timer.h"
 #include "hw/usb.h"
-#include "monitor/monitor.h"
 #include "sysemu/dma.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 4e9528e..25df25f 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -27,7 +27,6 @@
 
 #include "qemu-common.h"
 #include "qemu/timer.h"
-#include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 459af80..084129b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -31,7 +31,6 @@
 #include "block/coroutine.h"
 #include "qemu/timer.h"
 #include "qapi-types.h"
-#include "monitor/monitor.h"
 #include "qemu/hbitmap.h"
 #include "block/snapshot.h"
 #include "qemu/main-loop.h"
diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
index dc796c8..50ec2ff 100644
--- a/include/monitor/qdev.h
+++ b/include/monitor/qdev.h
@@ -2,7 +2,7 @@
 #define QEMU_QDEV_MONITOR_H
 
 #include "hw/qdev-core.h"
-#include "monitor/monitor.h"
+#include "qemu/typedefs.h"
 
 /*** monitor commands ***/
 
diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h
index 0345e01..17fe300 100644
--- a/include/sysemu/balloon.h
+++ b/include/sysemu/balloon.h
@@ -14,7 +14,6 @@
 #ifndef _QEMU_BALLOON_H
 #define _QEMU_BALLOON_H
 
-#include "monitor/monitor.h"
 #include "qapi-types.h"
 
 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
diff --git a/include/ui/console.h b/include/ui/console.h
index 9ad6c17..047a2b4 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -5,7 +5,7 @@
 #include "qom/object.h"
 #include "qapi/qmp/qdict.h"
 #include "qemu/notify.h"
-#include "monitor/monitor.h"
+#include "qemu/typedefs.h"
 #include "qapi-types.h"
 #include "qapi/error.h"
 
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 42db3c1..0dff422 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -26,7 +26,6 @@
 
 #include "qemu/option.h"
 #include "qemu/config-file.h"
-#include "monitor/monitor.h"
 
 extern int using_spice;
 
@@ -54,7 +53,6 @@ static inline CharDriverState *qemu_chr_open_spice_port(const char *name)
 #endif
 
 #else  /* CONFIG_SPICE */
-#include "monitor/monitor.h"
 
 #define using_spice 0
 #define spice_displays 0
diff --git a/migration/migration.c b/migration/migration.c
index d7056d7..c6ac08a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -17,7 +17,6 @@
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "migration/migration.h"
-#include "monitor/monitor.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
index 356dae2..4f9bcee 100644
--- a/net/l2tpv3.c
+++ b/net/l2tpv3.c
@@ -28,7 +28,6 @@
 #include "config-host.h"
 #include "net/net.h"
 #include "clients.h"
-#include "monitor/monitor.h"
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
diff --git a/qmp.c b/qmp.c
index 3dde771..c941585 100644
--- a/qmp.c
+++ b/qmp.c
@@ -14,6 +14,7 @@
  */
 
 #include "qemu-common.h"
+#include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
 #include "sysemu/char.h"
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index f6f61b9..288f7e2 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -36,7 +36,6 @@
 #include "cpu.h"
 #include "sysemu/device_tree.h"
 #include "qapi/qmp/qjson.h"
-#include "monitor/monitor.h"
 #include "exec/gdbstub.h"
 #include "exec/address-spaces.h"
 #include "trace.h"
diff --git a/tpm.c b/tpm.c
index 2044932..2c66072 100644
--- a/tpm.c
+++ b/tpm.c
@@ -13,7 +13,6 @@
  */
 #include "config-host.h"
 
-#include "monitor/monitor.h"
 #include "qapi/qmp/qerror.h"
 #include "sysemu/tpm_backend.h"
 #include "sysemu/tpm.h"
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 3e9bb38..e50f296 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -23,7 +23,6 @@
  */
 
 #include "sysemu/sysemu.h"
-#include "monitor/monitor.h"
 #include "ui/console.h"
 #include "qapi/error.h"
 #include "qmp-commands.h"
diff --git a/ui/spice-display.c b/ui/spice-display.c
index cc4a6ce..0360abf 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -19,7 +19,6 @@
 #include "ui/qemu-spice.h"
 #include "qemu/timer.h"
 #include "qemu/queue.h"
-#include "monitor/monitor.h"
 #include "ui/console.h"
 #include "sysemu/sysemu.h"
 #include "trace.h"
-- 
1.9.3

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

* Re: [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err()
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
@ 2015-06-14  2:57   ` Eric Blake
  2015-06-16 10:58     ` Markus Armbruster
  2015-06-15 16:19   ` Stefan Hajnoczi
  1 sibling, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-14  2:57 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> qerror_report_err() is a transitional interface to help with
> converting existing monitor commands to QMP.  It should not be used
> elsewhere.
> 
> The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
> used in QMP context?  If not, we can simply replace
> qerror_report_err() by error_report_err().
> 

> 
> Propoagate errors through qemu_opts_parse().  Create a convenience

s/Propoagate/Propagate/

> function qemu_opts_parse_noisily() that passes errors to
> error_report_err().  Switch all non-QMP users outside tests to it.
> 
> That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
> touching it anyway, rename it to vnc_parse().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers Markus Armbruster
@ 2015-06-14  3:09   ` Eric Blake
  2015-06-16 12:00     ` Markus Armbruster
  0 siblings, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-14  3:09 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> qerror_report() is a transitional interface to help with converting
> existing monitor commands to QMP.  It should not be used elsewhere.
> Replace by error_report() in initial startup helpers parse_sandbox()
> and parse_add_fd().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  vl.c | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 

>  #else
> -        qerror_report(ERROR_CLASS_GENERIC_ERROR,
> -                      "sandboxing request but seccomp is not compiled into this build");
> +        error_report("sandboxing request but seccomp is not compiled "
> +                     "into this build");

Pre-existing, but s/request/requested/ would sound better while touching
this.

Either way,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors Markus Armbruster
@ 2015-06-15 12:49   ` Eric Blake
  0 siblings, 0 replies; 45+ messages in thread
From: Eric Blake @ 2015-06-15 12:49 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> Results in nicer error messages.  Before this patch:
> 
>     Invalid GTK option string: gtk,lirum-larum
> 
> After:
> 
>     qemu-system-x86_64: -display gtk,lirum-larum: Invalid GTK option string
> 
> Of course, the thing ought to use QemuOpts instead of parsing by hand.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  vl.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
@ 2015-06-15 13:59   ` Eric Blake
  2015-06-16 12:26     ` Markus Armbruster
  2015-06-15 15:13   ` Stefan Hajnoczi
  2015-06-15 15:18   ` Luiz Capitulino
  2 siblings, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 13:59 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
> Fortunately, there's just one such macro left.  Eliminate it with this
> coccinelle semantic patch:
> 
>     @@
>     expression EP, E;
>     @@
>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  backends/rng-egd.c        |  3 ++-
>  blockdev-nbd.c            |  3 ++-
>  blockdev.c                | 33 ++++++++++++++++++++++-----------
>  hmp.c                     |  6 ++++--
>  include/qapi/qmp/qerror.h |  3 ---
>  net/net.c                 |  6 ++++--
>  qdev-monitor.c            |  6 ++++--
>  qmp.c                     | 12 ++++++++----
>  qom/object.c              |  6 ++++--
>  ui/input.c                |  3 ++-
>  10 files changed, 52 insertions(+), 29 deletions(-)

Plain transformation would be closer to a 1:1 insertion/deletion count.
 The larger insertion count is due to reflowing long lines after the
transformation.  Does coccinelle do that for you, or do you have to
touch things up manually?  But I'm okay with the result.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report()
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report() Markus Armbruster
@ 2015-06-15 15:08   ` Stefan Hajnoczi
  2015-06-15 20:56   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:08 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:54PM +0200, Markus Armbruster wrote:
> The traditional QMP command handler interface
> 
>     int qmp_FOO(Monitor *mon, const QDict *params, QObject **ret_data);
> 
> doesn't provide for returning an Error object.  Instead, the handler
> is expected to stash it in the monitor with qerror_report().
> 
> When we rebased QMP on top of QAPI, we didn't change this interface.
> Instead, commit 776574d introduced "middle mode" as a temporary aid
> for converting existing QMP commands to QAPI one by one.  More than
> three years later, we're still using it.
> 
> Middle mode has two effects:
> 
> * Instead of the native input marshallers
> 
>       static void qmp_marshal_input_FOO(QDict *, QObject **, Error **)
> 
>   it generates input marshallers conforming to the traditional QMP
>   command handler interface.
> 
> * It suppresses generation of code to register them with
>   qmp_register_command()
> 
>   This permits giving them internal linkage.
> 
> As long as we need qmp-commands.hx, we can't use the registry behind
> qmp_register_command(), so the latter has to stay for now.
> 
> The former has to go to get rid of qerror_report().  Changing all QMP
> commands to fit the QAPI mold in one go was impractical back when we
> started, but by now there are just a few stragglers left:
> do_qmp_capabilities(), qmp_qom_set(), qmp_qom_get(), qmp_object_add(),
> qmp_netdev_add(), do_device_add().
> 
> Switch middle mode to generate native input marshallers, and adapt the
> stragglers.  Simplifies both the monitor code and the stragglers.
> 
> Rename do_qmp_capabilities() to qmp_capabilities(), and
> do_device_add() to qmp_device_add, because that's how QMP command
> handlers are named today.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hmp.c                     |  5 ++++-
>  include/monitor/monitor.h |  7 +++---
>  include/monitor/qdev.h    |  3 ++-
>  include/net/net.h         |  2 +-
>  monitor.c                 | 24 ++++++---------------
>  net/net.c                 | 16 ++++++--------
>  qdev-monitor.c            | 15 ++++++-------
>  qmp-commands.hx           |  4 ++--
>  qmp.c                     | 55 +++++++++++------------------------------------
>  scripts/qapi-commands.py  | 41 ++++++-----------------------------
>  util/qemu-error.c         |  4 ++--
>  11 files changed, 50 insertions(+), 126 deletions(-)

Net portions look good.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h Markus Armbruster
@ 2015-06-15 15:08   ` Stefan Hajnoczi
  2015-06-15 21:37   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:08 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:56PM +0200, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  audio/spiceaudio.c          | 1 +
>  audio/wavcapture.c          | 1 +
>  block.c                     | 1 +
>  block/curl.c                | 1 +
>  block/dmg.c                 | 1 +
>  block/io.c                  | 1 +
>  block/iscsi.c               | 1 +
>  block/qcow2-snapshot.c      | 1 +
>  block/raw-posix.c           | 2 ++
>  block/ssh.c                 | 2 ++
>  block/vhdx-log.c            | 1 +
>  block/vmdk.c                | 1 +
>  block/vvfat.c               | 1 +
>  blockdev.c                  | 1 +
>  cpus.c                      | 1 +
>  hw/9pfs/virtio-9p.c         | 1 +
>  hw/char/virtio-serial-bus.c | 1 +
>  hw/core/qdev.c              | 1 +
>  hw/display/g364fb.c         | 1 +
>  hw/display/tcx.c            | 1 +
>  hw/i386/pc.c                | 1 +
>  hw/ide/ahci.c               | 1 +
>  hw/misc/ivshmem.c           | 1 +
>  hw/pci/pci.c                | 1 +
>  hw/ppc/virtex_ml507.c       | 1 +
>  hw/s390x/virtio-ccw.c       | 1 +
>  hw/scsi/vhost-scsi.c        | 1 +
>  hw/timer/hpet.c             | 1 +
>  hw/tpm/tpm_passthrough.c    | 1 +
>  hw/usb/bus.c                | 1 +
>  hw/usb/ccid-card-passthru.c | 1 +
>  hw/usb/dev-serial.c         | 1 +
>  hw/usb/dev-storage.c        | 1 +
>  hw/usb/host-libusb.c        | 1 +
>  hw/usb/redirect.c           | 1 +
>  include/qapi/qmp/qerror.h   | 3 ---
>  migration/migration.c       | 1 +
>  migration/qemu-file-buf.c   | 1 +
>  migration/qemu-file.c       | 1 +
>  migration/rdma.c            | 1 +
>  migration/savevm.c          | 1 +
>  net/net.c                   | 1 +
>  net/slirp.c                 | 1 +
>  qdev-monitor.c              | 1 +
>  qemu-char.c                 | 1 +
>  qemu-io-cmds.c              | 1 +
>  qemu-io.c                   | 2 ++
>  qemu-nbd.c                  | 1 +
>  slirp/misc.c                | 1 +
>  target-i386/cpu.c           | 1 +
>  tpm.c                       | 1 +
>  ui/input.c                  | 1 +
>  ui/spice-core.c             | 1 +
>  ui/vnc.c                    | 1 +
>  util/osdep.c                | 1 +
>  util/qemu-error.c           | 1 +
>  vl.c                        | 1 +
>  57 files changed, 59 insertions(+), 3 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
@ 2015-06-15 15:09   ` Stefan Hajnoczi
  2015-06-15 21:38   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:09 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:57PM +0200, Markus Armbruster wrote:
> In particular, don't include it into headers.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  backends/hostmem.c           | 1 -
>  balloon.c                    | 1 +
>  block.c                      | 1 +
>  block/backup.c               | 1 +
>  block/commit.c               | 1 +
>  block/mirror.c               | 1 +
>  block/qcow.c                 | 1 +
>  block/quorum.c               | 1 +
>  block/snapshot.c             | 1 +
>  block/stream.c               | 1 +
>  block/vmdk.c                 | 1 +
>  blockdev.c                   | 1 +
>  blockjob.c                   | 1 +
>  dump.c                       | 1 +
>  hmp.c                        | 1 +
>  hw/char/serial-pci.c         | 1 -
>  hw/dma/xilinx_axidma.c       | 1 -
>  hw/misc/ivshmem.c            | 1 -
>  hw/net/xilinx_axienet.c      | 1 -
>  hw/pci/pci-stub.c            | 1 +
>  hw/pci/pcie.c                | 1 -
>  hw/pci/shpc.c                | 1 -
>  hw/ppc/virtex_ml507.c        | 1 -
>  hw/s390x/s390-virtio.c       | 1 +
>  hw/usb/redirect.c            | 1 +
>  hw/virtio/virtio-rng.c       | 1 -
>  include/block/block_int.h    | 1 -
>  include/monitor/monitor.h    | 1 -
>  include/qemu/sockets.h       | 1 -
>  migration/migration.c        | 1 +
>  migration/savevm.c           | 1 +
>  monitor.c                    | 1 +
>  net/net.c                    | 1 +
>  numa.c                       | 1 -
>  qapi/qmp-output-visitor.c    | 1 -
>  qapi/string-output-visitor.c | 1 -
>  qdev-monitor.c               | 1 +
>  qemu-img.c                   | 1 +
>  qmp.c                        | 1 +
>  qobject/json-parser.c        | 1 -
>  scripts/qapi-commands.py     | 1 -
>  stubs/dump.c                 | 1 -
>  target-arm/cpu.c             | 1 -
>  target-i386/kvm.c            | 1 -
>  ui/vnc.c                     | 1 +
>  util/qemu-config.c           | 1 -
>  46 files changed, 25 insertions(+), 21 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h exactly where needed
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h " Markus Armbruster
@ 2015-06-15 15:09   ` Stefan Hajnoczi
  2015-06-15 21:40   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:09 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:58PM +0200, Markus Armbruster wrote:
> In particular, don't include it into headers.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  balloon.c                     | 2 +-
>  blockdev-nbd.c                | 1 -
>  hw/core/platform-bus.c        | 1 -
>  hw/display/qxl.c              | 1 -
>  hw/i386/pc.c                  | 1 -
>  hw/ide/ahci.c                 | 1 -
>  hw/ppc/spapr_vio.c            | 1 -
>  hw/s390x/event-facility.c     | 1 -
>  hw/s390x/s390-virtio-bus.c    | 1 -
>  hw/s390x/s390-virtio.c        | 1 -
>  hw/s390x/virtio-ccw.c         | 1 -
>  hw/usb/ccid-card-emulated.c   | 1 -
>  hw/usb/ccid-card-passthru.c   | 1 -
>  hw/usb/dev-serial.c           | 1 -
>  hw/usb/dev-smartcard-reader.c | 1 -
>  hw/usb/hcd-ehci.h             | 1 -
>  hw/usb/redirect.c             | 1 -
>  include/block/block_int.h     | 1 -
>  include/monitor/qdev.h        | 2 +-
>  include/sysemu/balloon.h      | 1 -
>  include/ui/console.h          | 2 +-
>  include/ui/qemu-spice.h       | 2 --
>  migration/migration.c         | 1 -
>  net/l2tpv3.c                  | 1 -
>  qmp.c                         | 1 +
>  target-s390x/kvm.c            | 1 -
>  tpm.c                         | 1 -
>  ui/input-legacy.c             | 1 -
>  ui/spice-display.c            | 1 -
>  29 files changed, 4 insertions(+), 29 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
@ 2015-06-15 15:12   ` Stefan Hajnoczi
  2015-06-15 16:09   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:12 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:52PM +0200, Markus Armbruster wrote:
> These macros expand into error class enumeration constant, comma,
> string.  Unclean.  Has been that way since commit 13f59ae.
> 
> The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
> commit.
> 
> Clean up as follows:
> 
> * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
>   delete it from the QERR_ macro.  No change after preprocessing.
> 
> * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
>   error_setg(...).  Again, no change after preprocessing.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  backends/rng-egd.c               |  8 ++---
>  backends/rng-random.c            |  6 ++--
>  backends/rng.c                   |  2 +-
>  backends/tpm.c                   |  2 +-
>  balloon.c                        |  2 +-
>  block.c                          |  2 +-
>  block/backup.c                   |  4 +--
>  block/commit.c                   |  2 +-
>  block/mirror.c                   |  8 ++---
>  block/qcow.c                     |  4 +--
>  block/qcow2.c                    |  4 +--
>  block/qed.c                      |  4 +--
>  block/quorum.c                   |  4 +--
>  block/snapshot.c                 |  4 +--
>  block/stream.c                   |  4 +--
>  block/vmdk.c                     | 12 ++++----
>  blockdev-nbd.c                   |  2 +-
>  blockdev.c                       | 43 +++++++++++++-------------
>  blockjob.c                       |  8 ++---
>  cpus.c                           |  8 ++---
>  dump.c                           | 12 ++++----
>  hmp.c                            | 10 +++---
>  hw/core/nmi.c                    |  2 +-
>  hw/core/qdev-properties-system.c |  3 +-
>  hw/core/qdev-properties.c        | 12 ++++----
>  hw/core/qdev.c                   |  8 ++---
>  hw/intc/openpic.c                |  6 ++--
>  hw/pci/pci-stub.c                |  2 +-
>  hw/ppc/spapr_pci.c               |  8 ++---
>  hw/s390x/s390-virtio.c           |  2 +-
>  hw/usb/redirect.c                |  6 ++--
>  include/qapi/qmp/qerror.h        | 60 ++++++++++++++++++------------------
>  migration/migration.c            | 35 ++++++++++-----------
>  migration/savevm.c               |  2 +-
>  monitor.c                        | 66 ++++++++++++++++++++--------------------
>  net/net.c                        | 12 ++++----
>  qapi/opts-visitor.c              | 24 +++++++--------
>  qapi/qapi-visit-core.c           | 28 ++++++++---------
>  qapi/qmp-dispatch.c              | 12 ++++----
>  qapi/qmp-input-visitor.c         | 28 ++++++++---------
>  qapi/string-input-visitor.c      | 24 +++++++--------
>  qdev-monitor.c                   | 12 ++++----
>  qemu-img.c                       |  2 +-
>  qga/commands-posix.c             | 40 ++++++++++++------------
>  qga/commands-win32.c             | 66 ++++++++++++++++++++--------------------
>  qga/main.c                       |  4 +--
>  qmp.c                            | 34 ++++++++++-----------
>  qom/object.c                     | 12 ++++----
>  stubs/arch-query-cpu-def.c       |  2 +-
>  target-i386/cpu.c                | 19 ++++++------
>  tpm.c                            |  8 +++--
>  ui/vnc.c                         |  4 +--
>  util/qemu-option.c               | 22 ++++++++------
>  53 files changed, 362 insertions(+), 358 deletions(-)

Nice simplification.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
  2015-06-15 13:59   ` Eric Blake
@ 2015-06-15 15:13   ` Stefan Hajnoczi
  2015-06-15 15:18   ` Luiz Capitulino
  2 siblings, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 15:13 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:51PM +0200, Markus Armbruster wrote:
> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
> Fortunately, there's just one such macro left.  Eliminate it with this
> coccinelle semantic patch:
> 
>     @@
>     expression EP, E;
>     @@
>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  backends/rng-egd.c        |  3 ++-
>  blockdev-nbd.c            |  3 ++-
>  blockdev.c                | 33 ++++++++++++++++++++++-----------
>  hmp.c                     |  6 ++++--
>  include/qapi/qmp/qerror.h |  3 ---
>  net/net.c                 |  6 ++++--
>  qdev-monitor.c            |  6 ++++--
>  qmp.c                     | 12 ++++++++----
>  qom/object.c              |  6 ++++--
>  ui/input.c                |  3 ++-
>  10 files changed, 52 insertions(+), 29 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
  2015-06-15 13:59   ` Eric Blake
  2015-06-15 15:13   ` Stefan Hajnoczi
@ 2015-06-15 15:18   ` Luiz Capitulino
  2015-06-15 20:33     ` Eric Blake
  2015-06-15 20:41     ` Peter Maydell
  2 siblings, 2 replies; 45+ messages in thread
From: Luiz Capitulino @ 2015-06-15 15:18 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, mdroth

On Sat, 13 Jun 2015 16:20:51 +0200
Markus Armbruster <armbru@redhat.com> wrote:

> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
> Fortunately, there's just one such macro left.  Eliminate it with this
> coccinelle semantic patch:
> 
>     @@
>     expression EP, E;
>     @@
>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)

This is a bit minor, but I think I'd have created a new function instead,
say error_set_enodev(). This avoids all the duplication. But I'm not asking
you to change, as the patch is good and this can be done in the future if
we so want.

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  backends/rng-egd.c        |  3 ++-
>  blockdev-nbd.c            |  3 ++-
>  blockdev.c                | 33 ++++++++++++++++++++++-----------
>  hmp.c                     |  6 ++++--
>  include/qapi/qmp/qerror.h |  3 ---
>  net/net.c                 |  6 ++++--
>  qdev-monitor.c            |  6 ++++--
>  qmp.c                     | 12 ++++++++----
>  qom/object.c              |  6 ++++--
>  ui/input.c                |  3 ++-
>  10 files changed, 52 insertions(+), 29 deletions(-)
> 
> diff --git a/backends/rng-egd.c b/backends/rng-egd.c
> index 2962795..849bd7a 100644
> --- a/backends/rng-egd.c
> +++ b/backends/rng-egd.c
> @@ -147,7 +147,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
>  
>      s->chr = qemu_chr_find(s->chr_name);
>      if (s->chr == NULL) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", s->chr_name);
>          return;
>      }
>  
> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
> index 0d9df47..128e810 100644
> --- a/blockdev-nbd.c
> +++ b/blockdev-nbd.c
> @@ -91,7 +91,8 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      if (!blk_is_inserted(blk)) {
> diff --git a/blockdev.c b/blockdev.c
> index a88ea76..8dec0cc 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1102,7 +1102,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return NULL;
>      }
>      bs = blk_bs(blk);
> @@ -1291,7 +1292,8 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
>      /* 2. check for validation */
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -1571,7 +1573,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
>  
>      blk = blk_by_name(backup->device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", backup->device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -1841,7 +1844,8 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>  
> @@ -1901,7 +1905,8 @@ void qmp_change_blockdev(const char *device, const char *filename,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -1960,7 +1965,8 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -2275,7 +2281,8 @@ void qmp_block_stream(const char *device,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -2349,7 +2356,8 @@ void qmp_block_commit(const char *device,
>       *  scenario in which all optional arguments are omitted. */
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -2461,7 +2469,8 @@ void qmp_drive_backup(const char *device, const char *target,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -2675,7 +2684,8 @@ void qmp_drive_mirror(const char *device, const char *target,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> @@ -2941,7 +2951,8 @@ void qmp_change_backing_file(const char *device,
>  
>      blk = blk_by_name(device);
>      if (!blk) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>          return;
>      }
>      bs = blk_bs(blk);
> diff --git a/hmp.c b/hmp.c
> index 05e4927..6f63927 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -1863,7 +1863,8 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
>      if (blk) {
>          qemuio_command(blk, command);
>      } else {
> -        error_set(&err, QERR_DEVICE_NOT_FOUND, device);
> +        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device);
>      }
>  
>      hmp_handle_error(mon, &err);
> @@ -1991,7 +1992,8 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
>  
>      obj = object_resolve_path(path, &ambiguous);
>      if (obj == NULL) {
> -        error_set(&err, QERR_DEVICE_NOT_FOUND, path);
> +        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", path);
>      } else {
>          if (ambiguous) {
>              monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 6468e40..2841344 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -55,9 +55,6 @@ void qerror_report_err(Error *err);
>  #define QERR_DEVICE_NO_HOTPLUG \
>      ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
>  
> -#define QERR_DEVICE_NOT_FOUND \
> -    ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
> -
>  #define QERR_FD_NOT_FOUND \
>      ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
>  
> diff --git a/net/net.c b/net/net.c
> index 429012f..212762d 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1109,7 +1109,8 @@ void qmp_netdev_del(const char *id, Error **errp)
>  
>      nc = qemu_find_netdev(id);
>      if (!nc) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, id);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", id);
>          return;
>      }
>  
> @@ -1220,7 +1221,8 @@ void qmp_set_link(const char *name, bool up, Error **errp)
>                                            MAX_QUEUE_NUM);
>  
>      if (queues == 0) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, name);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", name);
>          return;
>      }
>      nc = ncs[0];
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index e1dd367..7bd7d25 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -457,7 +457,8 @@ static BusState *qbus_find(const char *path, Error **errp)
>          pos += len;
>          dev = qbus_find_dev(bus, elem);
>          if (!dev) {
> -            error_set(errp, QERR_DEVICE_NOT_FOUND, elem);
> +            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                      "Device '%s' not found", elem);
>  #if 0 /* conversion from qerror_report() to error_set() broke this: */
>              if (!monitor_cur_is_qmp()) {
>                  qbus_list_dev(bus);
> @@ -793,7 +794,8 @@ void qmp_device_del(const char *id, Error **errp)
>      g_free(path);
>  
>      if (!obj) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, id);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", id);
>          return;
>      }
>  
> diff --git a/qmp.c b/qmp.c
> index 60658b4..14f7536 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -206,7 +206,8 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
>          if (ambiguous) {
>              error_setg(errp, "Path '%s' is ambiguous", path);
>          } else {
> -            error_set(errp, QERR_DEVICE_NOT_FOUND, path);
> +            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                      "Device '%s' not found", path);
>          }
>          return NULL;
>      }
> @@ -236,7 +237,8 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
>  
>      obj = object_resolve_path(path, NULL);
>      if (!obj) {
> -        error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
> +        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", path);
>          goto out;
>      }
>  
> @@ -261,7 +263,8 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)
>  
>      obj = object_resolve_path(path, NULL);
>      if (!obj) {
> -        error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
> +        error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", path);
>          goto out;
>      }
>  
> @@ -518,7 +521,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
>  
>      klass = object_class_by_name(typename);
>      if (klass == NULL) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, typename);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", typename);
>          return NULL;
>      }
>  
> diff --git a/qom/object.c b/qom/object.c
> index 96abd34..62fa44e 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -890,7 +890,8 @@ Object *object_property_get_link(Object *obj, const char *name,
>      if (str && *str) {
>          target = object_resolve_path(str, NULL);
>          if (!target) {
> -            error_set(errp, QERR_DEVICE_NOT_FOUND, str);
> +            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                      "Device '%s' not found", str);
>          }
>      }
>  
> @@ -1170,7 +1171,8 @@ static Object *object_resolve_link(Object *obj, const char *name,
>          if (target || ambiguous) {
>              error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
>          } else {
> -            error_set(errp, QERR_DEVICE_NOT_FOUND, path);
> +            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                      "Device '%s' not found", path);
>          }
>          target = NULL;
>      }
> diff --git a/ui/input.c b/ui/input.c
> index eeeabe8..e96e1ea 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -84,7 +84,8 @@ void qemu_input_handler_bind(QemuInputHandlerState *s,
>  
>      dev = qdev_find_recursive(sysbus_get_default(), device_id);
>      if (dev == NULL) {
> -        error_set(errp, QERR_DEVICE_NOT_FOUND, device_id);
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", device_id);
>          return;
>      }
>  

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

* Re: [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError
  2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
                   ` (10 preceding siblings ...)
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h " Markus Armbruster
@ 2015-06-15 16:03 ` Luiz Capitulino
  2015-06-16 13:08   ` Markus Armbruster
  11 siblings, 1 reply; 45+ messages in thread
From: Luiz Capitulino @ 2015-06-15 16:03 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, mdroth

On Sat, 13 Jun 2015 16:20:47 +0200
Markus Armbruster <armbru@redhat.com> wrote:

> After a bit over a year and many patches, QError is finally ripe.  All
> that's left of qerror.h after this series is a bunch of QERR_ macros.
> Killing them is left for another day.

Excellent!

I did my best to review this series, but unfortunately my review is
a bit weak because I'm not that familiar with some code paths
(like QemuOpts) and I was unable to apply patches starting with patch 04/11.

But it does look good to me:

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> 
> The diffstat looks a bit scary, but that's almost entirely due to
> mechanical changes like PATCH 05.
> 
> This series applies on top of my "[PATCH v2 0/7] qdev: Mostly wean off
> QError".
> 
> Markus Armbruster (11):
>   QemuOpts: Wean off qerror_report_err()
>   vl: Avoid qerror_report() outside QMP command handlers
>   vl: Use error_report() for --display errors
>   qerror: Eliminate QERR_DEVICE_NOT_FOUND
>   qerror: Clean up QERR_ macros to expand into a single string
>   tpm: Avoid qerror_report() outside QMP command handlers
>   qmp: Wean off qerror_report()
>   qerror: Finally unused, clean up
>   qerror: Move #include out of qerror.h
>   Include qapi/qmp/qerror.h exactly where needed
>   Include monitor/monitor.h exactly where needed
> 
>  audio/spiceaudio.c               |   1 +
>  audio/wavcapture.c               |   1 +
>  backends/hostmem.c               |   1 -
>  backends/rng-egd.c               |  11 +--
>  backends/rng-random.c            |   6 +-
>  backends/rng.c                   |   2 +-
>  backends/tpm.c                   |   2 +-
>  balloon.c                        |   5 +-
>  block.c                          |   4 +-
>  block/backup.c                   |   5 +-
>  block/commit.c                   |   3 +-
>  block/curl.c                     |   1 +
>  block/dmg.c                      |   1 +
>  block/io.c                       |   1 +
>  block/iscsi.c                    |   1 +
>  block/mirror.c                   |   9 +--
>  block/qapi.c                     |   6 --
>  block/qcow.c                     |   5 +-
>  block/qcow2-snapshot.c           |   1 +
>  block/qcow2.c                    |   4 +-
>  block/qed.c                      |   4 +-
>  block/quorum.c                   |   5 +-
>  block/raw-posix.c                |   2 +
>  block/snapshot.c                 |   5 +-
>  block/ssh.c                      |   2 +
>  block/stream.c                   |   5 +-
>  block/vhdx-log.c                 |   1 +
>  block/vmdk.c                     |  14 ++--
>  block/vvfat.c                    |   1 +
>  blockdev-nbd.c                   |   6 +-
>  blockdev.c                       |  80 ++++++++++++---------
>  blockjob.c                       |   9 +--
>  cpus.c                           |   9 +--
>  dump.c                           |  13 ++--
>  hmp.c                            |  24 ++++---
>  hw/9pfs/virtio-9p.c              |   1 +
>  hw/char/serial-pci.c             |   1 -
>  hw/char/virtio-serial-bus.c      |   1 +
>  hw/core/nmi.c                    |   2 +-
>  hw/core/platform-bus.c           |   1 -
>  hw/core/qdev-properties-system.c |   3 +-
>  hw/core/qdev-properties.c        |  12 ++--
>  hw/core/qdev.c                   |   9 +--
>  hw/display/g364fb.c              |   1 +
>  hw/display/qxl.c                 |   1 -
>  hw/display/tcx.c                 |   1 +
>  hw/dma/xilinx_axidma.c           |   1 -
>  hw/i386/pc.c                     |   2 +-
>  hw/ide/ahci.c                    |   2 +-
>  hw/intc/openpic.c                |   6 +-
>  hw/misc/ivshmem.c                |   2 +-
>  hw/net/xilinx_axienet.c          |   1 -
>  hw/pci/pci-stub.c                |   3 +-
>  hw/pci/pci.c                     |   1 +
>  hw/pci/pcie.c                    |   1 -
>  hw/pci/shpc.c                    |   1 -
>  hw/ppc/spapr_pci.c               |   8 +--
>  hw/ppc/spapr_vio.c               |   1 -
>  hw/ppc/virtex_ml507.c            |   2 +-
>  hw/s390x/event-facility.c        |   1 -
>  hw/s390x/s390-virtio-bus.c       |   1 -
>  hw/s390x/s390-virtio.c           |   4 +-
>  hw/s390x/virtio-ccw.c            |   2 +-
>  hw/scsi/vhost-scsi.c             |   1 +
>  hw/timer/hpet.c                  |   1 +
>  hw/tpm/tpm_passthrough.c         |   1 +
>  hw/usb/bus.c                     |   1 +
>  hw/usb/ccid-card-emulated.c      |   1 -
>  hw/usb/ccid-card-passthru.c      |   2 +-
>  hw/usb/dev-network.c             |   2 +-
>  hw/usb/dev-serial.c              |   2 +-
>  hw/usb/dev-smartcard-reader.c    |   1 -
>  hw/usb/dev-storage.c             |   1 +
>  hw/usb/hcd-ehci.h                |   1 -
>  hw/usb/host-libusb.c             |   1 +
>  hw/usb/redirect.c                |   9 +--
>  hw/virtio/virtio-rng.c           |   1 -
>  include/block/block_int.h        |   2 -
>  include/monitor/monitor.h        |   9 +--
>  include/monitor/qdev.h           |   5 +-
>  include/net/net.h                |   2 +-
>  include/qapi/qmp/qerror.h        |  85 +++++++++-------------
>  include/qapi/qmp/qobject.h       |   1 -
>  include/qemu/option.h            |   5 +-
>  include/qemu/sockets.h           |   1 -
>  include/sysemu/balloon.h         |   1 -
>  include/ui/console.h             |   4 +-
>  include/ui/qemu-spice.h          |   2 -
>  migration/migration.c            |  38 +++++-----
>  migration/qemu-file-buf.c        |   1 +
>  migration/qemu-file.c            |   1 +
>  migration/rdma.c                 |   1 +
>  migration/savevm.c               |   4 +-
>  monitor.c                        | 104 +++++++++++----------------
>  net/l2tpv3.c                     |   1 -
>  net/net.c                        |  41 +++++------
>  net/slirp.c                      |   1 +
>  numa.c                           |   1 -
>  qapi/opts-visitor.c              |  24 +++----
>  qapi/qapi-visit-core.c           |  28 ++++----
>  qapi/qmp-dispatch.c              |  12 ++--
>  qapi/qmp-input-visitor.c         |  28 ++++----
>  qapi/qmp-output-visitor.c        |   1 -
>  qapi/string-input-visitor.c      |  24 +++----
>  qapi/string-output-visitor.c     |   1 -
>  qdev-monitor.c                   |  37 +++++-----
>  qemu-char.c                      |   1 +
>  qemu-img.c                       |   6 +-
>  qemu-io-cmds.c                   |   1 +
>  qemu-io.c                        |   4 +-
>  qemu-nbd.c                       |   4 +-
>  qga/commands-posix.c             |  40 +++++------
>  qga/commands-win32.c             |  66 ++++++++---------
>  qga/main.c                       |   4 +-
>  qmp-commands.hx                  |   4 +-
>  qmp.c                            |  97 ++++++++++---------------
>  qobject/Makefile.objs            |   1 -
>  qobject/json-parser.c            |   1 -
>  qobject/qerror.c                 | 148 ---------------------------------------
>  qobject/qjson.c                  |   3 -
>  qom/object.c                     |  18 ++---
>  scripts/qapi-commands.py         |  42 ++---------
>  slirp/misc.c                     |   1 +
>  stubs/Makefile.objs              |   1 -
>  stubs/arch-query-cpu-def.c       |   2 +-
>  stubs/dump.c                     |   1 -
>  stubs/mon-is-qmp.c               |   2 +
>  stubs/mon-set-error.c            |   8 ---
>  target-arm/cpu.c                 |   1 -
>  target-i386/cpu.c                |  20 +++---
>  target-i386/kvm.c                |   1 -
>  target-s390x/kvm.c               |   1 -
>  tests/test-opts-visitor.c        |   3 +-
>  tests/test-qemu-opts.c           |   2 +-
>  tpm.c                            |  12 ++--
>  ui/input-legacy.c                |   1 -
>  ui/input.c                       |   4 +-
>  ui/spice-core.c                  |   1 +
>  ui/spice-display.c               |   1 -
>  ui/vnc.c                         |  10 +--
>  util/osdep.c                     |   1 +
>  util/qemu-config.c               |   1 -
>  util/qemu-error.c                |   5 +-
>  util/qemu-option.c               |  47 ++++++++-----
>  vl.c                             | 143 +++++++++++++++++++++----------------
>  145 files changed, 676 insertions(+), 845 deletions(-)
>  delete mode 100644 qobject/qerror.c
>  delete mode 100644 stubs/mon-set-error.c
> 

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

* Re: [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
  2015-06-15 15:12   ` Stefan Hajnoczi
@ 2015-06-15 16:09   ` Eric Blake
  2015-06-16 12:45     ` Markus Armbruster
  1 sibling, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 16:09 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> These macros expand into error class enumeration constant, comma,
> string.  Unclean.  Has been that way since commit 13f59ae.
> 
> The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
> commit.
> 
> Clean up as follows:
> 
> * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
>   delete it from the QERR_ macro.  No change after preprocessing.
> 
> * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
>   error_setg(...).  Again, no change after preprocessing.

Were these conversions done via coccinelle? If so, it would be nice to
mention the script used in the commit message.  But that doesn't affect
the correctness of the patch itself.

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

>  util/qemu-option.c               | 22 ++++++++------
>  53 files changed, 362 insertions(+), 358 deletions(-)

Close to 1:1 lineup; difference is due to altered line wraps in a few spots.

> 
> diff --git a/backends/rng-egd.c b/backends/rng-egd.c
> index 849bd7a..225221e 100644
> --- a/backends/rng-egd.c
> +++ b/backends/rng-egd.c
> @@ -140,8 +140,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
>      RngEgd *s = RNG_EGD(b);
>  
>      if (s->chr_name == NULL) {
> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
> -                  "chardev", "a valid character device");
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "chardev",
> +                   "a valid character device");

Interesting line rewrap.

> +++ b/backends/rng-random.c
> @@ -74,8 +74,8 @@ static void rng_random_opened(RngBackend *b, Error **errp)
>      RndRandom *s = RNG_RANDOM(b);
>  
>      if (s->filename == NULL) {
> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
> -                  "filename", "a valid filename");
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "filename",
> +                   "a valid filename");

and again


> +++ b/block/quorum.c
> @@ -800,8 +800,8 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp)
>  {
>  
>      if (threshold < 1) {
> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
> -                  "vote-threshold", "value >= 1");
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "vote-threshold",
> +                   "value >= 1");

looks like there are several of them. They don't hurt, so I'll quit
pointing them out.


>  
>  #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
> -    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
> +    "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"

Still a long line; worth wrapping with another \ mid-string?

> +++ b/tpm.c
> @@ -140,20 +140,22 @@ static int configure_tpm(QemuOpts *opts)
>  
>      id = qemu_opts_id(opts);
>      if (id == NULL) {
> -        qerror_report(QERR_MISSING_PARAMETER, "id");
> +        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
>          return 1;

Not quite the same s/error_set/error_setg/ change as everywhere else,
but still correct.

There may be additional merge conflicts depending on timing of getting
this in, but it is mechanical resolution, and the sooner we get this in,
the better.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err()
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
  2015-06-14  2:57   ` Eric Blake
@ 2015-06-15 16:19   ` Stefan Hajnoczi
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Hajnoczi @ 2015-06-15 16:19 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: mdroth, kwolf, qemu-devel, lcapitulino

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

On Sat, Jun 13, 2015 at 04:20:48PM +0200, Markus Armbruster wrote:
> qerror_report_err() is a transitional interface to help with
> converting existing monitor commands to QMP.  It should not be used
> elsewhere.
> 
> The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
> used in QMP context?  If not, we can simply replace
> qerror_report_err() by error_report_err().
> 
> The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are
> clearly not in QMP context.
> 
> The uses in vl.c aren't either, because the only QMP command handlers
> there are qmp_query_status() and qmp_query_machines(), and they don't
> call it.
> 
> Remaining uses:
> 
> * drive_def(): Command line -drive and such, HMP drive_add and pci_add
> 
> * hmp_chardev_add(): HMP chardev-add
> 
> * monitor_parse_command(): HMP core
> 
> * tmp_config_parse(): Command line -tpmdev
> 
> * net_host_device_add(): HMP host_net_add
> 
> * net_client_parse(): Command line -net and -netdev
> 
> * qemu_global_option(): Command line -global
> 
> * vnc_parse_func(): Command line -display, -vnc, default display, HMP
>   change, QMP change.  Bummer.
> 
> * qemu_pci_hot_add_nic(): HMP pci_add
> 
> * usb_net_init(): Command line -usbdevice, HMP usb_add
> 
> Propoagate errors through qemu_opts_parse().  Create a convenience
> function qemu_opts_parse_noisily() that passes errors to
> error_report_err().  Switch all non-QMP users outside tests to it.
> 
> That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
> touching it anyway, rename it to vnc_parse().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  blockdev.c                |   2 +-
>  hmp.c                     |   2 +-
>  hw/usb/dev-network.c      |   2 +-
>  include/qemu/option.h     |   5 ++-
>  include/ui/console.h      |   2 +-
>  monitor.c                 |   2 +-
>  net/net.c                 |   5 ++-
>  qdev-monitor.c            |   2 +-
>  qemu-img.c                |   3 +-
>  qemu-io.c                 |   2 +-
>  qemu-nbd.c                |   3 +-
>  qmp.c                     |   2 +-
>  tests/test-opts-visitor.c |   3 +-
>  tests/test-qemu-opts.c    |   2 +-
>  tpm.c                     |   2 +-
>  ui/vnc.c                  |   4 +-
>  util/qemu-option.c        |  25 ++++++++---
>  vl.c                      | 103 +++++++++++++++++++++++++++++-----------------
>  18 files changed, 109 insertions(+), 62 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-15 15:18   ` Luiz Capitulino
@ 2015-06-15 20:33     ` Eric Blake
  2015-06-16 12:28       ` Markus Armbruster
  2015-06-15 20:41     ` Peter Maydell
  1 sibling, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 20:33 UTC (permalink / raw)
  To: Luiz Capitulino, Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, mdroth

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

On 06/15/2015 09:18 AM, Luiz Capitulino wrote:
> On Sat, 13 Jun 2015 16:20:51 +0200
> Markus Armbruster <armbru@redhat.com> wrote:
> 
>> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
>> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
>> Fortunately, there's just one such macro left.  Eliminate it with this
>> coccinelle semantic patch:
>>
>>     @@
>>     expression EP, E;
>>     @@
>>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
> 
> This is a bit minor, but I think I'd have created a new function instead,
> say error_set_enodev(). This avoids all the duplication. But I'm not asking
> you to change, as the patch is good and this can be done in the future if
> we so want.

In fact, in both patch 4 and 5, I thought a similar thing - the
remaining QERR_ macros that contain a % embedded in them are a bit
unusual (when reading error_setg(), you have to go look up the QERR_
macro to see how many arguments you should really be passing).  If I
understand correctly, one of the reasons we went with QERR_ macros
embedding % was to ensure consistent error messages among multiple call
sites, in part if we want to enable error message translations (but
that's a bigger project anyways, which you have argued that we may not
even want).

Having helper functions for the more common error messages can both
reduce confusion (no hidden %) and duplication (callers don't need to
repeat the same string).  But I likewise agree with Luiz that it can be
deferred to the future if desired.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers Markus Armbruster
@ 2015-06-15 20:37   ` Eric Blake
  2015-06-16 13:07     ` Markus Armbruster
  0 siblings, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 20:37 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> qerror_report() is a transitional interface to help with converting
> existing monitor commands to QMP.  It should not be used elsewhere.
> Replace by error_report().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  tpm.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/tpm.c b/tpm.c
> index 99a9895..224e65e 100644
> --- a/tpm.c
> +++ b/tpm.c
> @@ -140,23 +140,21 @@ static int configure_tpm(QemuOpts *opts)
>  
>      id = qemu_opts_id(opts);
>      if (id == NULL) {
> -        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
> +        error_report(QERR_MISSING_PARAMETER, "id");

Ah, this fixes a hunk difference I pointed out in 5/11.  If you need to
rebase, I'd consider rearranging to put this patch first, so that the
mechanical 5/11 is even more mechanical (limited to just error_setg
conversion).  But that's not enough reason in itself for a respin, so:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-15 15:18   ` Luiz Capitulino
  2015-06-15 20:33     ` Eric Blake
@ 2015-06-15 20:41     ` Peter Maydell
  2015-06-16 12:28       ` Markus Armbruster
  1 sibling, 1 reply; 45+ messages in thread
From: Peter Maydell @ 2015-06-15 20:41 UTC (permalink / raw)
  To: Luiz Capitulino
  Cc: Kevin Wolf, Michael Roth, Markus Armbruster, Stefan Hajnoczi,
	QEMU Developers

On 15 June 2015 at 16:18, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> On Sat, 13 Jun 2015 16:20:51 +0200
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
>> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
>> Fortunately, there's just one such macro left.  Eliminate it with this
>> coccinelle semantic patch:
>>
>>     @@
>>     expression EP, E;
>>     @@
>>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
>
> This is a bit minor, but I think I'd have created a new function instead,
> say error_set_enodev(). This avoids all the duplication. But I'm not asking
> you to change, as the patch is good and this can be done in the future if
> we so want.

The thing about that kind of generic set-an-error function is that
it encourages people to use it rather than providing an error message
that's more specific and helpful for the particular situation. That
might not be a problem in this patch (I haven't read it), but I mention
it because I have a patch onlist elsewhere which undoes a bit of
"generic error based on an errno" in favour of being more specific
about why something didn't work.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report()
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report() Markus Armbruster
  2015-06-15 15:08   ` Stefan Hajnoczi
@ 2015-06-15 20:56   ` Eric Blake
  2015-06-16 12:54     ` Markus Armbruster
  1 sibling, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 20:56 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> The traditional QMP command handler interface
> 
>     int qmp_FOO(Monitor *mon, const QDict *params, QObject **ret_data);
> 
> doesn't provide for returning an Error object.  Instead, the handler
> is expected to stash it in the monitor with qerror_report().
> 
> When we rebased QMP on top of QAPI, we didn't change this interface.
> Instead, commit 776574d introduced "middle mode" as a temporary aid
> for converting existing QMP commands to QAPI one by one.  More than
> three years later, we're still using it.
> 
> Middle mode has two effects:

Are these effects documented anywhere, as in docs/qapi-code-gen.txt?
Should they be, or are we better off trying to get rid of middle mode?

> 
> * Instead of the native input marshallers
> 
>       static void qmp_marshal_input_FOO(QDict *, QObject **, Error **)
> 
>   it generates input marshallers conforming to the traditional QMP
>   command handler interface.
> 
> * It suppresses generation of code to register them with
>   qmp_register_command()
> 
>   This permits giving them internal linkage.
> 
> As long as we need qmp-commands.hx, we can't use the registry behind
> qmp_register_command(), so the latter has to stay for now.

Is there a qapi marking we can add for this effect, similar to
'gen':false?  For that matter...

> 
> The former has to go to get rid of qerror_report().  Changing all QMP
> commands to fit the QAPI mold in one go was impractical back when we
> started, but by now there are just a few stragglers left:
> do_qmp_capabilities(), qmp_qom_set(), qmp_qom_get(), qmp_object_add(),
> qmp_netdev_add(), do_device_add().

...many of these are already using 'gen':false!

> 
> Switch middle mode to generate native input marshallers, and adapt the
> stragglers.  Simplifies both the monitor code and the stragglers.
> 
> Rename do_qmp_capabilities() to qmp_capabilities(), and
> do_device_add() to qmp_device_add, because that's how QMP command
> handlers are named today.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hmp.c                     |  5 ++++-
>  include/monitor/monitor.h |  7 +++---
>  include/monitor/qdev.h    |  3 ++-
>  include/net/net.h         |  2 +-
>  monitor.c                 | 24 ++++++---------------
>  net/net.c                 | 16 ++++++--------
>  qdev-monitor.c            | 15 ++++++-------
>  qmp-commands.hx           |  4 ++--
>  qmp.c                     | 55 +++++++++++------------------------------------
>  scripts/qapi-commands.py  | 41 ++++++-----------------------------
>  util/qemu-error.c         |  4 ++--
>  11 files changed, 50 insertions(+), 126 deletions(-)

Relatively nice diffstat.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up Markus Armbruster
@ 2015-06-15 21:05   ` Eric Blake
  0 siblings, 0 replies; 45+ messages in thread
From: Eric Blake @ 2015-06-15 21:05 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> Remove it except for two things in qerror.h:
> 
> * Two #include to be cleaned up separately to avoid cluttering this
>   patch.
> 
> * The QERR_ macros.  Mark as obsolete.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  block/qapi.c               |   6 --
>  include/monitor/monitor.h  |   1 -
>  include/qapi/qmp/qerror.h  |  19 +-----
>  include/qapi/qmp/qobject.h |   1 -
>  monitor.c                  |  13 ----
>  qobject/Makefile.objs      |   1 -
>  qobject/qerror.c           | 148 ---------------------------------------------
>  qobject/qjson.c            |   3 -
>  stubs/Makefile.objs        |   1 -
>  stubs/mon-is-qmp.c         |   2 +
>  stubs/mon-set-error.c      |   8 ---
>  11 files changed, 4 insertions(+), 199 deletions(-)
>  delete mode 100644 qobject/qerror.c
>  delete mode 100644 stubs/mon-set-error.c
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h Markus Armbruster
  2015-06-15 15:08   ` Stefan Hajnoczi
@ 2015-06-15 21:37   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Eric Blake @ 2015-06-15 21:37 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

>  57 files changed, 59 insertions(+), 3 deletions(-)
> 

> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index f8182c7..842b27a 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -12,9 +12,6 @@
>  #ifndef QERROR_H
>  #define QERROR_H
>  
> -#include "qapi/qmp/qstring.h"
> -#include "qemu/error-report.h"
> -

The real meat of the change; the rest is adding these lines into .c
files where compilation broke otherwise :)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
  2015-06-15 15:09   ` Stefan Hajnoczi
@ 2015-06-15 21:38   ` Eric Blake
  2015-06-16 12:58     ` Markus Armbruster
  1 sibling, 1 reply; 45+ messages in thread
From: Eric Blake @ 2015-06-15 21:38 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> In particular, don't include it into headers.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

>  46 files changed, 25 insertions(+), 21 deletions(-)

Assuming this was done by deleting from headers, then adding it into .c
files that no longer compiled.  Were there any .c files where it was
unused, and if so, how did you go about finding them?  By grepping for
QERR_?

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h exactly where needed
  2015-06-13 14:20 ` [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h " Markus Armbruster
  2015-06-15 15:09   ` Stefan Hajnoczi
@ 2015-06-15 21:40   ` Eric Blake
  1 sibling, 0 replies; 45+ messages in thread
From: Eric Blake @ 2015-06-15 21:40 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, mdroth, stefanha, lcapitulino

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

On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> In particular, don't include it into headers.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

>  29 files changed, 4 insertions(+), 29 deletions(-)

Again, it might be nice to call out in the commit message how you
determined which files could drop it (was it via blanket deletion, then
re-add if compilation failed?).  But doesn't impact the patch being a
nice cleanup, so:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err()
  2015-06-14  2:57   ` Eric Blake
@ 2015-06-16 10:58     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 10:58 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> qerror_report_err() is a transitional interface to help with
>> converting existing monitor commands to QMP.  It should not be used
>> elsewhere.
>> 
>> The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
>> used in QMP context?  If not, we can simply replace
>> qerror_report_err() by error_report_err().
>> 
>
>> 
>> Propoagate errors through qemu_opts_parse().  Create a convenience
>
> s/Propoagate/Propagate/

Fixing...

>> function qemu_opts_parse_noisily() that passes errors to
>> error_report_err().  Switch all non-QMP users outside tests to it.
>> 
>> That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
>> touching it anyway, rename it to vnc_parse().
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers
  2015-06-14  3:09   ` Eric Blake
@ 2015-06-16 12:00     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:00 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> qerror_report() is a transitional interface to help with converting
>> existing monitor commands to QMP.  It should not be used elsewhere.
>> Replace by error_report() in initial startup helpers parse_sandbox()
>> and parse_add_fd().
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  vl.c | 23 +++++++++--------------
>>  1 file changed, 9 insertions(+), 14 deletions(-)
>> 
>
>>  #else
>> -        qerror_report(ERROR_CLASS_GENERIC_ERROR,
>> -                      "sandboxing request but seccomp is not compiled into this build");
>> +        error_report("sandboxing request but seccomp is not compiled "
>> +                     "into this build");
>
> Pre-existing, but s/request/requested/ would sound better while touching
> this.

The full error message is

    qemu-kvm-x86_64: -sandbox on: sandboxing request but seccomp is not compiled into this build

I think

    qemu-kvm-x86_64: -sandbox on: seccomp is not compiled into this build

would do just fine.

I guess I'd happily squash that into a shorter patch, but this one is
big enough for me to prefer a separate patch.

> Either way,
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-15 13:59   ` Eric Blake
@ 2015-06-16 12:26     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:26 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
>> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
>> Fortunately, there's just one such macro left.  Eliminate it with this
>> coccinelle semantic patch:
>> 
>>     @@
>>     expression EP, E;
>>     @@
>>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  backends/rng-egd.c        |  3 ++-
>>  blockdev-nbd.c            |  3 ++-
>>  blockdev.c                | 33 ++++++++++++++++++++++-----------
>>  hmp.c                     |  6 ++++--
>>  include/qapi/qmp/qerror.h |  3 ---
>>  net/net.c                 |  6 ++++--
>>  qdev-monitor.c            |  6 ++++--
>>  qmp.c                     | 12 ++++++++----
>>  qom/object.c              |  6 ++++--
>>  ui/input.c                |  3 ++-
>>  10 files changed, 52 insertions(+), 29 deletions(-)
>
> Plain transformation would be closer to a 1:1 insertion/deletion count.
>  The larger insertion count is due to reflowing long lines after the
> transformation.  Does coccinelle do that for you, or do you have to
> touch things up manually?

It does, and most of the time it's a relief.

>                            But I'm okay with the result.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-15 20:41     ` Peter Maydell
@ 2015-06-16 12:28       ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:28 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Kevin Wolf, QEMU Developers, Michael Roth, Stefan Hajnoczi,
	Luiz Capitulino

Peter Maydell <peter.maydell@linaro.org> writes:

> On 15 June 2015 at 16:18, Luiz Capitulino <lcapitulino@redhat.com> wrote:
>> On Sat, 13 Jun 2015 16:20:51 +0200
>> Markus Armbruster <armbru@redhat.com> wrote:
>>
>>> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
>>> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
>>> Fortunately, there's just one such macro left.  Eliminate it with this
>>> coccinelle semantic patch:
>>>
>>>     @@
>>>     expression EP, E;
>>>     @@
>>>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>>>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
>>
>> This is a bit minor, but I think I'd have created a new function instead,
>> say error_set_enodev(). This avoids all the duplication. But I'm not asking
>> you to change, as the patch is good and this can be done in the future if
>> we so want.
>
> The thing about that kind of generic set-an-error function is that
> it encourages people to use it rather than providing an error message
> that's more specific and helpful for the particular situation. That
> might not be a problem in this patch (I haven't read it), but I mention
> it because I have a patch onlist elsewhere which undoes a bit of
> "generic error based on an errno" in favour of being more specific
> about why something didn't work.

Observation seconded.

When creating bad error messages is easier or looks cleaner than
creating good ones, you'll invariably end up with tons of bad ones.

Back when we still pursued the "rich" error objects mistake, we had
"easier" on steroids: for a new error, you had to create a macro, maybe
add an error class, edit a table, and then use the macro.  Hard to blame
anyone for "sod it, I'll just reuse an existing one."

Using a common error helper when it doesn't quite fit is a case of
"looks cleaner".  It's only (marginally) cleaner when it fits.  But
having one for the cases where it fits creates temptation for cases
where it doesn't quite fit.

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

* Re: [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND
  2015-06-15 20:33     ` Eric Blake
@ 2015-06-16 12:28       ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:28 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, mdroth, qemu-devel, stefanha, Luiz Capitulino

Eric Blake <eblake@redhat.com> writes:

> On 06/15/2015 09:18 AM, Luiz Capitulino wrote:
>> On Sat, 13 Jun 2015 16:20:51 +0200
>> Markus Armbruster <armbru@redhat.com> wrote:
>> 
>>> Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
>>> in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
>>> Fortunately, there's just one such macro left.  Eliminate it with this
>>> coccinelle semantic patch:
>>>
>>>     @@
>>>     expression EP, E;
>>>     @@
>>>     -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
>>>     +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)
>> 
>> This is a bit minor, but I think I'd have created a new function instead,
>> say error_set_enodev(). This avoids all the duplication. But I'm not asking
>> you to change, as the patch is good and this can be done in the future if
>> we so want.
>
> In fact, in both patch 4 and 5, I thought a similar thing - the
> remaining QERR_ macros that contain a % embedded in them are a bit
> unusual (when reading error_setg(), you have to go look up the QERR_
> macro to see how many arguments you should really be passing).  If I
> understand correctly, one of the reasons we went with QERR_ macros
> embedding % was to ensure consistent error messages among multiple call
> sites, in part if we want to enable error message translations (but
> that's a bigger project anyways, which you have argued that we may not
> even want).
>
> Having helper functions for the more common error messages can both
> reduce confusion (no hidden %) and duplication (callers don't need to
> repeat the same string).  But I likewise agree with Luiz that it can be
> deferred to the future if desired.

My preferred solution is to have a helper function for the *action*
rather than just its error.  Not always practical.

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

* Re: [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string
  2015-06-15 16:09   ` Eric Blake
@ 2015-06-16 12:45     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:45 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> These macros expand into error class enumeration constant, comma,
>> string.  Unclean.  Has been that way since commit 13f59ae.
>> 
>> The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
>> commit.
>> 
>> Clean up as follows:
>> 
>> * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
>>   delete it from the QERR_ macro.  No change after preprocessing.
>> 
>> * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
>>   error_setg(...).  Again, no change after preprocessing.
>
> Were these conversions done via coccinelle? If so, it would be nice to
> mention the script used in the commit message.  But that doesn't affect
> the correctness of the patch itself.

The semantic patch I used is almost 200 repetitive lines, because I
derived it from qerror.h with regexp-magic.  I doubt including it is
useful.

>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
>>  util/qemu-option.c               | 22 ++++++++------
>>  53 files changed, 362 insertions(+), 358 deletions(-)
>
> Close to 1:1 lineup; difference is due to altered line wraps in a few spots.
>
>> 
>> diff --git a/backends/rng-egd.c b/backends/rng-egd.c
>> index 849bd7a..225221e 100644
>> --- a/backends/rng-egd.c
>> +++ b/backends/rng-egd.c
>> @@ -140,8 +140,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
>>      RngEgd *s = RNG_EGD(b);
>>  
>>      if (s->chr_name == NULL) {
>> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
>> -                  "chardev", "a valid character device");
>> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "chardev",
>> +                   "a valid character device");
>
> Interesting line rewrap.

Coccinelle.

>> +++ b/backends/rng-random.c
>> @@ -74,8 +74,8 @@ static void rng_random_opened(RngBackend *b, Error **errp)
>>      RndRandom *s = RNG_RANDOM(b);
>>  
>>      if (s->filename == NULL) {
>> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
>> -                  "filename", "a valid filename");
>> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "filename",
>> +                   "a valid filename");
>
> and again
>
>
>> +++ b/block/quorum.c
>> @@ -800,8 +800,8 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp)
>>  {
>>  
>>      if (threshold < 1) {
>> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
>> -                  "vote-threshold", "value >= 1");
>> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "vote-threshold",
>> +                   "value >= 1");
>
> looks like there are several of them. They don't hurt, so I'll quit
> pointing them out.

I'll try to avoid uncalled-for rewraps in v2.

>>  #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
>> - ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %"
>> PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
>> + "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64
>> ", maximum: %" PRId64 ")"
>
> Still a long line; worth wrapping with another \ mid-string?

Normally yes, but these macros should die, hopefully soon.

>> +++ b/tpm.c
>> @@ -140,20 +140,22 @@ static int configure_tpm(QemuOpts *opts)
>>  
>>      id = qemu_opts_id(opts);
>>      if (id == NULL) {
>> -        qerror_report(QERR_MISSING_PARAMETER, "id");
>> +        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
>>          return 1;
>
> Not quite the same s/error_set/error_setg/ change as everywhere else,
> but still correct.
>
> There may be additional merge conflicts depending on timing of getting
> this in, but it is mechanical resolution, and the sooner we get this in,
> the better.

Yup.

> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report()
  2015-06-15 20:56   ` Eric Blake
@ 2015-06-16 12:54     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:54 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> The traditional QMP command handler interface
>> 
>>     int qmp_FOO(Monitor *mon, const QDict *params, QObject **ret_data);
>> 
>> doesn't provide for returning an Error object.  Instead, the handler
>> is expected to stash it in the monitor with qerror_report().
>> 
>> When we rebased QMP on top of QAPI, we didn't change this interface.
>> Instead, commit 776574d introduced "middle mode" as a temporary aid
>> for converting existing QMP commands to QAPI one by one.  More than
>> three years later, we're still using it.
>> 
>> Middle mode has two effects:
>
> Are these effects documented anywhere, as in docs/qapi-code-gen.txt?
> Should they be, or are we better off trying to get rid of middle mode?

The latter.

>> * Instead of the native input marshallers
>> 
>>       static void qmp_marshal_input_FOO(QDict *, QObject **, Error **)
>> 
>>   it generates input marshallers conforming to the traditional QMP
>>   command handler interface.
>> 
>> * It suppresses generation of code to register them with
>>   qmp_register_command()
>> 
>>   This permits giving them internal linkage.
>> 
>> As long as we need qmp-commands.hx, we can't use the registry behind
>> qmp_register_command(), so the latter has to stay for now.
>
> Is there a qapi marking we can add for this effect, similar to
> 'gen':false?  For that matter...
>
>> 
>> The former has to go to get rid of qerror_report().  Changing all QMP
>> commands to fit the QAPI mold in one go was impractical back when we
>> started, but by now there are just a few stragglers left:
>> do_qmp_capabilities(), qmp_qom_set(), qmp_qom_get(), qmp_object_add(),
>> qmp_netdev_add(), do_device_add().
>
> ...many of these are already using 'gen':false!

Using qmp_register_command() for some commands and qmp-commands.hx for
others doesn't sound appealing.

The best way forward is getting rid of qmp-commands.hx.  Not in this
development cycle, though.

>> Switch middle mode to generate native input marshallers, and adapt the
>> stragglers.  Simplifies both the monitor code and the stragglers.
>> 
>> Rename do_qmp_capabilities() to qmp_capabilities(), and
>> do_device_add() to qmp_device_add, because that's how QMP command
>> handlers are named today.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  hmp.c                     |  5 ++++-
>>  include/monitor/monitor.h |  7 +++---
>>  include/monitor/qdev.h    |  3 ++-
>>  include/net/net.h         |  2 +-
>>  monitor.c                 | 24 ++++++---------------
>>  net/net.c                 | 16 ++++++--------
>>  qdev-monitor.c            | 15 ++++++-------
>>  qmp-commands.hx           |  4 ++--
>>  qmp.c | 55 +++++++++++------------------------------------
>>  scripts/qapi-commands.py  | 41 ++++++-----------------------------
>>  util/qemu-error.c         |  4 ++--
>>  11 files changed, 50 insertions(+), 126 deletions(-)
>
> Relatively nice diffstat.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed
  2015-06-15 21:38   ` Eric Blake
@ 2015-06-16 12:58     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 12:58 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> In particular, don't include it into headers.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
>>  46 files changed, 25 insertions(+), 21 deletions(-)
>
> Assuming this was done by deleting from headers, then adding it into .c
> files that no longer compiled.  Were there any .c files where it was
> unused, and if so, how did you go about finding them?  By grepping for
> QERR_?

Yes, I grepped for QERR_ in addition to compile.  Compile can only find
missing includes, grep also finds the superfluous ones, and covers code
I can't easily compile locally.

> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers
  2015-06-15 20:37   ` Eric Blake
@ 2015-06-16 13:07     ` Markus Armbruster
  0 siblings, 0 replies; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 13:07 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, lcapitulino, qemu-devel, stefanha, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> qerror_report() is a transitional interface to help with converting
>> existing monitor commands to QMP.  It should not be used elsewhere.
>> Replace by error_report().
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  tpm.c | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>> 
>> diff --git a/tpm.c b/tpm.c
>> index 99a9895..224e65e 100644
>> --- a/tpm.c
>> +++ b/tpm.c
>> @@ -140,23 +140,21 @@ static int configure_tpm(QemuOpts *opts)
>>  
>>      id = qemu_opts_id(opts);
>>      if (id == NULL) {
>> -        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
>> +        error_report(QERR_MISSING_PARAMETER, "id");
>
> Ah, this fixes a hunk difference I pointed out in 5/11.  If you need to
> rebase, I'd consider rearranging to put this patch first, so that the
> mechanical 5/11 is even more mechanical (limited to just error_setg
> conversion).

While that would make PATCH 05 a bit more mechanical, this one would
become quite a bit uglier, because I can't directly pass
QERR_MISSING_PARAMETER to any of the error_report() functions.

I'd either have to create an Error to pass to error_report_err(), or
drop the unwanted error class by wrapping parenthesis around
QERR_MISSING_PARAMETER to turn its comma into a comma operator.  Ugh.

>               But that's not enough reason in itself for a respin, so:
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError
  2015-06-15 16:03 ` [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Luiz Capitulino
@ 2015-06-16 13:08   ` Markus Armbruster
  2015-06-16 13:35     ` Luiz Capitulino
  0 siblings, 1 reply; 45+ messages in thread
From: Markus Armbruster @ 2015-06-16 13:08 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: kwolf, qemu-devel, stefanha, mdroth

Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Sat, 13 Jun 2015 16:20:47 +0200
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> After a bit over a year and many patches, QError is finally ripe.  All
>> that's left of qerror.h after this series is a bunch of QERR_ macros.
>> Killing them is left for another day.
>
> Excellent!
>
> I did my best to review this series, but unfortunately my review is
> a bit weak because I'm not that familiar with some code paths
> (like QemuOpts) and I was unable to apply patches starting with patch 04/11.

Did you apply on top of my "[PATCH v2 0/7] qdev: Mostly wean off
QError"?

> But it does look good to me:
>
> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError
  2015-06-16 13:08   ` Markus Armbruster
@ 2015-06-16 13:35     ` Luiz Capitulino
  0 siblings, 0 replies; 45+ messages in thread
From: Luiz Capitulino @ 2015-06-16 13:35 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, mdroth

On Tue, 16 Jun 2015 15:08:41 +0200
Markus Armbruster <armbru@redhat.com> wrote:

> Luiz Capitulino <lcapitulino@redhat.com> writes:
> 
> > On Sat, 13 Jun 2015 16:20:47 +0200
> > Markus Armbruster <armbru@redhat.com> wrote:
> >
> >> After a bit over a year and many patches, QError is finally ripe.  All
> >> that's left of qerror.h after this series is a bunch of QERR_ macros.
> >> Killing them is left for another day.
> >
> > Excellent!
> >
> > I did my best to review this series, but unfortunately my review is
> > a bit weak because I'm not that familiar with some code paths
> > (like QemuOpts) and I was unable to apply patches starting with patch 04/11.
> 
> Did you apply on top of my "[PATCH v2 0/7] qdev: Mostly wean off
> QError"?

No, I assumed it was already merged.

> > But it does look good to me:
> >
> > Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
> 
> Thanks!
> 

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

end of thread, other threads:[~2015-06-16 13:35 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13 14:20 [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 01/11] QemuOpts: Wean off qerror_report_err() Markus Armbruster
2015-06-14  2:57   ` Eric Blake
2015-06-16 10:58     ` Markus Armbruster
2015-06-15 16:19   ` Stefan Hajnoczi
2015-06-13 14:20 ` [Qemu-devel] [PATCH 02/11] vl: Avoid qerror_report() outside QMP command handlers Markus Armbruster
2015-06-14  3:09   ` Eric Blake
2015-06-16 12:00     ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 03/11] vl: Use error_report() for --display errors Markus Armbruster
2015-06-15 12:49   ` Eric Blake
2015-06-13 14:20 ` [Qemu-devel] [PATCH 04/11] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
2015-06-15 13:59   ` Eric Blake
2015-06-16 12:26     ` Markus Armbruster
2015-06-15 15:13   ` Stefan Hajnoczi
2015-06-15 15:18   ` Luiz Capitulino
2015-06-15 20:33     ` Eric Blake
2015-06-16 12:28       ` Markus Armbruster
2015-06-15 20:41     ` Peter Maydell
2015-06-16 12:28       ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 05/11] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
2015-06-15 15:12   ` Stefan Hajnoczi
2015-06-15 16:09   ` Eric Blake
2015-06-16 12:45     ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 06/11] tpm: Avoid qerror_report() outside QMP command handlers Markus Armbruster
2015-06-15 20:37   ` Eric Blake
2015-06-16 13:07     ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 07/11] qmp: Wean off qerror_report() Markus Armbruster
2015-06-15 15:08   ` Stefan Hajnoczi
2015-06-15 20:56   ` Eric Blake
2015-06-16 12:54     ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 08/11] qerror: Finally unused, clean up Markus Armbruster
2015-06-15 21:05   ` Eric Blake
2015-06-13 14:20 ` [Qemu-devel] [PATCH 09/11] qerror: Move #include out of qerror.h Markus Armbruster
2015-06-15 15:08   ` Stefan Hajnoczi
2015-06-15 21:37   ` Eric Blake
2015-06-13 14:20 ` [Qemu-devel] [PATCH 10/11] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
2015-06-15 15:09   ` Stefan Hajnoczi
2015-06-15 21:38   ` Eric Blake
2015-06-16 12:58     ` Markus Armbruster
2015-06-13 14:20 ` [Qemu-devel] [PATCH 11/11] Include monitor/monitor.h " Markus Armbruster
2015-06-15 15:09   ` Stefan Hajnoczi
2015-06-15 21:40   ` Eric Blake
2015-06-15 16:03 ` [Qemu-devel] [PATCH 00/11] Sprint to the finish: purge QError Luiz Capitulino
2015-06-16 13:08   ` Markus Armbruster
2015-06-16 13:35     ` Luiz Capitulino

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.