: qapi: generate qerrors from qapi-schema-errors.json
cover : qapi: generate qerrors from qapi-schema-errors.json
This series moves all qerrors we have today to qapi-schema-errors.json and generate the error macros and table from it.
With this series, one doesn't have to manually add an error macro and the matching table entry anymore. He or she just have to add the new error to qapi-schema-errors.json.
There's only one small problem: the matching between error class name and the (generated) error macro may not be clear for those not familirized with qerrors. There are two possible solutions to this:
1. Add the generated macro name along with the error class name in qapi-schema-json-errors.json; and/or
2. add docs/qapi-errors.txt to explain this in detail
This series is my first step on improving our error API.
Makefile | 8 +- hw/qdev-properties.c | 2 +- migration-tcp.c | 6 +- monitor.c | 2 +- qapi-schema-errors.json | 616 +++++++++++++++++++++++++++++++++++++++++++++++ qapi/qmp-dispatch.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qemu-sockets.c | 22 +- qerror.c | 310 +----------------------- qerror.h | 220 +---------------- scripts/check-qerror.sh | 6 +- scripts/qapi-errors.py | 180 ++++++++++++++ scripts/qapi.py | 4 +- 13 files changed, 827 insertions(+), 553 deletions(-)
PATCH 1/9 qerror: rename QERR_SOCKET_* macros
The socket error classes call a socket 'Sock', like in SockConnectFailed, but the error macros call a socket SOCKET, like in QERR_SOCKET_CONNECT_FAILED.
This will cause problems when the error macros creation get automated, because the macro name will be derived from the error class name.
Avoid that by renaming all QERR_SOCKET_* macros to QERR_SOCK_*.
--- migration-tcp.c | 6 +++--- qemu-sockets.c | 22 +++++++++++----------- qerror.c | 10 +++++----- qerror.h | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-)
migration-tcp.c +3 -3
@@ -90,13 +90,13 @@ int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,if (!error_is_set (errp)) {migrate_fd_connect (s); - }else if (error_is_type (*errp,QERR_SOCKET_CONNECT_IN_PROGRESS )) { + }else if (error_is_type (*errp,QERR_SOCK_CONNECT_IN_PROGRESS )) {DPRINTF ("connect in progress\n" );qemu_set_fd_handler2 (s->fd,NULL ,NULL , tcp_wait_for_connect, s); - }else if (error_is_type (*errp,QERR_SOCKET_CREATE_FAILED )) { + }else if (error_is_type (*errp,QERR_SOCK_CREATE_FAILED )) {DPRINTF ("connect failed\n" );return -1 ; - }else if (error_is_type (*errp,QERR_SOCKET_CONNECT_FAILED )) { + }else if (error_is_type (*errp,QERR_SOCK_CONNECT_FAILED )) {DPRINTF ("connect failed\n" );migrate_fd_error (s);return -1 ;
qemu-sockets.c +11 -11
@@ -120,7 +120,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)if ((qemu_opt_get (opts,"host" ) ==NULL ) || (qemu_opt_get (opts,"port" ) ==NULL )) {fprintf (stderr,"%s: host and/or port not specified\n" , __FUNCTION__); -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED );return -1 ; }pstrcpy (port,sizeof (port),qemu_opt_get (opts,"port" ));
@@ -139,7 +139,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)if (rc !=0 ) {fprintf (stderr,"getaddrinfo(%s,%s): %s\n" , addr, port,gai_strerror (rc)); -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED );return -1 ; }
@@ -153,7 +153,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)fprintf (stderr,"%s: socket(%s): %s\n" , __FUNCTION__,inet_strfamily (e->ai_family),strerror (errno));if (!e->ai_next) { -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED ); }continue ; }
@@ -179,7 +179,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)inet_strfamily (e->ai_family), uaddr,inet_getport (e), strerror(errno));if (!e->ai_next) { -error_set (errp,QERR_SOCKET_BIND_FAILED ); +error_set (errp,QERR_SOCK_BIND_FAILED ); } } }
@@ -191,7 +191,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) listen:if (listen (slisten,1 ) !=0 ) { -error_set (errp,QERR_SOCKET_LISTEN_FAILED ); +error_set (errp,QERR_SOCK_LISTEN_FAILED );perror ("listen" );closesocket (slisten);freeaddrinfo (res);
@@ -226,7 +226,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp) block =qemu_opt_get_bool (opts,"block" ,0 );if (addr ==NULL || port ==NULL ) {fprintf (stderr,"inet_connect: host and/or port not specified\n" ); -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED );return -1 ; }
@@ -239,7 +239,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp)if (0 != (rc =getaddrinfo (addr, port, &ai, &res))) {fprintf (stderr,"getaddrinfo(%s,%s): %s\n" , addr, port,gai_strerror (rc)); -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED );return -1 ; }
@@ -274,7 +274,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp)#else if (!block && (rc == -EINPROGRESS )) {#endif -error_set (errp,QERR_SOCKET_CONNECT_IN_PROGRESS ); +error_set (errp,QERR_SOCK_CONNECT_IN_PROGRESS ); }else if (rc <0 ) {if (NULL == e->ai_next) fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__,
@@ -287,7 +287,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp)freeaddrinfo (res);return sock; } -error_set (errp,QERR_SOCKET_CONNECT_FAILED ); +error_set (errp,QERR_SOCK_CONNECT_FAILED );freeaddrinfo (res);return -1 ; }
@@ -479,7 +479,7 @@ int inet_listen(const char *str, char *ostr, int olen, } } }else { -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED ); }qemu_opts_del (opts);return sock;
@@ -497,7 +497,7 @@ int inet_connect(const char *str, bool block, Error **errp) } sock =inet_connect_opts (opts, errp); }else { -error_set (errp,QERR_SOCKET_CREATE_FAILED ); +error_set (errp,QERR_SOCK_CREATE_FAILED ); }qemu_opts_del (opts);return sock;
qerror.c +5 -5
@@ -309,23 +309,23 @@ static const QErrorStringTable qerror_table[] = { .desc = "Could not start VNC server on %(target)", }, { - .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS, + .error_fmt = QERR_SOCK_CONNECT_IN_PROGRESS, .desc = "Connection can not be completed immediately", }, { - .error_fmt = QERR_SOCKET_CONNECT_FAILED, + .error_fmt = QERR_SOCK_CONNECT_FAILED, .desc = "Failed to connect to socket", }, { - .error_fmt = QERR_SOCKET_LISTEN_FAILED, + .error_fmt = QERR_SOCK_LISTEN_FAILED, .desc = "Failed to set socket to listening mode", }, { - .error_fmt = QERR_SOCKET_BIND_FAILED, + .error_fmt = QERR_SOCK_BIND_FAILED, .desc = "Failed to bind socket", }, { - .error_fmt = QERR_SOCKET_CREATE_FAILED, + .error_fmt = QERR_SOCK_CREATE_FAILED, .desc = "Failed to create socket", }, {}
qerror.h +5 -5
@@ -251,19 +251,19 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_VNC_SERVER_FAILED \ "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }" -#define QERR_SOCKET_CONNECT_IN_PROGRESS \ +#define QERR_SOCK_CONNECT_IN_PROGRESS \ "{ 'class': 'SockConnectInprogress', 'data': {} }" -#define QERR_SOCKET_CONNECT_FAILED \ +#define QERR_SOCK_CONNECT_FAILED \ "{ 'class': 'SockConnectFailed', 'data': {} }" -#define QERR_SOCKET_LISTEN_FAILED \ +#define QERR_SOCK_LISTEN_FAILED \ "{ 'class': 'SockListenFailed', 'data': {} }" -#define QERR_SOCKET_BIND_FAILED \ +#define QERR_SOCK_BIND_FAILED \ "{ 'class': 'SockBindFailed', 'data': {} }" -#define QERR_SOCKET_CREATE_FAILED \ +#define QERR_SOCK_CREATE_FAILED \ "{ 'class': 'SockCreateFailed', 'data': {} }"#endif /* QERROR_H */
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 2/9 qerror: rename QERR_SOCK_CONNECT_IN_PROGRESS
In reply to Luiz CapitulinoThe error class name is SockConnectInprogress, not SockConnectInProgress.
Rename the QERR_SOCK_CONNECT_IN_PROGRESS macro to QERR_SOCK_CONNECT_INPROGRESS to reflect that, so that future error macro generation generates the expected macro name.
--- migration-tcp.c | 2 +- qemu-sockets.c | 2 +- qerror.c | 2 +- qerror.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
migration-tcp.c +1 -1
@@ -90,7 +90,7 @@ int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,if (!error_is_set (errp)) {migrate_fd_connect (s); - }else if (error_is_type (*errp,QERR_SOCK_CONNECT_IN_PROGRESS )) { + }else if (error_is_type (*errp,QERR_SOCK_CONNECT_INPROGRESS )) {DPRINTF ("connect in progress\n" );qemu_set_fd_handler2 (s->fd,NULL ,NULL , tcp_wait_for_connect, s); }else if (error_is_type (*errp,QERR_SOCK_CREATE_FAILED )) {
qemu-sockets.c +1 -1
@@ -274,7 +274,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp)#else if (!block && (rc == -EINPROGRESS )) {#endif -error_set (errp,QERR_SOCK_CONNECT_IN_PROGRESS ); +error_set (errp,QERR_SOCK_CONNECT_INPROGRESS ); }else if (rc <0 ) {if (NULL == e->ai_next) fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__,
qerror.c +1 -1
@@ -309,7 +309,7 @@ static const QErrorStringTable qerror_table[] = { .desc = "Could not start VNC server on %(target)", }, { - .error_fmt = QERR_SOCK_CONNECT_IN_PROGRESS, + .error_fmt = QERR_SOCK_CONNECT_INPROGRESS, .desc = "Connection can not be completed immediately", }, {
qerror.h +1 -1
@@ -251,7 +251,7 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_VNC_SERVER_FAILED \ "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }" -#define QERR_SOCK_CONNECT_IN_PROGRESS \ +#define QERR_SOCK_CONNECT_INPROGRESS \ "{ 'class': 'SockConnectInprogress', 'data': {} }"#define QERR_SOCK_CONNECT_FAILED \
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 3/9 qerror: rename QERR_QMP_EXTRA_MEMBER
In reply to Luiz CapitulinoThe error class name is QMPExtraInputObjectMember, not QMPExtraMember.
Rename the QERR_QMP_EXTRA_MEMBER macro to QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER to reflect that, so that future error macro generation generates the expected macro name.
--- monitor.c | 2 +- qapi/qmp-dispatch.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qerror.c | 2 +- qerror.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
monitor.c +1 -1
@@ -4434,7 +4434,7 @@ static QDict *qmp_check_input_obj(QObject *input_obj) }else if (!strcmp (arg_name,"id" )) {/* FIXME: check duplicated IDs for async commands */ }else { -qerror_report (QERR_QMP_EXTRA_MEMBER , arg_name); +qerror_report (QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER , arg_name);return NULL ; } }
qapi/qmp-dispatch.c +1 -1
@@ -47,7 +47,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) } has_exec_key = true; }else if (strcmp (arg_name,"arguments" )) { -error_set (errp,QERR_QMP_EXTRA_MEMBER , arg_name); +error_set (errp,QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER , arg_name);return NULL ; } }
qapi/qmp-input-visitor.c +1 -1
@@ -104,7 +104,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_set (errp,QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER , key); }g_hash_table_unref (top_ht); }
qerror.c +1 -1
@@ -271,7 +271,7 @@ static const QErrorStringTable qerror_table[] = { .desc = "QMP input object member '%(member)' expects '%(expected)'", }, { - .error_fmt = QERR_QMP_EXTRA_MEMBER, + .error_fmt = QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER, .desc = "QMP input object member '%(member)' is unexpected", }, {
qerror.h +1 -1
@@ -224,7 +224,7 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \ "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }" -#define QERR_QMP_EXTRA_MEMBER \ +#define QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER \ "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"#define QERR_RESET_REQUIRED \
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 4/9 qerror: rename QERR_PROPERTY_VALUE_NOT_POWER_OF_2
In reply to Luiz CapitulinoThe error class name is PropertyValueNotPowerOf2, not PropertyValueNotPowerOf_2.
Rename the QERR_PROPERTY_VALUE_NOT_POWER_OF_2 macro to QERR_PROPERTY_VALUE_NOT_POWER_OF2 to reflect that, so that future error macro generation generates the expected macro name.
--- hw/qdev-properties.c | 2 +- qerror.c | 2 +- qerror.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
hw/qdev-properties.c +1 -1
@@ -885,7 +885,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,/* We rely on power-of-2 blocksizes for bitmasks */ if ((value & (value -1 )) !=0 ) { -error_set (errp,QERR_PROPERTY_VALUE_NOT_POWER_OF_2 , +error_set (errp,QERR_PROPERTY_VALUE_NOT_POWER_OF2 , dev->id?:"" , name, (int64_t )value);return ; }
qerror.c +1 -1
@@ -245,7 +245,7 @@ static const QErrorStringTable qerror_table[] = { .desc = "Property '%(device).%(property)' can't find value '%(value)'", }, { - .error_fmt = QERR_PROPERTY_VALUE_NOT_POWER_OF_2, + .error_fmt = QERR_PROPERTY_VALUE_NOT_POWER_OF2, .desc ="Property '%(device).%(property)' doesn't take " "value '%(value)', it's not a power of 2", },
qerror.h +1 -1
@@ -205,7 +205,7 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_PROPERTY_VALUE_NOT_FOUND \ "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }" -#define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \ +#define QERR_PROPERTY_VALUE_NOT_POWER_OF2 \ "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \ "'device': %s, 'property': %s, 'value': %"PRId64" } }"
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 5/9 qapi: qapi.py: allow the "'" character be escaped
In reply to Luiz CapitulinoA future commit will add a new qapi script which escapes that character.
--- scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/qapi.py +3 -1
@@ -21,7 +21,9 @@ def tokenize(data): elif data[0] == "'": data = data[1:] string = '' - while data[0] != "'": + while True: + if data[0] == "'" and string[len(string)-1] != "\\": + break string += data[0] data = data[1:] data = data[1:]
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 6/9 qapi: add qapi-schema-errors.json
In reply to Luiz CapitulinoThis is the main error file, where all errors are defined and from where error macros and whatnot will be automatically generated.
It contains all errors classes currently defined in qerror.[ch].
--- qapi-schema-errors.json | 616 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 616 insertions(+) create mode 100644 qapi-schema-errors.json
qapi-schema-errors.json new file +616 -0
@@ -0,0 +1,616 @@ +## +# @AddClientFailed +# +# Since: 0.15 +## +{ 'error': 'AddClientFailed', + 'description': 'Could not add client' } + +## +# @AmbiguousPath +# +# Since: 1.1.0 +## +{ 'error': 'AmbiguousPath', + 'description': 'Path \'%(path)\' does not uniquely identify a %(object)', + 'data': {'path': 'str'} } + +## +# @BadBusForDevice +# +# Since: 0.14 +## +{ 'error': 'BadBusForDevice', + 'description': 'Device \'%(device)\' can\'t go on a %(bad_bus_type) bus', + 'data': {'device': 'str', 'bad_bus_type': 'str'} } + +## +# @BaseNotFound +# +# Since: 1.1.0 +## +{ 'error': 'BaseNotFound', + 'description': 'Base \'%(base)\' not found', + 'data': {'base': 'str'} } + +## +# @BlockFormatFeatureNotSupported +# +# Since: 1.0 +## +{ 'error': 'BlockFormatFeatureNotSupported', + 'description': 'Block format \'%(format)\' used by device \'%(name)\' does not support feature \'%(feature)\'', + 'data': {'format': 'str', 'name': 'str', 'feature': 'str'} } + +## +# @BufferOverrun +# +# Since: 0.15 +## +{ 'error': 'BufferOverrun', + 'description': 'An internal buffer overran' } + +## +# @BusNoHotplug +# +# Since: 0.14 +## +{ 'error': 'BusNoHotplug', + 'description': 'Bus \'%(bus)\' does not support hotplugging', + 'data': {'bus': 'str'} } + +## +# @BusNotFound +# +# Since: 0.14 +## +{ 'error': 'BusNotFound', + 'description': 'Bus \'%(bus)\' not found', + 'data': {'bus': 'str'} } + +## +# @CommandDisabled +# +# Since: 1.1.0 +## +{ 'error': 'CommandDisabled', + 'description': 'The command %(name) has been disabled for this instance', + 'data': {'name': 'str'} } + +## +# @CommandNotFound +# +# Since: 0.14 +## +{ 'error': 'CommandNotFound', + 'description': 'The command %(name) has not been found', + 'data': {'name': 'str'} } + +## +# @DeviceEncrypted +# +# Since: 0.14 +## +{ 'error': 'DeviceEncrypted', + 'description': 'Device \'%(device)\' is encrypted', + 'data': {'device': 'str', 'filename': 'str'} } + +## +# @DeviceFeatureBlocksMigration +# +# Since: 1.0 +## +{ 'error': 'DeviceFeatureBlocksMigration', + 'description': 'Migration is disabled when using feature \'%(feature)\' in device \'%(device)\'', + 'data': {'device': 'str', 'feature': 'str'} } + +## +# @DeviceHasNoMedium +# +# Since: 1.1.0 +## +{ 'error': 'DeviceHasNoMedium', + 'description': 'Device \'%(device)\' has no medium', + 'data': {'device': 'str'} } + +## +# @DeviceInitFailed +# +# Since: 0.14 +## +{ 'error': 'DeviceInitFailed', + 'description': 'Device \'%(device)\' could not be initialized', + 'data': {'device': 'str'} } + +## +# @DeviceInUse +# +# Since: 0.14 +## +{ 'error': 'DeviceInUse', + 'description': 'Device \'%(device)\' is in use', + 'data': {'device': 'str'} } + +## +# @DeviceIsReadOnly +# +# Since: 1.1.0 +## +{ 'error': 'DeviceIsReadOnly', + 'description': 'Device \'%(device)\' is read only', + 'data': {'device': 'str'} } + +## +# @DeviceLocked +# +# Since: 0.14 +## +{ 'error': 'DeviceLocked', + 'description': 'Device \'%(device)\' is locked', + 'data': {'device': 'str'} } + +## +# @DeviceMultipleBusses +# +# Since: 0.14 +## +{ 'error': 'DeviceMultipleBusses', + 'description': 'Device \'%(device)\' has multiple child busses', + 'data': {'device': 'str'} } + +## +# @DeviceNoBus +# +# Since: 0.14 +## +{ 'error': 'DeviceNoBus', + 'description': 'Device \'%(device)\' has no child bus', + 'data': {'device': 'str'} } + +## +# @DeviceNoHotplug +# +# Since: 0.14 +## +{ 'error': 'DeviceNoHotplug', + 'description': 'Device \'%(device)\' does not support hotplugging', + 'data': {'device': 'str'} } + +## +# @DeviceNotActive +# +# Since: 0.14 +## +{ 'error': 'DeviceNotActive', + 'description': 'Device \'%(device)\' has not been activated', + 'data': {'device': 'str'} } + +## +# @DeviceNotEncrypted +# +# Since: 0.14 +## +{ 'error': 'DeviceNotEncrypted', + 'description': 'Device \'%(device)\' is not encrypted', + 'data': {'device': 'str'} } + +## +# @DeviceNotFound +# +# Since: 0.14 +## +{ 'error': 'DeviceNotFound', + 'description': 'Device \'%(device)\' not found', + 'data': {'device': 'str'} } + +## +# @DeviceNotRemovable +# +# Since: 0.14 +## +{ 'error': 'DeviceNotRemovable', + 'description': 'Device \'%(device)\' is not removable', + 'data': {'device': 'str'} } + +## +# @DuplicateId +# +# Since: 0.14 +## +{ 'error': 'DuplicateId', + 'description': 'Duplicate ID \'%(id)\' for %(object)', + 'data': {'id': 'str', 'object': 'str'} } + +## +# @FdNotFound +# +# Since: 0.14 +## +{ 'error': 'FdNotFound', + 'description': 'File descriptor named \'%(name)\' not found', + 'data': {'name': 'str'} } + +## +# @FdNotSupplied +# +# Since: 0.14 +## +{ 'error': 'FdNotSupplied', + 'description': 'No file descriptor supplied via SCM_RIGHTS' } + +## +# @FeatureDisabled +# +# Since: 0.15 +## +{ 'error': 'FeatureDisabled', + 'description': 'The feature \'%(name)\' is not enabled', + 'data': {'name': 'str'} } + +## +# @InvalidBlockFormat +# +# Since: 0.14 +## +{ 'error': 'InvalidBlockFormat', + 'description': 'Invalid block format \'%(name)\'', + 'data': {'name': 'str'} } + +## +# @InvalidOptionGroup +# +# Since: 1.2.0 +## +{ 'error': 'InvalidOptionGroup', + 'description': 'There is no option group \'%(group)\'', + 'data': {'group': 'str'} } + +## +# @InvalidParameter +# +# Since: 0.14 +## +{ 'error': 'InvalidParameter', + 'description': 'Invalid parameter \'%(name)\'', + 'data': {'name': 'str'} } + +## +# @InvalidParameterCombination +# +# Since: 1.1.0 +## +{ 'error': 'InvalidParameterCombination', + 'description': 'Invalid parameter combination' } + +## +# @InvalidParameterType +# +# Since: 0.14 +## +{ 'error': 'InvalidParameterType', + 'description': 'Invalid parameter type for \'%(name)\', expected: %(expected)', + 'data': {'name': 'str', 'expected': 'str'} } + +## +# @InvalidParameterValue +# +# Since: 0.14 +## +{ 'error': 'InvalidParameterValue', + 'description': 'Parameter \'%(name)\' expects %(expected)', + 'data': {'name': 'str', 'expected': 'str'} } + +## +# @InvalidPassword +# +# Since: 0.14 +## +{ 'error': 'InvalidPassword', + 'description': 'Password incorrect' } + +## +# @IOError +# +# Since: 1.1.0 +## +{ 'error': 'IOError', + 'description': 'An IO error has occurred' } + +## +# @JSONParseError +# +# Since: 0.15 +## +{ 'error': 'JSONParseError', + 'description': 'JSON parse error, %(message)', + 'data': {'message': 'str'} } + +## +# @JSONParsing +# +# Since: 0.14 +## +{ 'error': 'JSONParsing', + 'description': 'Invalid JSON syntax' } + +## +# @KVMMissingCap +# +# Since: 0.14 +## +{ 'error': 'KVMMissingCap', + 'description': 'Using KVM without %(capability), %(feature) unavailable', + 'data': {'capability': 'str', 'feature': 'str'} } + +## +# @MigrationActive +# +# Since: 1.1.0 +## +{ 'error': 'MigrationActive', + 'description': 'There\'s a migration process in progress' } + +## +# @MigrationExpected +# +# Since: 0.14 +## +{ 'error': 'MigrationExpected', + 'description': 'An incoming migration is expected before this command can be executed' } + +## +# @MigrationNotSupported +# +# Since: 1.1.0 +## +{ 'error': 'MigrationNotSupported', + 'description': 'State blocked by non-migratable device \'%(device)\'', + 'data': {'device': 'str'} } + +## +# @MissingParameter +# +# Since: 0.14 +## +{ 'error': 'MissingParameter', + 'description': 'Parameter \'%(name)\' is missing', + 'data': {'name': 'str'} } + +## +# @NoBusForDevice +# +# Since: 0.14 +## +{ 'error': 'NoBusForDevice', + 'description': 'No \'%(bus)\' bus found for device \'%(device)\'', + 'data': {'device': 'str', 'bus': 'str'} } + +## +# @NotSupported +# +# Since: 1.0 +## +{ 'error': 'NotSupported', + 'description': 'Not supported' } + +## +# @OpenFileFailed +# +# Since: 0.14 +## +{ 'error': 'OpenFileFailed', + 'description': 'Could not open \'%(filename)\'', + 'data': {'filename': 'str'} } + +## +# @PermissionDenied +# +# Since: 1.1.0 +## +{ 'error': 'PermissionDenied', + 'description': 'Insufficient permission to perform this operation' } + +## +# @PropertyNotFound +# +# Since: 0.14 +## +{ 'error': 'PropertyNotFound', + 'description': 'Property \'%(device).%(property)\' not found', + 'data': {'device': 'str', 'property': 'str'} } + +## +# @PropertyValueBad +# +# Since: 0.14 +## +{ 'error': 'PropertyValueBad', + 'description': 'Property \'%(device).%(property)\' doesn\'t take value \'%(value)\'', + 'data': {'device': 'str', 'property': 'str', 'value': 'str'} } + +## +# @PropertyValueInUse +# +# Since: 0.14 +## +{ 'error': 'PropertyValueInUse', + 'description': 'Property \'%(device).%(property)\' can\'t take value \'%(value)\', it\'s in use', + 'data': {'device': 'str', 'property': 'str', 'value': 'str'} } + +## +# @PropertyValueNotFound +# +# Since: 0.14 +## +{ 'error': 'PropertyValueNotFound', + 'description': 'Property \'%(device).%(property)\' can\'t find value \'%(value)\'', + 'data': {'device': 'str', 'property': 'str', 'value': 'str'} } + +## +# @PropertyValueNotPowerOf2 +# +# Since: 1.1.0 +## +{ 'error': 'PropertyValueNotPowerOf2', + 'description': 'Property \'%(device).%(property)\' doesn\'t take value \'%(value)\', it\'s not a power of 2', + 'data': {'device': 'str', 'property': 'str', 'value': 'int'} } + +## +# @PropertyValueOutOfRange +# +# Since: 1.1.0 +## +{ 'error': 'PropertyValueOutOfRange', + 'description': 'Property \'%(device).%(property)\' doesn\'t take value %(value) (minimum: %(min), maximum: %(max))', + 'data': {'device': 'str', 'property': 'str', 'value': 'int', 'min': 'int', 'max': 'int'} } + +## +# @QgaCommandFailed +# +# Since: 0.15 +## +{ 'error': 'QgaCommandFailed', + 'description': 'Guest agent command failed, error was \'%(message)\'', + 'data': {'message': 'str'} } + +## +# @QgaLoggingFailed +# +# Since: 0.15 +## +{ 'error': 'QgaLoggingFailed', + 'description': 'Guest agent failed to log non-optional log statement' } + +## +# @QMPBadInputObject +# +# Since: 0.14 +## +{ 'error': 'QMPBadInputObject', + 'description': 'Expected \'%(expected)\' in QMP input', + 'data': {'expected': 'str'} } + +## +# @QMPBadInputObjectMember +# +# Since: 0.14 +## +{ 'error': 'QMPBadInputObjectMember', + 'description': 'QMP input object member \'%(member)\' expects \'%(expected)\'', + 'data': {'member': 'str', 'expected': 'str'} } + +## +# @QMPExtraInputObjectMember +# +# Since: 0.14 +## +{ 'error': 'QMPExtraInputObjectMember', + 'description': 'QMP input object member \'%(member)\' is unexpected', + 'data': {'member': 'str'} } + +## +# @ResetRequired +# +# Since: 1.0 +## +{ 'error': 'ResetRequired', + 'description': 'Resetting the Virtual Machine is required' } + +## +# @SetPasswdFailed +# +# Since: 0.14 +## +{ 'error': 'SetPasswdFailed', + 'description': 'Could not set password' } + +## +# @SockBindFailed +# +# Since: 1.1.0 +## +{ 'error': 'SockBindFailed', + 'description': 'Failed to bind socket' } + +## +# @SockConnectFailed +# +# Since: 1.1.0 +## +{ 'error': 'SockConnectFailed', + 'description': 'Failed to connect to socket' } + +## +# @SockConnectInprogress +# +# Since: 1.1.0 +## +{ 'error': 'SockConnectInprogress', + 'description': 'Connection can not be completed immediately' } + +## +# @SockCreateFailed +# +# Since: 1.1.0 +## +{ 'error': 'SockCreateFailed', + 'description': 'Failed to create socket' } + +## +# @SockListenFailed +# +# Since: 1.1.0 +## +{ 'error': 'SockListenFailed', + 'description': 'Failed to set socket to listening mode' } + +## +# @TooManyFiles +# +# Since: 0.14 +## +{ 'error': 'TooManyFiles', + 'description': 'Too many open files' } + +## +# @UndefinedError +# +# Since: 0.14 +## +{ 'error': 'UndefinedError', + 'description': 'An undefined error has occurred' } + +## +# @UnknownBlockFormatFeature +# +# Since: 0.14 +## +{ 'error': 'UnknownBlockFormatFeature', + 'description': '\'%(device)\' uses a %(format) feature which is not supported by this qemu version: %(feature)', + 'data': {'device': 'str', 'format': 'str', 'feature': 'str'} } + +## +# @Unsupported +# +# Since: 0.15 +## +{ 'error': 'Unsupported', + 'description': 'this feature or command is not currently supported' } + +## +# @VirtFSFeatureBlocksMigration +# +# Since: 1.0.1 +## +{ 'error': 'VirtFSFeatureBlocksMigration', + 'description': 'Migration is disabled when VirtFS export path \'%(path)\' is mounted in the guest using mount_tag \'%(tag)\'', + 'data': {'path': 'str', 'tag': 'str'} } + +## +# @VNCServerFailed +# +# Since: 0.14 +## +{ 'error': 'VNCServerFailed', + 'description': 'Could not start VNC server on %(target)', + 'data': {'target': 'str'} }
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 7/9 qapi: add qapi-errors.py
In reply to Luiz CapitulinoThis script generates two files from qapi-schema-errors.json:
o qapi-errors.h: contains error macro definitions, eg. QERR_BASE_NOT_FOUND, corresponds to most of today's qerror.h
o qapi-errors.c: contains the error table that currently exists in qerror.c
The script is not used yet though, that's going to be done by the next commit.
--- Makefile | 8 ++- scripts/qapi-errors.py | 180 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 scripts/qapi-errors.py
Makefile +6 -2
@@ -22,8 +22,9 @@ GENERATED_HEADERS = config-host.h trace.h qemu-options.def ifeq ($(TRACE_BACKEND),dtrace) GENERATED_HEADERS += trace-dtrace.h endif -GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h -GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c trace.c +GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-errors.h +GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-errors.c \ + trace.c # Don't try to regenerate Makefile or configure # We don't generate any of them
@@ -200,6 +201,9 @@ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py qmp-commands.h qmp-marshal.c :\ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") +qapi-errors.h qapi-errors.c :\ +$(SRC_PATH)/qapi-schema-errors.json $(SRC_PATH)/scripts/qapi-errors.py + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-errors.py -o "." < $<, " GEN $@") QGALIB_OBJ=$(addprefix qapi-generated/, qga-qapi-types.o qga-qapi-visit.o qga-qmp-marshal.o) QGALIB_GEN=$(addprefix qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
scripts/qapi-errors.py new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 8/9 qerror: switch to qapi generated error macros and table
In reply to Luiz CapitulinoPrevious commits added qapi infrastructure to automatically generate qerror macros and the qerror table from qapi-schema-errors.json.
This commit drops the current error macros from qerror.h and the error table from qerror.c and use the generated ones instead.
Please, note that qapi-error.c is actually _included_ by qerror.c. This is hacky, but the alternative is to make the table private to qapi-error.c and generate functions to return table entries. I think that doesn't pay much off.
--- qerror.c | 310 +-------------------------------------------------------------- qerror.h | 220 +-------------------------------------------- 2 files changed, 2 insertions(+), 528 deletions(-)
qerror.c +1 -309
@@ -14,6 +14,7 @@#include "qjson.h" #include "qerror.h" #include "qemu-common.h" +#include "qapi-errors.c" static void qerror_destroy_obj (QObject *obj);
@@ -23,315 +24,6 @@ static const QType qerror_type = { };/** -* The 'desc' parameter is a printf-like string, the format of the format -* string is: -* -* %(KEY) -* -* Where KEY is a QDict key, which has to be passed to qerror_from_info(). -* -* Example: -* -* "foo error on device: %(device) slot: %(slot_nr)" -* -* A single percent sign can be printed if followed by a second one, -* for example: -* -* "running out of foo: %(foo)%%" -* -* Please keep the entries in alphabetical order. -* Use scripts/check-qerror.sh to check. -*/ -static const QErrorStringTable qerror_table[] = { - { - .error_fmt =QERR_ADD_CLIENT_FAILED , - .desc ="Could not add client" , - }, - { - .error_fmt =QERR_AMBIGUOUS_PATH , - .desc ="Path '%(path)' does not uniquely identify a %(object)" - }, - { - .error_fmt =QERR_BAD_BUS_FOR_DEVICE , - .desc ="Device '%(device)' can't go on a %(bad_bus_type) bus" , - }, - { - .error_fmt =QERR_BASE_NOT_FOUND , - .desc ="Base '%(base)' not found" , - }, - { - .error_fmt =QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , - .desc ="Block format '%(format)' used by device '%(name)' does not support feature '%(feature)'" , - }, - { - .error_fmt =QERR_BUS_NO_HOTPLUG , - .desc ="Bus '%(bus)' does not support hotplugging" , - }, - { - .error_fmt =QERR_BUS_NOT_FOUND , - .desc ="Bus '%(bus)' not found" , - }, - { - .error_fmt =QERR_COMMAND_DISABLED , - .desc ="The command %(name) has been disabled for this instance" , - }, - { - .error_fmt =QERR_COMMAND_NOT_FOUND , - .desc ="The command %(name) has not been found" , - }, - { - .error_fmt =QERR_DEVICE_ENCRYPTED , - .desc ="Device '%(device)' is encrypted" , - }, - { - .error_fmt =QERR_DEVICE_FEATURE_BLOCKS_MIGRATION , - .desc ="Migration is disabled when using feature '%(feature)' in device '%(device)'" , - }, - { - .error_fmt =QERR_DEVICE_HAS_NO_MEDIUM , - .desc ="Device '%(device)' has no medium" , - }, - { - .error_fmt =QERR_DEVICE_INIT_FAILED , - .desc ="Device '%(device)' could not be initialized" , - }, - { - .error_fmt =QERR_DEVICE_IN_USE , - .desc ="Device '%(device)' is in use" , - }, - { - .error_fmt =QERR_DEVICE_IS_READ_ONLY , - .desc ="Device '%(device)' is read only" , - }, - { - .error_fmt =QERR_DEVICE_LOCKED , - .desc ="Device '%(device)' is locked" , - }, - { - .error_fmt =QERR_DEVICE_MULTIPLE_BUSSES , - .desc ="Device '%(device)' has multiple child busses" , - }, - { - .error_fmt =QERR_DEVICE_NO_BUS , - .desc ="Device '%(device)' has no child bus" , - }, - { - .error_fmt =QERR_DEVICE_NO_HOTPLUG , - .desc ="Device '%(device)' does not support hotplugging" , - }, - { - .error_fmt =QERR_DEVICE_NOT_ACTIVE , - .desc ="Device '%(device)' has not been activated" , - }, - { - .error_fmt =QERR_DEVICE_NOT_ENCRYPTED , - .desc ="Device '%(device)' is not encrypted" , - }, - { - .error_fmt =QERR_DEVICE_NOT_FOUND , - .desc ="Device '%(device)' not found" , - }, - { - .error_fmt =QERR_DEVICE_NOT_REMOVABLE , - .desc ="Device '%(device)' is not removable" , - }, - { - .error_fmt =QERR_DUPLICATE_ID , - .desc ="Duplicate ID '%(id)' for %(object)" , - }, - { - .error_fmt =QERR_FD_NOT_FOUND , - .desc ="File descriptor named '%(name)' not found" , - }, - { - .error_fmt =QERR_FD_NOT_SUPPLIED , - .desc ="No file descriptor supplied via SCM_RIGHTS" , - }, - { - .error_fmt =QERR_FEATURE_DISABLED , - .desc ="The feature '%(name)' is not enabled" , - }, - { - .error_fmt =QERR_INVALID_BLOCK_FORMAT , - .desc ="Invalid block format '%(name)'" , - }, - { - .error_fmt =QERR_INVALID_OPTION_GROUP , - .desc ="There is no option group '%(group)'" , - }, - { - .error_fmt =QERR_INVALID_PARAMETER , - .desc ="Invalid parameter '%(name)'" , - }, - { - .error_fmt =QERR_INVALID_PARAMETER_COMBINATION , - .desc ="Invalid parameter combination" , - }, - { - .error_fmt =QERR_INVALID_PARAMETER_TYPE , - .desc ="Invalid parameter type for '%(name)', expected: %(expected)" , - }, - { - .error_fmt =QERR_INVALID_PARAMETER_VALUE , - .desc ="Parameter '%(name)' expects %(expected)" , - }, - { - .error_fmt =QERR_INVALID_PASSWORD , - .desc ="Password incorrect" , - }, - { - .error_fmt =QERR_IO_ERROR , - .desc ="An IO error has occurred" , - }, - { - .error_fmt =QERR_JSON_PARSE_ERROR , - .desc ="JSON parse error, %(message)" , - - }, - { - .error_fmt =QERR_JSON_PARSING , - .desc ="Invalid JSON syntax" , - }, - { - .error_fmt =QERR_KVM_MISSING_CAP , - .desc ="Using KVM without %(capability), %(feature) unavailable" , - }, - { - .error_fmt =QERR_MIGRATION_ACTIVE , - .desc ="There's a migration process in progress" , - }, - { - .error_fmt =QERR_MIGRATION_NOT_SUPPORTED , - .desc ="State blocked by non-migratable device '%(device)'" , - }, - { - .error_fmt =QERR_MIGRATION_EXPECTED , - .desc ="An incoming migration is expected before this command can be executed" , - }, - { - .error_fmt =QERR_MISSING_PARAMETER , - .desc ="Parameter '%(name)' is missing" , - }, - { - .error_fmt =QERR_NO_BUS_FOR_DEVICE , - .desc ="No '%(bus)' bus found for device '%(device)'" , - }, - { - .error_fmt =QERR_NOT_SUPPORTED , - .desc ="Not supported" , - }, - { - .error_fmt =QERR_OPEN_FILE_FAILED , - .desc ="Could not open '%(filename)'" , - }, - { - .error_fmt =QERR_PERMISSION_DENIED , - .desc ="Insufficient permission to perform this operation" , - }, - { - .error_fmt =QERR_PROPERTY_NOT_FOUND , - .desc ="Property '%(device).%(property)' not found" , - }, - { - .error_fmt =QERR_PROPERTY_VALUE_BAD , - .desc ="Property '%(device).%(property)' doesn't take value '%(value)'" , - }, - { - .error_fmt =QERR_PROPERTY_VALUE_IN_USE , - .desc ="Property '%(device).%(property)' can't take value '%(value)', it's in use" , - }, - { - .error_fmt =QERR_PROPERTY_VALUE_NOT_FOUND , - .desc ="Property '%(device).%(property)' can't find value '%(value)'" , - }, - { - .error_fmt =QERR_PROPERTY_VALUE_NOT_POWER_OF2 , - .desc ="Property '%(device).%(property)' doesn't take " -"value '%(value)', it's not a power of 2" , - }, - { - .error_fmt =QERR_PROPERTY_VALUE_OUT_OF_RANGE , - .desc ="Property '%(device).%(property)' doesn't take " -"value %(value) (minimum: %(min), maximum: %(max))" , - }, - { - .error_fmt =QERR_QGA_COMMAND_FAILED , - .desc ="Guest agent command failed, error was '%(message)'" , - }, - { - .error_fmt =QERR_QGA_LOGGING_FAILED , - .desc ="Guest agent failed to log non-optional log statement" , - }, - { - .error_fmt =QERR_QMP_BAD_INPUT_OBJECT , - .desc ="Expected '%(expected)' in QMP input" , - }, - { - .error_fmt =QERR_QMP_BAD_INPUT_OBJECT_MEMBER , - .desc ="QMP input object member '%(member)' expects '%(expected)'" , - }, - { - .error_fmt =QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER , - .desc ="QMP input object member '%(member)' is unexpected" , - }, - { - .error_fmt =QERR_RESET_REQUIRED , - .desc ="Resetting the Virtual Machine is required" , - }, - { - .error_fmt =QERR_SET_PASSWD_FAILED , - .desc ="Could not set password" , - }, - { - .error_fmt =QERR_TOO_MANY_FILES , - .desc ="Too many open files" , - }, - { - .error_fmt =QERR_UNDEFINED_ERROR , - .desc ="An undefined error has occurred" , - }, - { - .error_fmt =QERR_UNKNOWN_BLOCK_FORMAT_FEATURE , - .desc ="'%(device)' uses a %(format) feature which is not " -"supported by this qemu version: %(feature)" , - }, - { - .error_fmt =QERR_UNSUPPORTED , - .desc ="this feature or command is not currently supported" , - }, - { - .error_fmt =QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION , - .desc ="Migration is disabled when VirtFS export path '%(path)' " -"is mounted in the guest using mount_tag '%(tag)'" , - }, - { - .error_fmt =QERR_VNC_SERVER_FAILED , - .desc ="Could not start VNC server on %(target)" , - }, - { - .error_fmt =QERR_SOCK_CONNECT_INPROGRESS , - .desc ="Connection can not be completed immediately" , - }, - { - .error_fmt =QERR_SOCK_CONNECT_FAILED , - .desc ="Failed to connect to socket" , - }, - { - .error_fmt =QERR_SOCK_LISTEN_FAILED , - .desc ="Failed to set socket to listening mode" , - }, - { - .error_fmt =QERR_SOCK_BIND_FAILED , - .desc ="Failed to bind socket" , - }, - { - .error_fmt =QERR_SOCK_CREATE_FAILED , - .desc ="Failed to create socket" , - }, - {} -}; - -/** * qerror_new(): Create a new QError * * Return strong reference.
qerror.h +1 -219
230 lines not on this page · raw message
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 9/9 scripts: update check-qerror.sh
In reply to Luiz CapitulinoThe qerror.h file doesn't contain the macros anymore, the script should check qapi-schema-errors.json instead.
--- scripts/check-qerror.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
scripts/check-qerror.sh +2 -4
@@ -16,7 +16,5 @@ check_order() { return 0 } -check_order 'Definitions in qerror.h must be in alphabetical order:' \ - grep '^#define QERR_' qerror.h -check_order 'Entries in qerror.c:qerror_table must be in alphabetical order:' \ - sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c +check_order 'Definitions must be in alphabetical order:' \ + grep '^# @' qapi-schema-errors.json
Signature · 1 line
1.7.11.2.249.g31c7954.dirty