qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set()
@ 2012-07-25 20:50 Luiz Capitulino
  2012-07-25 20:50 ` [Qemu-devel] [PATCH 01/14] monitor: drop unused monitor debug code Luiz Capitulino
                   ` (15 more replies)
  0 siblings, 16 replies; 37+ messages in thread
From: Luiz Capitulino @ 2012-07-25 20:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aliguori, armbru, afaerber, peter.maydell

Basically, this series changes a call like:

 error_set(errp, QERR_DEVICE_NOT_FOUND, device);

to:

 error_set(errp, QERR_DEVICE_NOT_FOUND,
           "Device 'device=%s' not found", device);

In the first call, QERR_DEVICE_NOT_FOUND is a string containing a json dict:

    "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"

error_set() then uses that string and the 'device' argument to build the
error object, which is a QDict. The human error message is fixed, and exists
in the qerror_table[] array. That array is indexed, and the human error
message is added to the error object.

In the new way, QERR_DEVICE_NOT_FOUND is an enumeration value and the
human error message is passed as an argument. qerror_table[] is gone. The
error object is built by using QERR_DEVICE_NOT_FOUND as an index for a table
containing all those json dict strings (this can, and probably will, be
eliminated, as the QMP code can generate its error object from the Error
object).

An important detail is that, the error object data member is constructed
by parsing the human message string and looking for name=value pairs. If
a required data member (like 'device' above) is not found in the human message,
a default value is used ('unknown' for strings and 0 for integers).

This series unlocks several possible simplification, like moving from:

    struct Error
    {
        QDict *obj;
        const char *fmt;
        char *msg;
    };

to:

    struct Error
    {
        ErrClass err_class;
        char *msg;
    };

But I haven't done it all yet.

Please, check individual patches for more details.

 balloon.c                   |  10 +-
 block.c                     |   4 +-
 block/cow.c                 |   3 +-
 block/qcow.c                |   7 +-
 block/qcow2.c               |   3 +-
 block/qed.c                 |   3 +-
 block/stream.c              |   2 +-
 block/vdi.c                 |   4 +-
 block/vmdk.c                |   4 +-
 block/vpc.c                 |   4 +-
 block/vvfat.c               |   4 +-
 blockdev.c                  |  79 +++++++-------
 configure                   |  10 --
 cpus.c                      |  13 ++-
 dump-stub.c                 |   2 +-
 dump.c                      |  18 ++--
 error.c                     |  45 ++------
 error.h                     |   5 +-
 hmp.c                       |   2 +-
 hw/9pfs/virtio-9p.c         |   3 +-
 hw/ivshmem.c                |   2 +-
 hw/pci-stub.c               |   2 +-
 hw/pci.c                    |   4 +-
 hw/qdev-addr.c              |   6 +-
 hw/qdev-monitor.c           |  26 +++--
 hw/qdev-properties.c        |  49 ++++-----
 hw/qdev.c                   |   6 +-
 hw/usb/bus.c                |   3 +-
 hw/usb/hcd-ehci.c           |   6 +-
 hw/usb/redirect.c           |   5 +-
 json-parser.c               |   2 +-
 migration.c                 |   6 +-
 monitor.c                   | 127 +++++------------------
 net.c                       |  20 ++--
 qapi/qapi-visit-core.c      |  22 ++--
 qapi/qmp-dispatch.c         |  14 ++-
 qapi/qmp-input-visitor.c    |  22 ++--
 qapi/string-input-visitor.c |  12 +--
 qemu-config.c               |   2 +-
 qemu-ga.c                   |   4 +-
 qemu-option.c               |  20 ++--
 qemu-sockets.c              |  22 ++--
 qerror.c                    | 243 ++++++++++++++------------------------------
 qerror.h                    |  22 +---
 qga/commands-posix.c        |  78 +++++++-------
 qga/commands-win32.c        |  53 ++++------
 qmp.c                       |  47 +++++----
 qom/object.c                |  20 ++--
 savevm.c                    |   6 +-
 scripts/qapi-errors.py      |  80 ++++++++-------
 target-i386/cpu.c           |  15 +--
 ui/vnc.c                    |   4 +-
 52 files changed, 450 insertions(+), 725 deletions(-)

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

end of thread, other threads:[~2012-07-27 14:27 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-25 20:50 [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set() Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 01/14] monitor: drop unused monitor debug code Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 02/14] qerror: reduce public exposure Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort() Luiz Capitulino
2012-07-26 12:33   ` Markus Armbruster
2012-07-26 15:02     ` Luiz Capitulino
2012-07-26 12:59   ` Eric Blake
2012-07-25 20:50 ` [Qemu-devel] [PATCH 04/14] qerror: drop qerror_report_internal() Luiz Capitulino
2012-07-26 12:35   ` Markus Armbruster
2012-07-25 20:50 ` [Qemu-devel] [PATCH 05/14] qerror: qerror_format(): return an allocated string Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 06/14] qerror: don't delay error message construction Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 07/14] error: " Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 08/14] qerror: add build_error_dict() and error_object_table[] Luiz Capitulino
2012-07-26 12:52   ` Markus Armbruster
2012-07-25 20:50 ` [Qemu-devel] [PATCH 09/14] qerror: qerror_report(): take an index and a human error message Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 10/14] error: error_set(): " Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 11/14] qerror: drop qerror_table[] for good Luiz Capitulino
2012-07-26 12:54   ` Markus Armbruster
2012-07-25 20:50 ` [Qemu-devel] [PATCH 12/14] error: turn QERR_ macros into an enumeration Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 13/14] qerror: change all qerror_report() calls to use the ErrClass enum Luiz Capitulino
2012-07-25 20:50 ` [Qemu-devel] [PATCH 14/14] error: change all error_set() " Luiz Capitulino
2012-07-26  2:43 ` [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set() Anthony Liguori
2012-07-26  9:45   ` Kevin Wolf
2012-07-26 12:41     ` Anthony Liguori
2012-07-26 14:12       ` Luiz Capitulino
2012-07-26 15:05         ` Anthony Liguori
2012-07-26 15:52           ` Markus Armbruster
2012-07-26 14:40       ` Kevin Wolf
2012-07-26 15:20         ` Anthony Liguori
2012-07-26 16:12   ` Daniel P. Berrange
2012-07-26 16:38     ` Markus Armbruster
2012-07-26 15:54 ` Markus Armbruster
2012-07-26 16:03   ` Paolo Bonzini
2012-07-26 16:37     ` Luiz Capitulino
2012-07-27 13:17       ` Andreas Färber
2012-07-27 13:45         ` Anthony Liguori
2012-07-27 14:27         ` Luiz Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).