Patchwork [26/27] error, qerror: pass desc string to error calls

login
register
mail settings
Submitter Luiz Capitulino
Date July 27, 2012, 9:32 p.m.
Message ID <1343424728-22461-27-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/173794/
State New
Headers show

Comments

Luiz Capitulino - July 27, 2012, 9:32 p.m.
FIXME: broke error_is_type() and qemu-ga.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 error.c  |   5 ++-
 qerror.c |  44 ++------------------
 qerror.h | 143 +++++++++++++++++++++++++++++++--------------------------------
 3 files changed, 77 insertions(+), 115 deletions(-)
Amos Kong - Aug. 1, 2012, 11:37 a.m.
On 28/07/12 05:32, Luiz Capitulino wrote:
> FIXME: broke error_is_type() and qemu-ga.
>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
> ---
>   error.c  |   5 ++-
>   qerror.c |  44 ++------------------
>   qerror.h | 143 +++++++++++++++++++++++++++++++--------------------------------
>   3 files changed, 77 insertions(+), 115 deletions(-)
>
> diff --git a/error.c b/error.c
> index 1c37092..dd20ab8 100644
> --- a/error.c
> +++ b/error.c
> @@ -29,6 +29,7 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
>   {
>       Error *err;
>       va_list ap;
> +    char msg[2048];
>
>       if (errp == NULL) {
>           return;
> @@ -37,9 +38,9 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
>       err = g_malloc0(sizeof(*err));
>
>       va_start(ap, fmt);
> -    err->obj = qobject_to_qdict(qobject_from_jsonv(fmt,&ap));

err->obj is not set in latest error_set(), it would be used in 
error_is_type()

    >> error_class = qdict_get_str(err->obj, "class");



> +    vsnprintf(msg, sizeof(msg), fmt, ap);
>       va_end(ap);
> -    err->msg = qerror_format(fmt, err->obj);
> +    err->msg = g_strdup(msg);
>       err->err_class = err_class;
>
>       *errp = err;
> diff --git a/qerror.c b/qerror.c
> index 85e65b8..f443261 100644
> --- a/qerror.c
> +++ b/qerror.c
> @@ -346,45 +346,6 @@ static QError *qerror_new(void)
>       return qerr;
>   }
>
> -static QDict *error_obj_from_fmt_no_fail(const char *fmt, va_list *va)
> -{
> -    QObject *obj;
> -    QDict *ret;
> -
> -    obj = qobject_from_jsonv(fmt, va);
> -    if (!obj) {
> -        fprintf(stderr, "invalid json in error dict '%s'\n", fmt);
> -        abort();
> -    }
> -    if (qobject_type(obj) != QTYPE_QDICT) {
> -        fprintf(stderr, "error is not a dict '%s'\n", fmt);
> -        abort();
> -    }
> -
> -    ret = qobject_to_qdict(obj);
> -    obj = qdict_get(ret, "class");
> -    if (!obj) {
> -        fprintf(stderr, "missing 'class' key in '%s'\n", fmt);
> -        abort();
> -    }
> -    if (qobject_type(obj) != QTYPE_QSTRING) {
> -        fprintf(stderr, "'class' key value should be a string in '%s'\n", fmt);
> -        abort();
> -    }
> -
> -    obj = qdict_get(ret, "data");
> -    if (!obj) {
> -        fprintf(stderr, "missing 'data' key in '%s'\n", fmt);
> -        abort();
> -    }
> -    if (qobject_type(obj) != QTYPE_QDICT) {
> -        fprintf(stderr, "'data' key value should be a dict in '%s'\n", fmt);
> -        abort();
> -    }
> -
> -    return ret;
> -}
> -
>   /**
>    * qerror_from_info(): Create a new QError from error information
>    *
> @@ -394,13 +355,14 @@ static QError *qerror_from_info(ErrorClass err_class, const char *fmt,
>                                   va_list *va)
>   {
>       QError *qerr;
> +    char msg[2048];
>
>       qerr = qerror_new();
>       loc_save(&qerr->loc);
>
>       qerr->err_class = err_class;
> -    qerr->error = error_obj_from_fmt_no_fail(fmt, va);
> -    qerr->err_msg = qerror_format(fmt, qerr->error);
> +    vsnprintf(msg, sizeof(msg), fmt, *va);
> +    qerr->err_msg = g_strdup(msg);
>
>       return qerr;
>   }
> diff --git a/qerror.h b/qerror.h
> index 14b9bfc..92a4b83 100644
> --- a/qerror.h
> +++ b/qerror.h
> @@ -45,217 +45,216 @@ char *qerror_format(const char *fmt, QDict *error);
>    * Use scripts/check-qerror.sh to check.
>    */
>   #define QERR_ADD_CLIENT_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AddClientFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Could not add client"
>
>   #define QERR_AMBIGUOUS_PATH \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object"
>
>   #define QERR_BAD_BUS_FOR_DEVICE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus"
>
>   #define QERR_BASE_NOT_FOUND \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
>
>   #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
>
>   #define QERR_BUFFER_OVERRUN \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BufferOverrun', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran"
>
>   #define QERR_BUS_NO_HOTPLUG \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
>
>   #define QERR_BUS_NOT_FOUND \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
>
>   #define QERR_COMMAND_DISABLED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance"
>
>   #define QERR_COMMAND_NOT_FOUND \
> -    ERROR_CLASS_COMMAND_NOT_FOUND, "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
> +    ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
>
>   #define QERR_DEVICE_ENCRYPTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is encrypted (filename=%s)"
>
>   #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'"
>
>   #define QERR_DEVICE_HAS_NO_MEDIUM \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
>
>   #define QERR_DEVICE_INIT_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
>
>   #define QERR_DEVICE_IN_USE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
>
>   #define QERR_DEVICE_IS_READ_ONLY \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
>
>   #define QERR_DEVICE_LOCKED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked"
>
>   #define QERR_DEVICE_MULTIPLE_BUSSES \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses"
>
>   #define QERR_DEVICE_NO_BUS \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus"
>
>   #define QERR_DEVICE_NO_HOTPLUG \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
>
>   #define QERR_DEVICE_NOT_ACTIVE \
> -    ERROR_CLASS_DEVICE_NOT_ACTIVE, "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
> +    ERROR_CLASS_DEVICE_NOT_ACTIVE, "Device '%s' has not been activated"
>
>   #define QERR_DEVICE_NOT_ENCRYPTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
>
>   #define QERR_DEVICE_NOT_FOUND \
> -    ERROR_CLASS_DEVICE_NOT_FOUND, "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
> +    ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
>
>   #define QERR_DEVICE_NOT_REMOVABLE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable"
>
>   #define QERR_DUPLICATE_ID \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s"
>
>   #define QERR_FD_NOT_FOUND \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
>
>   #define QERR_FD_NOT_SUPPLIED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotSupplied', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
>
>   #define QERR_FEATURE_DISABLED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
>
>   #define QERR_INVALID_BLOCK_FORMAT \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
>
>   #define QERR_INVALID_OPTION_GROUP \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'"
>
>   #define QERR_INVALID_PARAMETER \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
>
>   #define QERR_INVALID_PARAMETER_COMBINATION \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterCombination', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination"
>
>   #define QERR_INVALID_PARAMETER_TYPE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
>
>   #define QERR_INVALID_PARAMETER_VALUE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
>
>   #define QERR_INVALID_PASSWORD \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidPassword', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
>
>   #define QERR_IO_ERROR \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'IOError', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
>
>   #define QERR_JSON_PARSE_ERROR \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s"
>
>   #define QERR_JSON_PARSING \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParsing', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
>
>   #define QERR_KVM_MISSING_CAP \
> -    ERROR_CLASS_K_V_M_MISSING_CAP, "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
> +    ERROR_CLASS_K_V_M_MISSING_CAP, "Using KVM without %s, %s unavailable"
>
>   #define QERR_MIGRATION_ACTIVE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationActive', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
>
>   #define QERR_MIGRATION_NOT_SUPPORTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
> +    ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
>
>   #define QERR_MIGRATION_EXPECTED \
> -    ERROR_CLASS_MIGRATION_EXPECTED, "{ 'class': 'MigrationExpected', 'data': {} }"
> +    ERROR_CLASS_MIGRATION_EXPECTED, "An incoming migration is expected before this command can be executed"
>
>   #define QERR_MISSING_PARAMETER \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
>
>   #define QERR_NO_BUS_FOR_DEVICE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'"
>
>   #define QERR_NOT_SUPPORTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NotSupported', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Not supported"
>
>   #define QERR_OPEN_FILE_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Could not open '%s'"
>
>   #define QERR_PERMISSION_DENIED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PermissionDenied', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
>
>   #define QERR_PROPERTY_NOT_FOUND \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found"
>
>   #define QERR_PROPERTY_VALUE_BAD \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
>
>   #define QERR_PROPERTY_VALUE_IN_USE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use"
>
>   #define QERR_PROPERTY_VALUE_NOT_FOUND \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'"
>
>   #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
> -    "'device': %s, 'property': %s, 'value': %"PRId64" } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2"
>
>   #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
>
>   #define QERR_QGA_COMMAND_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
>
>   #define QERR_QGA_LOGGING_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaLoggingFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement"
>
>   #define QERR_QMP_BAD_INPUT_OBJECT \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
>
>   #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
>
>   #define QERR_QMP_EXTRA_MEMBER \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
>
>   #define QERR_RESET_REQUIRED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'ResetRequired', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required"
>
>   #define QERR_SET_PASSWD_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SetPasswdFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Could not set password"
>
>   #define QERR_TOO_MANY_FILES \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'TooManyFiles', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Too many open files"
>
>   #define QERR_UNDEFINED_ERROR \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UndefinedError', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
>
>   #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
>
>   #define QERR_UNSUPPORTED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'Unsupported', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
>
>   #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'"
>
>   #define QERR_VNC_SERVER_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
> +    ERROR_CLASS_GENERIC_ERROR, "Could not start VNC server on %s"
>
>   #define QERR_SOCKET_CONNECT_IN_PROGRESS \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectInprogress', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Connection can not be completed immediately"
>
>   #define QERR_SOCKET_CONNECT_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"
>
>   #define QERR_SOCKET_LISTEN_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockListenFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode"
>
>   #define QERR_SOCKET_BIND_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockBindFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket"
>
>   #define QERR_SOCKET_CREATE_FAILED \
> -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockCreateFailed', 'data': {} }"
> +    ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
>
>   #endif /* QERROR_H */
Luiz Capitulino - Aug. 1, 2012, 1:31 p.m.
On Wed, 01 Aug 2012 19:37:29 +0800
Amos Kong <akong@redhat.com> wrote:

> On 28/07/12 05:32, Luiz Capitulino wrote:
> > FIXME: broke error_is_type() and qemu-ga.
> >
> > Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
> > ---
> >   error.c  |   5 ++-
> >   qerror.c |  44 ++------------------
> >   qerror.h | 143 +++++++++++++++++++++++++++++++--------------------------------
> >   3 files changed, 77 insertions(+), 115 deletions(-)
> >
> > diff --git a/error.c b/error.c
> > index 1c37092..dd20ab8 100644
> > --- a/error.c
> > +++ b/error.c
> > @@ -29,6 +29,7 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
> >   {
> >       Error *err;
> >       va_list ap;
> > +    char msg[2048];
> >
> >       if (errp == NULL) {
> >           return;
> > @@ -37,9 +38,9 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
> >       err = g_malloc0(sizeof(*err));
> >
> >       va_start(ap, fmt);
> > -    err->obj = qobject_to_qdict(qobject_from_jsonv(fmt,&ap));
> 
> err->obj is not set in latest error_set(), it would be used in 
> error_is_type()

Yes, I'm aware about this and wrote to the changelog above so that I don't
forget about it.

> 
>     >> error_class = qdict_get_str(err->obj, "class");
> 
> 
> 
> > +    vsnprintf(msg, sizeof(msg), fmt, ap);
> >       va_end(ap);
> > -    err->msg = qerror_format(fmt, err->obj);
> > +    err->msg = g_strdup(msg);
> >       err->err_class = err_class;
> >
> >       *errp = err;
> > diff --git a/qerror.c b/qerror.c
> > index 85e65b8..f443261 100644
> > --- a/qerror.c
> > +++ b/qerror.c
> > @@ -346,45 +346,6 @@ static QError *qerror_new(void)
> >       return qerr;
> >   }
> >
> > -static QDict *error_obj_from_fmt_no_fail(const char *fmt, va_list *va)
> > -{
> > -    QObject *obj;
> > -    QDict *ret;
> > -
> > -    obj = qobject_from_jsonv(fmt, va);
> > -    if (!obj) {
> > -        fprintf(stderr, "invalid json in error dict '%s'\n", fmt);
> > -        abort();
> > -    }
> > -    if (qobject_type(obj) != QTYPE_QDICT) {
> > -        fprintf(stderr, "error is not a dict '%s'\n", fmt);
> > -        abort();
> > -    }
> > -
> > -    ret = qobject_to_qdict(obj);
> > -    obj = qdict_get(ret, "class");
> > -    if (!obj) {
> > -        fprintf(stderr, "missing 'class' key in '%s'\n", fmt);
> > -        abort();
> > -    }
> > -    if (qobject_type(obj) != QTYPE_QSTRING) {
> > -        fprintf(stderr, "'class' key value should be a string in '%s'\n", fmt);
> > -        abort();
> > -    }
> > -
> > -    obj = qdict_get(ret, "data");
> > -    if (!obj) {
> > -        fprintf(stderr, "missing 'data' key in '%s'\n", fmt);
> > -        abort();
> > -    }
> > -    if (qobject_type(obj) != QTYPE_QDICT) {
> > -        fprintf(stderr, "'data' key value should be a dict in '%s'\n", fmt);
> > -        abort();
> > -    }
> > -
> > -    return ret;
> > -}
> > -
> >   /**
> >    * qerror_from_info(): Create a new QError from error information
> >    *
> > @@ -394,13 +355,14 @@ static QError *qerror_from_info(ErrorClass err_class, const char *fmt,
> >                                   va_list *va)
> >   {
> >       QError *qerr;
> > +    char msg[2048];
> >
> >       qerr = qerror_new();
> >       loc_save(&qerr->loc);
> >
> >       qerr->err_class = err_class;
> > -    qerr->error = error_obj_from_fmt_no_fail(fmt, va);
> > -    qerr->err_msg = qerror_format(fmt, qerr->error);
> > +    vsnprintf(msg, sizeof(msg), fmt, *va);
> > +    qerr->err_msg = g_strdup(msg);
> >
> >       return qerr;
> >   }
> > diff --git a/qerror.h b/qerror.h
> > index 14b9bfc..92a4b83 100644
> > --- a/qerror.h
> > +++ b/qerror.h
> > @@ -45,217 +45,216 @@ char *qerror_format(const char *fmt, QDict *error);
> >    * Use scripts/check-qerror.sh to check.
> >    */
> >   #define QERR_ADD_CLIENT_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AddClientFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Could not add client"
> >
> >   #define QERR_AMBIGUOUS_PATH \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object"
> >
> >   #define QERR_BAD_BUS_FOR_DEVICE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus"
> >
> >   #define QERR_BASE_NOT_FOUND \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
> >
> >   #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
> >
> >   #define QERR_BUFFER_OVERRUN \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BufferOverrun', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran"
> >
> >   #define QERR_BUS_NO_HOTPLUG \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
> >
> >   #define QERR_BUS_NOT_FOUND \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
> >
> >   #define QERR_COMMAND_DISABLED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance"
> >
> >   #define QERR_COMMAND_NOT_FOUND \
> > -    ERROR_CLASS_COMMAND_NOT_FOUND, "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
> >
> >   #define QERR_DEVICE_ENCRYPTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is encrypted (filename=%s)"
> >
> >   #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'"
> >
> >   #define QERR_DEVICE_HAS_NO_MEDIUM \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
> >
> >   #define QERR_DEVICE_INIT_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
> >
> >   #define QERR_DEVICE_IN_USE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
> >
> >   #define QERR_DEVICE_IS_READ_ONLY \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
> >
> >   #define QERR_DEVICE_LOCKED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked"
> >
> >   #define QERR_DEVICE_MULTIPLE_BUSSES \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses"
> >
> >   #define QERR_DEVICE_NO_BUS \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus"
> >
> >   #define QERR_DEVICE_NO_HOTPLUG \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
> >
> >   #define QERR_DEVICE_NOT_ACTIVE \
> > -    ERROR_CLASS_DEVICE_NOT_ACTIVE, "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_DEVICE_NOT_ACTIVE, "Device '%s' has not been activated"
> >
> >   #define QERR_DEVICE_NOT_ENCRYPTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
> >
> >   #define QERR_DEVICE_NOT_FOUND \
> > -    ERROR_CLASS_DEVICE_NOT_FOUND, "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
> >
> >   #define QERR_DEVICE_NOT_REMOVABLE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable"
> >
> >   #define QERR_DUPLICATE_ID \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s"
> >
> >   #define QERR_FD_NOT_FOUND \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
> >
> >   #define QERR_FD_NOT_SUPPLIED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotSupplied', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
> >
> >   #define QERR_FEATURE_DISABLED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
> >
> >   #define QERR_INVALID_BLOCK_FORMAT \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
> >
> >   #define QERR_INVALID_OPTION_GROUP \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'"
> >
> >   #define QERR_INVALID_PARAMETER \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
> >
> >   #define QERR_INVALID_PARAMETER_COMBINATION \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterCombination', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination"
> >
> >   #define QERR_INVALID_PARAMETER_TYPE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
> >
> >   #define QERR_INVALID_PARAMETER_VALUE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
> >
> >   #define QERR_INVALID_PASSWORD \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidPassword', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
> >
> >   #define QERR_IO_ERROR \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'IOError', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
> >
> >   #define QERR_JSON_PARSE_ERROR \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s"
> >
> >   #define QERR_JSON_PARSING \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParsing', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
> >
> >   #define QERR_KVM_MISSING_CAP \
> > -    ERROR_CLASS_K_V_M_MISSING_CAP, "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
> > +    ERROR_CLASS_K_V_M_MISSING_CAP, "Using KVM without %s, %s unavailable"
> >
> >   #define QERR_MIGRATION_ACTIVE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationActive', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
> >
> >   #define QERR_MIGRATION_NOT_SUPPORTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
> >
> >   #define QERR_MIGRATION_EXPECTED \
> > -    ERROR_CLASS_MIGRATION_EXPECTED, "{ 'class': 'MigrationExpected', 'data': {} }"
> > +    ERROR_CLASS_MIGRATION_EXPECTED, "An incoming migration is expected before this command can be executed"
> >
> >   #define QERR_MISSING_PARAMETER \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
> >
> >   #define QERR_NO_BUS_FOR_DEVICE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'"
> >
> >   #define QERR_NOT_SUPPORTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NotSupported', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Not supported"
> >
> >   #define QERR_OPEN_FILE_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Could not open '%s'"
> >
> >   #define QERR_PERMISSION_DENIED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PermissionDenied', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
> >
> >   #define QERR_PROPERTY_NOT_FOUND \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found"
> >
> >   #define QERR_PROPERTY_VALUE_BAD \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
> >
> >   #define QERR_PROPERTY_VALUE_IN_USE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use"
> >
> >   #define QERR_PROPERTY_VALUE_NOT_FOUND \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'"
> >
> >   #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
> > -    "'device': %s, 'property': %s, 'value': %"PRId64" } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2"
> >
> >   #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
> >
> >   #define QERR_QGA_COMMAND_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
> >
> >   #define QERR_QGA_LOGGING_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaLoggingFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement"
> >
> >   #define QERR_QMP_BAD_INPUT_OBJECT \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
> >
> >   #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
> >
> >   #define QERR_QMP_EXTRA_MEMBER \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
> >
> >   #define QERR_RESET_REQUIRED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'ResetRequired', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required"
> >
> >   #define QERR_SET_PASSWD_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SetPasswdFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Could not set password"
> >
> >   #define QERR_TOO_MANY_FILES \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'TooManyFiles', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Too many open files"
> >
> >   #define QERR_UNDEFINED_ERROR \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UndefinedError', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
> >
> >   #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
> >
> >   #define QERR_UNSUPPORTED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'Unsupported', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
> >
> >   #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'"
> >
> >   #define QERR_VNC_SERVER_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Could not start VNC server on %s"
> >
> >   #define QERR_SOCKET_CONNECT_IN_PROGRESS \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectInprogress', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Connection can not be completed immediately"
> >
> >   #define QERR_SOCKET_CONNECT_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"
> >
> >   #define QERR_SOCKET_LISTEN_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockListenFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode"
> >
> >   #define QERR_SOCKET_BIND_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockBindFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket"
> >
> >   #define QERR_SOCKET_CREATE_FAILED \
> > -    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockCreateFailed', 'data': {} }"
> > +    ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
> >
> >   #endif /* QERROR_H */
>

Patch

diff --git a/error.c b/error.c
index 1c37092..dd20ab8 100644
--- a/error.c
+++ b/error.c
@@ -29,6 +29,7 @@  void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
 {
     Error *err;
     va_list ap;
+    char msg[2048];
 
     if (errp == NULL) {
         return;
@@ -37,9 +38,9 @@  void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
     err = g_malloc0(sizeof(*err));
 
     va_start(ap, fmt);
-    err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap));
+    vsnprintf(msg, sizeof(msg), fmt, ap);
     va_end(ap);
-    err->msg = qerror_format(fmt, err->obj);
+    err->msg = g_strdup(msg);
     err->err_class = err_class;
 
     *errp = err;
diff --git a/qerror.c b/qerror.c
index 85e65b8..f443261 100644
--- a/qerror.c
+++ b/qerror.c
@@ -346,45 +346,6 @@  static QError *qerror_new(void)
     return qerr;
 }
 
-static QDict *error_obj_from_fmt_no_fail(const char *fmt, va_list *va)
-{
-    QObject *obj;
-    QDict *ret;
-
-    obj = qobject_from_jsonv(fmt, va);
-    if (!obj) {
-        fprintf(stderr, "invalid json in error dict '%s'\n", fmt);
-        abort();
-    }
-    if (qobject_type(obj) != QTYPE_QDICT) {
-        fprintf(stderr, "error is not a dict '%s'\n", fmt);
-        abort();
-    }
-
-    ret = qobject_to_qdict(obj);
-    obj = qdict_get(ret, "class");
-    if (!obj) {
-        fprintf(stderr, "missing 'class' key in '%s'\n", fmt);
-        abort();
-    }
-    if (qobject_type(obj) != QTYPE_QSTRING) {
-        fprintf(stderr, "'class' key value should be a string in '%s'\n", fmt);
-        abort();
-    }
-
-    obj = qdict_get(ret, "data");
-    if (!obj) {
-        fprintf(stderr, "missing 'data' key in '%s'\n", fmt);
-        abort();
-    }
-    if (qobject_type(obj) != QTYPE_QDICT) {
-        fprintf(stderr, "'data' key value should be a dict in '%s'\n", fmt);
-        abort();
-    }
-
-    return ret;
-}
-
 /**
  * qerror_from_info(): Create a new QError from error information
  *
@@ -394,13 +355,14 @@  static QError *qerror_from_info(ErrorClass err_class, const char *fmt,
                                 va_list *va)
 {
     QError *qerr;
+    char msg[2048];
 
     qerr = qerror_new();
     loc_save(&qerr->loc);
 
     qerr->err_class = err_class;
-    qerr->error = error_obj_from_fmt_no_fail(fmt, va);
-    qerr->err_msg = qerror_format(fmt, qerr->error);
+    vsnprintf(msg, sizeof(msg), fmt, *va);
+    qerr->err_msg = g_strdup(msg);
 
     return qerr;
 }
diff --git a/qerror.h b/qerror.h
index 14b9bfc..92a4b83 100644
--- a/qerror.h
+++ b/qerror.h
@@ -45,217 +45,216 @@  char *qerror_format(const char *fmt, QDict *error);
  * Use scripts/check-qerror.sh to check.
  */
 #define QERR_ADD_CLIENT_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AddClientFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Could not add client"
 
 #define QERR_AMBIGUOUS_PATH \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object"
 
 #define QERR_BAD_BUS_FOR_DEVICE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus"
 
 #define QERR_BASE_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
 
 #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
 
 #define QERR_BUFFER_OVERRUN \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BufferOverrun', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran"
 
 #define QERR_BUS_NO_HOTPLUG \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
 
 #define QERR_BUS_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
 
 #define QERR_COMMAND_DISABLED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance"
 
 #define QERR_COMMAND_NOT_FOUND \
-    ERROR_CLASS_COMMAND_NOT_FOUND, "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
+    ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
 
 #define QERR_DEVICE_ENCRYPTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is encrypted (filename=%s)"
 
 #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'"
 
 #define QERR_DEVICE_HAS_NO_MEDIUM \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
 
 #define QERR_DEVICE_INIT_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
 
 #define QERR_DEVICE_IN_USE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
 
 #define QERR_DEVICE_IS_READ_ONLY \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
 
 #define QERR_DEVICE_LOCKED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked"
 
 #define QERR_DEVICE_MULTIPLE_BUSSES \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses"
 
 #define QERR_DEVICE_NO_BUS \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus"
 
 #define QERR_DEVICE_NO_HOTPLUG \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
 
 #define QERR_DEVICE_NOT_ACTIVE \
-    ERROR_CLASS_DEVICE_NOT_ACTIVE, "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
+    ERROR_CLASS_DEVICE_NOT_ACTIVE, "Device '%s' has not been activated"
 
 #define QERR_DEVICE_NOT_ENCRYPTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
 
 #define QERR_DEVICE_NOT_FOUND \
-    ERROR_CLASS_DEVICE_NOT_FOUND, "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
+    ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
 
 #define QERR_DEVICE_NOT_REMOVABLE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable"
 
 #define QERR_DUPLICATE_ID \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s"
 
 #define QERR_FD_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
 
 #define QERR_FD_NOT_SUPPLIED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotSupplied', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
 
 #define QERR_FEATURE_DISABLED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
 
 #define QERR_INVALID_BLOCK_FORMAT \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
 
 #define QERR_INVALID_OPTION_GROUP \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'"
 
 #define QERR_INVALID_PARAMETER \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
 
 #define QERR_INVALID_PARAMETER_COMBINATION \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterCombination', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination"
 
 #define QERR_INVALID_PARAMETER_TYPE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
 
 #define QERR_INVALID_PARAMETER_VALUE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
 
 #define QERR_INVALID_PASSWORD \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidPassword', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
 
 #define QERR_IO_ERROR \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'IOError', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
 
 #define QERR_JSON_PARSE_ERROR \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s"
 
 #define QERR_JSON_PARSING \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParsing', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
 
 #define QERR_KVM_MISSING_CAP \
-    ERROR_CLASS_K_V_M_MISSING_CAP, "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
+    ERROR_CLASS_K_V_M_MISSING_CAP, "Using KVM without %s, %s unavailable"
 
 #define QERR_MIGRATION_ACTIVE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationActive', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
 
 #define QERR_MIGRATION_NOT_SUPPORTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
+    ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
 
 #define QERR_MIGRATION_EXPECTED \
-    ERROR_CLASS_MIGRATION_EXPECTED, "{ 'class': 'MigrationExpected', 'data': {} }"
+    ERROR_CLASS_MIGRATION_EXPECTED, "An incoming migration is expected before this command can be executed"
 
 #define QERR_MISSING_PARAMETER \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
 
 #define QERR_NO_BUS_FOR_DEVICE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'"
 
 #define QERR_NOT_SUPPORTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NotSupported', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Not supported"
 
 #define QERR_OPEN_FILE_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Could not open '%s'"
 
 #define QERR_PERMISSION_DENIED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PermissionDenied', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
 
 #define QERR_PROPERTY_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found"
 
 #define QERR_PROPERTY_VALUE_BAD \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
 
 #define QERR_PROPERTY_VALUE_IN_USE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use"
 
 #define QERR_PROPERTY_VALUE_NOT_FOUND \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'"
 
 #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
-    "'device': %s, 'property': %s, 'value': %"PRId64" } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2"
 
 #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
+    ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
 
 #define QERR_QGA_COMMAND_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
 
 #define QERR_QGA_LOGGING_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaLoggingFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement"
 
 #define QERR_QMP_BAD_INPUT_OBJECT \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
 
 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
 
 #define QERR_QMP_EXTRA_MEMBER \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
 
 #define QERR_RESET_REQUIRED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'ResetRequired', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required"
 
 #define QERR_SET_PASSWD_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SetPasswdFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Could not set password"
 
 #define QERR_TOO_MANY_FILES \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'TooManyFiles', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Too many open files"
 
 #define QERR_UNDEFINED_ERROR \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UndefinedError', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
 
 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
 
 #define QERR_UNSUPPORTED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'Unsupported', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
 
 #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'"
 
 #define QERR_VNC_SERVER_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
+    ERROR_CLASS_GENERIC_ERROR, "Could not start VNC server on %s"
 
 #define QERR_SOCKET_CONNECT_IN_PROGRESS \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectInprogress', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Connection can not be completed immediately"
 
 #define QERR_SOCKET_CONNECT_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"
 
 #define QERR_SOCKET_LISTEN_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockListenFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode"
 
 #define QERR_SOCKET_BIND_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockBindFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket"
 
 #define QERR_SOCKET_CREATE_FAILED \
-    ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockCreateFailed', 'data': {} }"
+    ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
 
 #endif /* QERROR_H */