: add printf-like human msg to error_set()
cover : add printf-like human msg to error_set()
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
to:
error_set(errp, QERR_DEVICE_NOT_FOUND,
"Device 'device=%s' not found", device);
In the first call, QERR_DEVICE_NOT_FOUND is a string containing a json dict:
"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"error_set() then uses that string and the 'device' argument to build the error object, which is a QDict. The human error message is fixed, and exists in the qerror_table[] array. That array is indexed, and the human error message is added to the error object.
In the new way, QERR_DEVICE_NOT_FOUND is an enumeration value and the human error message is passed as an argument. qerror_table[] is gone. The error object is built by using QERR_DEVICE_NOT_FOUND as an index for a table containing all those json dict strings (this can, and probably will, be eliminated, as the QMP code can generate its error object from the Error object).
An important detail is that, the error object data member is constructed by parsing the human message string and looking for name=value pairs. If a required data member (like 'device' above) is not found in the human message, a default value is used ('unknown' for strings and 0 for integers).
This series unlocks several possible simplification, like moving from:
struct Error
{
QDict *obj;
const char *fmt;
char *msg;
};to:
struct Error
{
ErrClass err_class;
char *msg;
};But I haven't done it all yet.
Please, check individual patches for more details.
balloon.c | 10 +- block.c | 4 +- block/cow.c | 3 +- block/qcow.c | 7 +- block/qcow2.c | 3 +- block/qed.c | 3 +- block/stream.c | 2 +- block/vdi.c | 4 +- block/vmdk.c | 4 +- block/vpc.c | 4 +- block/vvfat.c | 4 +- blockdev.c | 79 +++++++------- configure | 10 -- cpus.c | 13 ++- dump-stub.c | 2 +- dump.c | 18 ++-- error.c | 45 ++------ error.h | 5 +- hmp.c | 2 +- hw/9pfs/virtio-9p.c | 3 +- hw/ivshmem.c | 2 +- hw/pci-stub.c | 2 +- hw/pci.c | 4 +- hw/qdev-addr.c | 6 +- hw/qdev-monitor.c | 26 +++-- hw/qdev-properties.c | 49 ++++----- hw/qdev.c | 6 +- hw/usb/bus.c | 3 +- hw/usb/hcd-ehci.c | 6 +- hw/usb/redirect.c | 5 +- json-parser.c | 2 +- migration.c | 6 +- monitor.c | 127 +++++------------------ net.c | 20 ++-- qapi/qapi-visit-core.c | 22 ++-- qapi/qmp-dispatch.c | 14 ++- qapi/qmp-input-visitor.c | 22 ++-- qapi/string-input-visitor.c | 12 +-- qemu-config.c | 2 +- qemu-ga.c | 4 +- qemu-option.c | 20 ++-- qemu-sockets.c | 22 ++-- qerror.c | 243 ++++++++++++++------------------------------ qerror.h | 22 +--- qga/commands-posix.c | 78 +++++++------- qga/commands-win32.c | 53 ++++------ qmp.c | 47 +++++---- qom/object.c | 20 ++-- savevm.c | 6 +- scripts/qapi-errors.py | 80 ++++++++------- target-i386/cpu.c | 15 +-- ui/vnc.c | 4 +- 52 files changed, 450 insertions(+), 725 deletions(-)
PATCH 1/14 monitor: drop unused monitor debug code
In the old QMP days, this code was used to find out QMP commands that might be calling monitor_printf() down its call chain.
This is almost impossible to happen today, because the qapi converted commands don't even have a monitor object. Besides, it's been more than a year since I used this last time.
Let's just drop it.
--- configure | 10 ---------- monitor.c | 62 -------------------------------------------------------------- 2 files changed, 72 deletions(-)
configure +0 -10
@@ -147,7 +147,6 @@ vhost_net="no" kvm="no" gprof="no" debug_tcg="no" -debug_mon="no" debug="no" strip_opt="yes" tcg_interpreter="no"
@@ -633,14 +632,9 @@ for opt do ;; --disable-debug-tcg) debug_tcg="no" ;; - --enable-debug-mon) debug_mon="yes" - ;; - --disable-debug-mon) debug_mon="no" - ;; --enable-debug) # Enable debugging options that aren't excessively noisy debug_tcg="yes" - debug_mon="yes" debug="yes" strip_opt="no" ;;
@@ -3007,7 +3001,6 @@ echo "host CPU $cpu" echo "host big endian $bigendian" echo "target list $target_list" echo "tcg debug enabled $debug_tcg" -echo "Mon debug enabled $debug_mon" echo "gprof enabled $gprof" echo "sparse enabled $sparse" echo "strip binaries $strip_opt"
@@ -3100,9 +3093,6 @@ echo "ARCH=$ARCH" >> $config_host_mak if test "$debug_tcg" = "yes" ; then echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak fi -if test "$debug_mon" = "yes" ; then - echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak -fi if test "$debug" = "yes" ; then echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak fi
monitor.c +0 -62
93 lines not on this page · raw message
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 2/14 qerror: reduce public exposure
In reply to Luiz CapitulinoMake functions only used in qerror.c static.
--- qerror.c | 10 +++++----- qerror.h | 5 ----- 2 files changed, 5 insertions(+), 10 deletions(-)
qerror.c +5 -5
@@ -28,7 +28,7 @@ static const QType qerror_type = {* * Return strong reference. */ -QError *qerror_new (void ) +static QError *qerror_new (void ) {QError *qerr;
@@ -116,8 +116,8 @@ static void qerror_set_desc(QError *qerr, const char *fmt)* * Return strong reference. */ -QError *qerror_from_info (const char *file,int linenr,const char *func, -const char *fmt,va_list *va) +static QError *qerror_from_info (const char *file,int linenr,const char *func, +const char *fmt,va_list *va) {QError *qerr;
@@ -241,7 +241,7 @@ QString *qerror_human(const QError *qerror)* it uses error_report() for this, so that the output is routed to the right * place (ie. stderr or Monitor's device). */ -void qerror_print (QError *qerror) +static void qerror_print (QError *qerror) {QString *qstring =qerror_human (qerror);loc_push_restore (&qerror->loc);
@@ -312,7 +312,7 @@ void assert_no_error(Error *err)/** * qobject_to_qerror(): Convert a QObject into a QError */ -QError *qobject_to_qerror (const QObject *obj) +static QError *qobject_to_qerror (const QObject *obj) {if (qobject_type (obj) !=QTYPE_QERROR ) {return NULL ;
qerror.h +0 -5
@@ -34,11 +34,7 @@ typedef struct QError {const QErrorStringTable *entry; } QError; -QError *qerror_new (void ); -QError *qerror_from_info (const char *file,int linenr,const char *func, -const char *fmt,va_list *va)GCC_FMT_ATTR (4 ,0 );QString *qerror_human (const QError *qerror); -void qerror_print (QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func, const char *fmt, ...) GCC_FMT_ATTR(4, 5);void qerror_report_err (Error *err);
@@ -46,6 +42,5 @@ void assert_no_error(Error *err);QString *qerror_format (const char *fmt,QDict *error);#define qerror_report (fmt, ...) \ qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) -QError *qobject_to_qerror (const QObject *obj);#endif /* QERROR_H */
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 3/14 qerror: drop qerror_abort()
In reply to Luiz CapitulinoPreviously, developers had to create error dicts manually and also enter the matching desc table entry. Thus, qerro_abort() was added to help catching bad error dicts.
Today, all that stuff is generated automatically which makes the chance of a bad generated dict quite low.
Also, qerror_abort() would... _abort_ on a bad error dict!
This commit maintains the same verification logic on the error object but drops the abort() in favor of reporting UndefinedError for bad dicts (and also print a debug message to stderr).
--- qerror.c | 83 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 37 deletions(-)
qerror.c +46 -37
@@ -38,55 +38,50 @@ static QError *qerror_new(void)return qerr; } -static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, - const char *fmt, ...) -{ -va_list ap; - -fprintf (stderr,"qerror: bad call in function '%s':\n" , qerr->func); -fprintf (stderr,"qerror: -> " ); - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -va_end (ap); - -fprintf (stderr,"\nqerror: call at %s:%d\n" , qerr->file, qerr->linenr); -abort (); -} - -static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, - const char *fmt, va_list *va) +static QDict *error_object_from_fmt (const char *fmt,va_list *va) {QObject *obj; +QDict *ret; obj =qobject_from_jsonv (fmt, va);if (!obj) { -qerror_abort (qerr,"invalid format '%s'" , fmt); +fprintf (stderr,"invalid json in error dict '%s'\n" , fmt); +return NULL ; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"error format is not a QDict '%s'" , fmt); +fprintf (stderr,"error is not a dict '%s'\n" , fmt); + goto out_free; } - qerr->error =qobject_to_qdict (obj); - - obj =qdict_get (qerr->error,"class" ); + ret =qobject_to_qdict (obj); + obj =qdict_get (ret,"class" );if (!obj) { -qerror_abort (qerr,"missing 'class' key in '%s'" , fmt); +fprintf (stderr,"missing 'class' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QSTRING ) { -qerror_abort (qerr,"'class' key value should be a QString" ); +fprintf (stderr,"'class' key value should be a string in '%s'\n" , fmt); + goto out_free; } - - obj =qdict_get (qerr->error,"data" ); + + obj =qdict_get (ret,"data" );if (!obj) { -qerror_abort (qerr,"missing 'data' key in '%s'" , fmt); +fprintf (stderr,"missing 'data' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"'data' key value should be a QDICT" ); +fprintf (stderr,"'data' key value should be a dict in '%s'\n" , fmt); + goto out_free; } + +return ret; + +out_free: +qobject_decref (obj); +return NULL ; } -static void qerror_set_desc (QError *qerr,const char *fmt) +static const QErrorStringTable *error_get_desc (const char *fmt) {int i;
@@ -94,12 +89,17 @@ static void qerror_set_desc(QError *qerr, const char *fmt)for (i =0 ; qerror_table[i].error_fmt; i++) {if (strcmp (qerror_table[i].error_fmt, fmt) ==0 ) { - qerr->entry = &qerror_table[i]; -return ; +return &qerror_table[i]; } } -qerror_abort (qerr,"error format '%s' not found" , fmt); +fprintf (stderr,"error format '%s' not found\n" , fmt); +return NULL ; +} + +static QDict *build_error_no_arg (const char *fmt) +{ +return qobject_to_qdict (qobject_from_jsonv (fmt,NULL )); }/**
@@ -127,13 +127,22 @@ static QError *qerror_from_info(const char *file, int linenr, const char *func, qerr->file = file; qerr->func = func; -if (!fmt) { -qerror_abort (qerr,"QDict not specified" ); + qerr->error =error_object_from_fmt (fmt, va); +if (!qerr->error) { + goto bad_err; + } + + qerr->entry =error_get_desc (fmt); +if (!qerr->entry) { +QDECREF (qerr->error); + goto bad_err; } -qerror_set_data (qerr, fmt, va); -qerror_set_desc (qerr, fmt); +return qerr; +bad_err: + qerr->error =build_error_no_arg (QERR_UNDEFINED_ERROR ); + qerr->entry =error_get_desc (QERR_UNDEFINED_ERROR );return qerr; }
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
Re: [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort()
Quoted 2 lines · Luiz Capitulino
Previously, developers had to create error dicts manually and also enter the matching desc table entry. Thus,
qerro_abort()was added to help
s/qerro_/qerror_/
Quoted 4 lines
catching bad error dicts.
Today, all that stuff is generated automatically which makes the chance of a bad generated dict quite low.
The generator can only generate well-formed dicts, right?
Quoted 1 line
Also,
qerror_abort()would... _abort_ on a bad error dict!
In my opinion, it's perfectly fine to abort on a programming error.
Quoted 3 lines
This commit maintains the same verification logic on the error object but drops the
abort()in favor of reporting UndefinedError for bad dicts (and also print a debug message to stderr).
I certainly won't object to your elaborate handling, but me, I'd simply replace qerror_abort() by straight abort() and be done with it *shrug*
Quoted 124 lines
Signed-off-by Luiz Capitulino <[email protected]>--- qerror.c | 83 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 37 deletions(-)qerror.c +40
-35@@ -38,55 +38,50 @@ static QError *qerror_new(void)return qerr; } -static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, - const char *fmt, ...) -{ -va_list ap; - -fprintf (stderr,"qerror: bad call in function '%s':\n" , qerr->func); -fprintf (stderr,"qerror: -> " ); - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -va_end (ap); - -fprintf (stderr,"\nqerror: call at %s:%d\n" , qerr->file, qerr->linenr); -abort (); -} - -static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, - const char *fmt, va_list *va) +static QDict *error_object_from_fmt (const char *fmt,va_list *va) {QObject *obj; +QDict *ret; obj =qobject_from_jsonv (fmt, va);if (!obj) { -qerror_abort (qerr,"invalid format '%s'" , fmt); +fprintf (stderr,"invalid json in error dict '%s'\n" , fmt); +return NULL ; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"error format is not a QDict '%s'" , fmt); +fprintf (stderr,"error is not a dict '%s'\n" , fmt); + goto out_free; } - qerr->error =qobject_to_qdict (obj); - - obj =qdict_get (qerr->error,"class" ); + ret =qobject_to_qdict (obj); + obj =qdict_get (ret,"class" );if (!obj) { -qerror_abort (qerr,"missing 'class' key in '%s'" , fmt); +fprintf (stderr,"missing 'class' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QSTRING ) { -qerror_abort (qerr,"'class' key value should be a QString" ); +fprintf (stderr,"'class' key value should be a string in '%s'\n" , fmt); + goto out_free; } - - obj =qdict_get (qerr->error,"data" ); + + obj =qdict_get (ret,"data" );if (!obj) { -qerror_abort (qerr,"missing 'data' key in '%s'" , fmt); +fprintf (stderr,"missing 'data' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"'data' key value should be a QDICT" ); +fprintf (stderr,"'data' key value should be a dict in '%s'\n" , fmt); + goto out_free; } + +return ret; + +out_free: +qobject_decref (obj); +return NULL ; } -static void qerror_set_desc (QError *qerr,const char *fmt) +static const QErrorStringTable *error_get_desc (const char *fmt) {int i;@@ -94,12 +89,17 @@ static void qerror_set_desc(QError *qerr, const char *fmt)for (i =0 ; qerror_table[i].error_fmt; i++) {if (strcmp (qerror_table[i].error_fmt, fmt) ==0 ) { - qerr->entry = &qerror_table[i]; -return ; +return &qerror_table[i]; } } -qerror_abort (qerr,"error format '%s' not found" , fmt); +fprintf (stderr,"error format '%s' not found\n" , fmt); +return NULL ; +} + +static QDict *build_error_no_arg (const char *fmt) +{ +return qobject_to_qdict (qobject_from_jsonv (fmt,NULL )); }/** @@ -127,13 +127,22 @@ static QError *qerror_from_info(const char *file, int linenr, const char *func, qerr->file = file; qerr->func = func; -if (!fmt) { -qerror_abort (qerr,"QDict not specified" ); + qerr->error =error_object_from_fmt (fmt, va); +if (!qerr->error) { + goto bad_err; + } + + qerr->entry =error_get_desc (fmt); +if (!qerr->entry) {
qerror.c static QError *qerror_from_info(const char *file, int linenr, const char *func, · line 144
Quoted 10 lines
qerror.c +5
-2+QDECREF (qerr->error); + goto bad_err; } -qerror_set_data (qerr, fmt, va); -qerror_set_desc (qerr, fmt); +return qerr; +bad_err: + qerr->error =build_error_no_arg (QERR_UNDEFINED_ERROR );
Nit: defeats gcc's format checking. This shouldn't:
qerr->error = qobject_to_qdict(qobject_from_json(QERR_UNDEFINED_ERROR));
Quoted 3 lines
qerror.c +1
-0+ qerr->entry =error_get_desc (QERR_UNDEFINED_ERROR );return qerr; }
Re: [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort()
Quoted 5 lines · On Thu, 26 Jul 2012 14:33:23 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 2 lines · Luiz Capitulino
Previously, developers had to create error dicts manually and also enter the matching desc table entry. Thus,
qerro_abort()was added to help
Quoted 8 lines
s/qerro_/qerror_/
Quoted 4 lines
catching bad error dicts.
Today, all that stuff is generated automatically which makes the chance of a bad generated dict quite low.
The generator can only generate well-formed dicts, right?
I didn't say that. I said the chances of generating a bad dict is low, specially in production.
Quoted 4 lines
Quoted 2 lines
Also,
qerror_abort()would... _abort_ on a bad error dict!In my opinion, it's perfectly fine to abort on a programming error.
In this case it's quite easy to recover, so why should we abort?
Quoted 7 lines
Quoted 4 lines
This commit maintains the same verification logic on the error object but drops the
abort()in favor of reporting UndefinedError for bad dicts (and also print a debug message to stderr).I certainly won't object to your elaborate handling, but me, I'd simply replace
qerror_abort()by straightabort()and be done with it *shrug*
Well, honestly speaking, I did this while I was re-reading that code and I ended up dropping it down this series (remember this is an RFC) :)
But I think I'll add it back for v1.
Quoted 144 lines
Quoted 125 lines
Signed-off-by Luiz Capitulino <[email protected]>--- qerror.c | 83 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 37 deletions(-)qerror.c +40
-35@@ -38,55 +38,50 @@ static QError *qerror_new(void)return qerr; } -static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, - const char *fmt, ...) -{ -va_list ap; - -fprintf (stderr,"qerror: bad call in function '%s':\n" , qerr->func); -fprintf (stderr,"qerror: -> " ); - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -va_end (ap); - -fprintf (stderr,"\nqerror: call at %s:%d\n" , qerr->file, qerr->linenr); -abort (); -} - -static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, - const char *fmt, va_list *va) +static QDict *error_object_from_fmt (const char *fmt,va_list *va) {QObject *obj; +QDict *ret; obj =qobject_from_jsonv (fmt, va);if (!obj) { -qerror_abort (qerr,"invalid format '%s'" , fmt); +fprintf (stderr,"invalid json in error dict '%s'\n" , fmt); +return NULL ; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"error format is not a QDict '%s'" , fmt); +fprintf (stderr,"error is not a dict '%s'\n" , fmt); + goto out_free; } - qerr->error =qobject_to_qdict (obj); - - obj =qdict_get (qerr->error,"class" ); + ret =qobject_to_qdict (obj); + obj =qdict_get (ret,"class" );if (!obj) { -qerror_abort (qerr,"missing 'class' key in '%s'" , fmt); +fprintf (stderr,"missing 'class' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QSTRING ) { -qerror_abort (qerr,"'class' key value should be a QString" ); +fprintf (stderr,"'class' key value should be a string in '%s'\n" , fmt); + goto out_free; } - - obj =qdict_get (qerr->error,"data" ); + + obj =qdict_get (ret,"data" );if (!obj) { -qerror_abort (qerr,"missing 'data' key in '%s'" , fmt); +fprintf (stderr,"missing 'data' key in '%s'\n" , fmt); + goto out_free; }if (qobject_type (obj) !=QTYPE_QDICT ) { -qerror_abort (qerr,"'data' key value should be a QDICT" ); +fprintf (stderr,"'data' key value should be a dict in '%s'\n" , fmt); + goto out_free; } + +return ret; + +out_free: +qobject_decref (obj); +return NULL ; } -static void qerror_set_desc (QError *qerr,const char *fmt) +static const QErrorStringTable *error_get_desc (const char *fmt) {int i;@@ -94,12 +89,17 @@ static void qerror_set_desc(QError *qerr, const char *fmt)for (i =0 ; qerror_table[i].error_fmt; i++) {if (strcmp (qerror_table[i].error_fmt, fmt) ==0 ) { - qerr->entry = &qerror_table[i]; -return ; +return &qerror_table[i]; } } -qerror_abort (qerr,"error format '%s' not found" , fmt); +fprintf (stderr,"error format '%s' not found\n" , fmt); +return NULL ; +} + +static QDict *build_error_no_arg (const char *fmt) +{ +return qobject_to_qdict (qobject_from_jsonv (fmt,NULL )); }/** @@ -127,13 +127,22 @@ static QError *qerror_from_info(const char *file, int linenr, const char *func, qerr->file = file; qerr->func = func; -if (!fmt) { -qerror_abort (qerr,"QDict not specified" ); + qerr->error =error_object_from_fmt (fmt, va); +if (!qerr->error) { + goto bad_err; + } + + qerr->entry =error_get_desc (fmt); +if (!qerr->entry) {qerror.c static QError *qerror_from_info(const char *file, int linenr, const char *func, · line 144
Quoted 10 lines
qerror.c +5
-2+QDECREF (qerr->error); + goto bad_err; } -qerror_set_data (qerr, fmt, va); -qerror_set_desc (qerr, fmt); +return qerr; +bad_err: + qerr->error =build_error_no_arg (QERR_UNDEFINED_ERROR );Nit: defeats gcc's format checking. This shouldn't:
qerr->error = qobject_to_qdict(qobject_from_json(QERR_UNDEFINED_ERROR));Quoted 3 lines
qerror.c +1
-0+ qerr->entry =error_get_desc (QERR_UNDEFINED_ERROR );return qerr; }
Re: [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort()
In reply to Luiz CapitulinoQuoted 2 lines · Luiz Capitulino
Previously, developers had to create error dicts manually and also enter the matching desc table entry. Thus,
qerro_abort()was added to help
s/qerro_/qerror_/
Quoted 13 lines
catching bad error dicts.
Today, all that stuff is generated automatically which makes the chance of a bad generated dict quite low.
Also,
qerror_abort()would... _abort_ on a bad error dict!This commit maintains the same verification logic on the error object but drops the
abort()in favor of reporting UndefinedError for bad dicts (and also print a debug message to stderr).Signed-off-by Luiz Capitulino <[email protected]>---
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 4/14 qerror: drop qerror_report_internal()
In reply to Luiz CapitulinoIt's not needed anymore and conflicts with future error improvements.
Also drops related error information, that is, the file where the error ocurred, the line number and function. This has never been fully used.
--- qerror.c | 20 +++----------------- qerror.h | 8 +------- 2 files changed, 4 insertions(+), 24 deletions(-)
qerror.c +3 -17
@@ -105,27 +105,14 @@ static QDict *build_error_no_arg(const char *fmt)/** * qerror_from_info(): Create a new QError from error information * -* The information consists of: -* -* - file the file name of where the error occurred -* - linenr the line number of where the error occurred -* - func the function name of where the error occurred -* - fmt JSON printf-like dictionary, there must exist keys 'class' and -* 'data' -* - va va_list of all arguments specified by fmt -* * Return strong reference. */ -static QError *qerror_from_info (const char *file,int linenr,const char *func, -const char *fmt,va_list *va) +static QError *qerror_from_info (const char *fmt,va_list *va) {QError *qerr; qerr =qerror_new ();loc_save (&qerr->loc); - qerr->linenr = linenr; - qerr->file = file; - qerr->func = func; qerr->error =error_object_from_fmt (fmt, va);if (!qerr->error) {
@@ -259,14 +246,13 @@ static void qerror_print(QError *qerror)QDECREF (qstring); } -void qerror_report_internal (const char *file,int linenr,const char *func, -const char *fmt, ...) +void qerror_report (const char *fmt, ...) {va_list va;QError *qerror;va_start (va, fmt); - qerror =qerror_from_info (file, linenr, func, fmt, &va); + qerror =qerror_from_info (fmt, &va);va_end (va);if (monitor_cur_is_qmp ()) {
qerror.h +1 -7
@@ -28,19 +28,13 @@ typedef struct QError { QObject_HEAD;QDict *error;Location loc; -int linenr; -const char *file; -const char *func;const QErrorStringTable *entry; } QError;QString *qerror_human (const QError *qerror); -void qerror_report_internal(const char *file, int linenr, const char *func, - const char *fmt, ...) GCC_FMT_ATTR(4, 5); +void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void qerror_report_err (Error *err);void assert_no_error (Error *err);QString *qerror_format (const char *fmt,QDict *error); -#define qerror_report (fmt, ...) \ - qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)#endif /* QERROR_H */
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
Re: [Qemu-devel] [PATCH 04/14] qerror: drop qerror_report_internal()
Quoted 4 lines · Luiz Capitulino
It's not needed anymore and conflicts with future error improvements.
Also drops related error information, that is, the file where the error ocurred, the line number and function. This has never been fully used.
Suggest "Subject: qerror: drop file, linenr, func", because that's the interesting part. qerror_report_internal() is merely detail.
PATCH 5/14 qerror: qerror_format(): return an allocated string
In reply to Luiz CapitulinoSimplifies current and future users.
--- error.c | 5 +---- qerror.c | 10 ++++++++-- qerror.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-)
error.c +1 -4
@@ -64,10 +64,7 @@ bool error_is_set(Error **errp)const char *error_get_pretty (Error *err) {if (err->msg ==NULL ) { -QString *str; - str =qerror_format (err->fmt, err->obj); - err->msg =g_strdup (qstring_get_str (str)); -QDECREF (str); + err->msg =qerror_format (err->fmt, err->obj); }return err->msg;
qerror.c +8 -2
@@ -207,9 +207,11 @@ static QString *qerror_format_desc(QDict *error,return qstring; } -QString *qerror_format (const char *fmt,QDict *error) +char *qerror_format (const char *fmt,QDict *error) {const QErrorStringTable *entry =NULL ; +QString *qstr; +char *ret;int i;for (i =0 ; qerror_table[i].error_fmt; i++) {
@@ -219,7 +221,11 @@ QString *qerror_format(const char *fmt, QDict *error) } } -return qerror_format_desc (error, entry); + qstr =qerror_format_desc (error, entry); + ret =g_strdup (qstring_get_str (qstr)); +QDECREF (qstr); + +return ret; }/**
qerror.h +1 -1
@@ -35,6 +35,6 @@ QString *qerror_human(const QError *qerror); void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void qerror_report_err (Error *err);void assert_no_error (Error *err); -QString *qerror_format (const char *fmt,QDict *error); +char *qerror_format (const char *fmt,QDict *error);#endif /* QERROR_H */
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 6/14 qerror: don't delay error message construction
In reply to Luiz CapitulinoToday, the error message is only constructed when it's used. This commit changes that to construct the error message when the error object is built (ie. when the error is reported).
This eliminates the need of storing a pointer to qerror_table[], which will be dropped soon, and also simplifies the code.
--- qerror.c | 34 +++++++--------------------------- qerror.h | 2 +- 2 files changed, 8 insertions(+), 28 deletions(-)
qerror.c +7 -27
@@ -81,22 +81,6 @@ out_free:return NULL ; } -static const QErrorStringTable *error_get_desc (const char *fmt) -{ -int i; - -// FIXME: inefficient loop - -for (i =0 ; qerror_table[i].error_fmt; i++) { -if (strcmp (qerror_table[i].error_fmt, fmt) ==0 ) { -return &qerror_table[i]; - } - } - -fprintf (stderr,"error format '%s' not found\n" , fmt); -return NULL ; -} -static QDict *build_error_no_arg (const char *fmt) {return qobject_to_qdict (qobject_from_jsonv (fmt,NULL ));
@@ -119,8 +103,8 @@ static QError *qerror_from_info(const char *fmt, va_list *va) goto bad_err; } - qerr->entry =error_get_desc (fmt); -if (!qerr->entry) { + qerr->err_msg =qerror_format (fmt, qerr->error); +if (!qerr->err_msg) {QDECREF (qerr->error); goto bad_err; }
@@ -129,7 +113,7 @@ static QError *qerror_from_info(const char *fmt, va_list *va) bad_err: qerr->error =build_error_no_arg (QERR_UNDEFINED_ERROR ); - qerr->entry =error_get_desc (QERR_UNDEFINED_ERROR ); + qerr->err_msg =qerror_format (QERR_UNDEFINED_ERROR , qerr->error);return qerr; }
@@ -233,7 +217,7 @@ char *qerror_format(const char *fmt, QDict *error)*/ QString *qerror_human (const QError *qerror) { -return qerror_format_desc (qerror->error, qerror->entry); +return qstring_from_str (qerror->err_msg); }/**
@@ -280,19 +264,14 @@ struct Errorvoid qerror_report_err (Error *err) {QError *qerr; -int i; qerr =qerror_new ();loc_save (&qerr->loc);QINCREF (err->obj); qerr->error = err->obj; -for (i =0 ; qerror_table[i].error_fmt; i++) { -if (strcmp (qerror_table[i].error_fmt, err->fmt) ==0 ) { - qerr->entry = &qerror_table[i]; -break ; - } - } + qerr->err_msg =qerror_format (err->fmt, qerr->error); +/* FIXME: should report UndefinedError on error */ if (monitor_cur_is_qmp ()) {monitor_set_error (cur_mon, qerr);
@@ -333,5 +312,6 @@ static void qerror_destroy_obj(QObject *obj) qerr =qobject_to_qerror (obj);QDECREF (qerr->error); +g_free (qerr->err_msg);g_free (qerr); }
qerror.h +1 -1
@@ -28,7 +28,7 @@ typedef struct QError { QObject_HEAD;QDict *error;Location loc; -const QErrorStringTable *entry; +char *err_msg; } QError;QString *qerror_human (const QError *qerror);
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 7/14 error: don't delay error message construction
In reply to Luiz CapitulinoToday, the error message is only constructed when it's used. This commit changes that to construct the error message when the error object is built (ie. when the error is reported).
This simplifies the Error object.
--- error.c | 8 +------- qerror.c | 4 +--- 2 files changed, 2 insertions(+), 10 deletions(-)
error.c +1 -7
@@ -20,7 +20,6 @@struct Error {QDict *obj; -const char *fmt;char *msg; };
@@ -38,7 +37,7 @@ void error_set(Error **errp, const char *fmt, ...)va_start (ap, fmt); err->obj =qobject_to_qdict (qobject_from_jsonv (fmt, &ap));va_end (ap); - err->fmt = fmt; + err->msg =qerror_format (fmt, err->obj); *errp = err; }
@@ -49,7 +48,6 @@ Error *error_copy(const Error *err) err_new =g_malloc0 (sizeof (*err)); err_new->msg =g_strdup (err->msg); - err_new->fmt = err->fmt; err_new->obj = err->obj;QINCREF (err_new->obj);
@@ -63,10 +61,6 @@ bool error_is_set(Error **errp)const char *error_get_pretty (Error *err) { -if (err->msg ==NULL ) { - err->msg =qerror_format (err->fmt, err->obj); - } -return err->msg; }
qerror.c +1 -3
@@ -257,7 +257,6 @@ void qerror_report(const char *fmt, ...)struct Error {QDict *obj; -const char *fmt;char *msg; };
@@ -270,8 +269,7 @@ void qerror_report_err(Error *err)QINCREF (err->obj); qerr->error = err->obj; - qerr->err_msg =qerror_format (err->fmt, qerr->error); -/* FIXME: should report UndefinedError on error */ + qerr->err_msg =g_strdup (err->msg);if (monitor_cur_is_qmp ()) {monitor_set_error (cur_mon, qerr);
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 8/14 qerror: add build_error_dict() and error_object_table[]
In reply to Luiz CapitulinoIn the near future, the QERR_ macros (which are json strings today) will be turned into an enumeration. When we get there, build_error_dict() will be used to (guess what) build an error dict by:
1. Using the error class as an index to error_object_table[], which contains all QMP errors as json strings (with default values)
2. Use the human error string to construct the error object data member. For example, an error message like:
"Parameter name=brain has not been found"
Will construct the following data member:
'data': { 'name': 'brain' } }
--- qerror.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ qerror.h | 1 + scripts/qapi-errors.py | 39 +++++++++++++++++++++++ 3 files changed, 126 insertions(+)
qerror.c +86 -0
@@ -38,6 +38,92 @@ static QError *qerror_new(void)return qerr; } +static bool iscchar (int c) +{ +return (isalpha (c) ||isdigit (c) || c =='_' ); +} + +static char *get_key (const char *str) +{ +char *p, *ret; + + ret = p =g_strdup (str); + +while (!iscchar (*p)) { + p++; + } +memmove (ret, p,strlen (ret)); + + p = ret; +while (iscchar (*p)) { + p++; + } + *p ='\0' ; + +return ret; +} + +static char *get_value (const char *str) +{ +char *p, *ret; + + p =strchr (str,'=' ); +while (!iscchar (*p)) { + p++; + } + p = ret =g_strdup (p); +while (iscchar (*p)) { + p++; + } + *p ='\0' ; + +return ret; +} + +static void set_dict_data (const char *msg,QDict *data_dict) +{ +char *str, *msg2, *saveptr =NULL ; + + msg2 =g_strdup (msg); + str =strtok_r (msg2," " , &saveptr); +while (str) { +if (strchr (str,'=' )) { +char *key =get_key (str); +char *value =get_value (str); + +/* FIXME: handle ints */ +if (qdict_haskey (data_dict, key)) { +qdict_put (data_dict, key,qstring_from_str (value)); + } + +g_free (key); +g_free (value); + } + str =strtok_r (NULL ," " , &saveptr); + } + +g_free (msg2); +} + +QDict *build_error_dict (int err_class,const char *msg) +{ +QDict *err_dict; +QObject *obj; + +assert (msg[0 ] !='\0' ); + + obj =qobject_from_json (error_object_table[err_class]); +assert (obj); +assert (qobject_type (obj) ==QTYPE_QDICT ); + + err_dict =qobject_to_qdict (obj); +assert (qdict_haskey (err_dict,"data" )); + +set_dict_data (msg,qdict_get_qdict (err_dict,"data" )); + +return err_dict; +} +static QDict *error_object_from_fmt (const char *fmt,va_list *va) {QObject *obj;
qerror.h +1 -0
@@ -36,5 +36,6 @@ void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void qerror_report_err (Error *err);void assert_no_error (Error *err);char *qerror_format (const char *fmt,QDict *error); +QDict *build_error_dict (int err_class,const char *msg);#endif /* QERROR_H */
scripts/qapi-errors.py +39 -0
@@ -85,6 +85,42 @@ static const QErrorStringTable qerror_table[] = { return ret +def gen_error_data_obj(data): + colon = '' + data_str = '' + for k, v in data.items(): + data_str += colon + "'%s': " % k + if v == 'str': + data_str += "'unknown'" + elif v == 'int': + data_str += '0' + else: + sys.exit("unknown data type '%s' for error '%s'" % (v, name)) + colon = ', ' + return data_str + +def gen_error_obj_table(exprs): + ret = mcgen(''' +static const char *error_object_table[] = { +''') + + for err in exprs: + data = gen_error_data_obj({}) + if err.has_key('data'): + data = gen_error_data_obj(err['data']) + ret += mcgen(''' + "{ 'class': '%(error_class)s', 'data': { %(error_data)s } }", +''', + error_class=err['error'], error_data=data) + + ret += mcgen(''' + NULL, +}; + +''') + + return ret; + def gen_error_macro_data_str(data): colon = '' data_str = ''
@@ -173,5 +209,8 @@ if __name__ == '__main__': ret = gen_error_def_table(exprs) fdef.write(ret) + ret = gen_error_obj_table(exprs) + fdef.write(ret) + fdef.flush() fdef.close()
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
Re: [Qemu-devel] [PATCH 08/14] qerror: add build_error_dict() and error_object_table[]
Quoted 28 lines · Luiz Capitulino
In the near future, the
QERR_macros (which are json strings today) will be turned into an enumeration. When we get there,build_error_dict()will be used to (guess what) build an error dict by:1. Using the error class as an index to error_object_table[], which contains all QMP errors as json strings (with default values)
2. Use the human error string to construct the error object data member. For example, an error message like:
"Parameter name=brain has not been found"
Will construct the following data member:
'data': { 'name': 'brain' } }
Signed-off-by Luiz Capitulino <[email protected]>--- qerror.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ qerror.h | 1 + scripts/qapi-errors.py | 39 +++++++++++++++++++++++ 3 files changed, 126 insertions(+)qerror.c +0
-0
qerror.c static QError *qerror_new(void) · line 44
Quoted 7 lines
qerror.c +4
-0@@ -38,6 +38,92 @@ static QError *qerror_new(void)return qerr; } +static bool iscchar (int c) +{ +return (isalpha (c) ||isdigit (c) || c =='_' ); +}
Depends on locale, which may not be what you want.
Beware of passing negative arguments to ctype.h functions.
Quoted 10 lines
qerror.c +10
-0+ +static char *get_key (const char *str) +{ +char *p, *ret; + + ret = p =g_strdup (str); + +while (!iscchar (*p)) { + p++; + }
qerror.c static QError *qerror_new(void) · line 64
Quoted 10 lines
qerror.c +10
-0+memmove (ret, p,strlen (ret)); + + p = ret; +while (iscchar (*p)) { + p++; + } + *p ='\0' ; + +return ret; +}
Suggest something like
static char *get_key(const char *str)
{
char *beg, *end;
for (beg = str; !iscchar(*beg); beg++) ;
for (end = beg; iscchar(*end); end++) ;
return g_strndup(beg, end - beg);
}Quoted 7 lines
qerror.c +7
-0+ +static char *get_value (const char *str) +{ +char *p, *ret; + + p =strchr (str,'=' ); +while (!iscchar (*p)) {
qerror.c static QError *qerror_new(void) · line 81
Quoted 10 lines
qerror.c +10
-0+ p++; + } + p = ret =g_strdup (p); +while (iscchar (*p)) { + p++; + } + *p ='\0' ; + +return ret; +}
Likewise.
Quoted 70 lines
qerror.c +45
-0+ +static void set_dict_data (const char *msg,QDict *data_dict) +{ +char *str, *msg2, *saveptr =NULL ; + + msg2 =g_strdup (msg); + str =strtok_r (msg2," " , &saveptr); +while (str) { +if (strchr (str,'=' )) { +char *key =get_key (str); +char *value =get_value (str); + +/* FIXME: handle ints */ +if (qdict_haskey (data_dict, key)) { +qdict_put (data_dict, key,qstring_from_str (value)); + } + +g_free (key); +g_free (value); + } + str =strtok_r (NULL ," " , &saveptr); + } + +g_free (msg2); +} + +QDict *build_error_dict (int err_class,const char *msg) +{ +QDict *err_dict; +QObject *obj; + +assert (msg[0 ] !='\0' ); + + obj =qobject_from_json (error_object_table[err_class]); +assert (obj); +assert (qobject_type (obj) ==QTYPE_QDICT ); + + err_dict =qobject_to_qdict (obj); +assert (qdict_haskey (err_dict,"data" )); + +set_dict_data (msg,qdict_get_qdict (err_dict,"data" )); + +return err_dict; +} +static QDict *error_object_from_fmt (const char *fmt,va_list *va) {QObject *obj;qerror.h +1
-0@@ -36,5 +36,6 @@ void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void qerror_report_err (Error *err);void assert_no_error (Error *err);char *qerror_format (const char *fmt,QDict *error); +QDict *build_error_dict (int err_class,const char *msg);#endif /* QERROR_H */ scripts/qapi-errors.py +3
-0@@ -85,6 +85,42 @@ static const QErrorStringTable qerror_table[] = { return ret +def gen_error_data_obj(data): + colon = '' + data_str = ''
scripts/qapi-errors.py static const QErrorStringTable qerror_table[] = { · line 100
Quoted 10 lines
scripts/qapi-errors.py +10
-0+ for k, v in data.items(): + data_str += colon + "'%s': " % k + if v == 'str': + data_str += "'unknown'" + elif v == 'int': + data_str += '0' + else: + sys.exit("unknown data type '%s' for error '%s'" % (v, name)) + colon = ', ' + return data_str
colon is either empty or ', ', but never a colon. What about calling it sep, for separator?
Quoted 35 lines
scripts/qapi-errors.py +26
-0+ +def gen_error_obj_table(exprs): + ret = mcgen(''' +static const char *error_object_table[] = { +''') + + for err in exprs: + data = gen_error_data_obj({}) + if err.has_key('data'): + data = gen_error_data_obj(err['data']) + ret += mcgen(''' + "{ 'class': '%(error_class)s', 'data': { %(error_data)s } }", +''', + error_class=err['error'], error_data=data) + + ret += mcgen(''' + NULL, +}; + +''') + + return ret; + def gen_error_macro_data_str(data): colon = '' data_str = ''@@ -173,5 +209,8 @@ if __name__ == '__main__': ret = gen_error_def_table(exprs) fdef.write(ret) + ret = gen_error_obj_table(exprs) + fdef.write(ret) + fdef.flush() fdef.close()
PATCH 9/14 qerror: qerror_report(): take an index and a human error message
In reply to Luiz CapitulinoThis commit does three indivisible changes:
1. qerror_report() is changed to take an index to error_object_table[] and a human error message in printf format.
That is, we go from:
qerror_report(const char *fmt, ...);
where fmt is a json dict in string format and the arguments are error data (the data member in qapi-schema-error.json).
To:
qerror_report(int err_class, const char *fmt, ...);
where err_class is the error_object_table[] index, and the remaining arguments form a printf-like string, which is going to be used as the human error message.
Future commits will turn the index into a proper enumeration.
qerror_report() is also changed to use build_error_dict(), which was introduced by the last commit.
2. error_object_from_fmt(), which was used to build the error object from the previous 'fmt' argument is dropped
3. All calls to qerror_report() are changed to adhere to the new signature. As an example, a call like:
qerror_report(QERR_DEVICE_IN_USE, device);
is changed to:
qerror_report(/* QERR_DEVICE_IN_USE */ 14,
"Device 'device=%s' is in use", device);
The name in the comment is going to be the future enum for the
index used.TODO: fix long lines.
--- block/cow.c | 3 +-- block/qcow.c | 3 +-- block/qcow2.c | 3 +-- block/qed.c | 3 +-- blockdev.c | 10 ++++---- hw/pci.c | 4 +-- hw/qdev-monitor.c | 24 +++++++++--------- hw/usb/bus.c | 3 +-- hw/usb/hcd-ehci.c | 6 ++--- hw/usb/redirect.c | 5 ++-- monitor.c | 55 ++++++++++++++++++----------------------- qemu-option.c | 2 +- qerror.c | 73 ++++++------------------------------------------------- qerror.h | 2 +- 14 files changed, 60 insertions(+), 136 deletions(-)
block/cow.c +1 -2
@@ -81,8 +81,7 @@ static int cow_open(BlockDriverState *bs, int flags)char version[64 ];snprintf (version,sizeof (version),"COW version %d" , cow_header.version); -qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE , - bs->device_name,"cow" , version); +qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"cow" , version); ret = -ENOTSUP ; goto fail; }
block/qcow.c +1 -2
@@ -118,8 +118,7 @@ static int qcow_open(BlockDriverState *bs, int flags)if (header.version !=QCOW_VERSION ) {char version[64 ];snprintf (version,sizeof (version),"QCOW version %d" , header.version); -qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE , - bs->device_name,"qcow" , version); +qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow" , version); ret = -ENOTSUP ; goto fail; }
block/qcow2.c +1 -2
@@ -192,8 +192,7 @@ static void GCC_FMT_ATTR(2, 3) report_unsupported(BlockDriverState *bs,vsnprintf (msg,sizeof (msg), fmt, ap);va_end (ap); -qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE , - bs->device_name,"qcow2" , msg); +qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow2" , msg); } static void report_unsupported_feature(BlockDriverState *bs,
block/qed.c +1 -2
@@ -397,8 +397,7 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)char buf[64 ];snprintf (buf,sizeof (buf),"%" PRIx64, s->header.features & ~QED_FEATURE_MASK ); -qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE , - bs->device_name,"QED" , buf); +qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"QED" , buf);return -ENOTSUP ; }if (!qed_is_cluster_size_valid (s->header.cluster_size)) {
blockdev.c +5 -5
@@ -633,18 +633,18 @@ void do_commit(Monitor *mon, const QDict *qdict)if (!strcmp (device,"all" )) { ret =bdrv_commit_all ();if (ret == -EBUSY ) { -qerror_report (QERR_DEVICE_IN_USE , device); +qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , device);return ; } }else { bs =bdrv_find (device);if (!bs) { -qerror_report (QERR_DEVICE_NOT_FOUND , device); +qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , device);return ; } ret =bdrv_commit (bs);if (ret == -EBUSY ) { -qerror_report (QERR_DEVICE_IN_USE , device); +qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , device);return ; } }
@@ -985,11 +985,11 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) bs =bdrv_find (id);if (!bs) { -qerror_report (QERR_DEVICE_NOT_FOUND , id); +qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id);return -1 ; }if (bdrv_in_use (bs)) { -qerror_report (QERR_DEVICE_IN_USE , id); +qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , id);return -1 ; }
hw/pci.c +2 -2
@@ -1506,7 +1506,7 @@ static int pci_qdev_init(DeviceState *qdev)if (pci_dev ==NULL )return -1 ;if (qdev->hotplugged && pc->no_hotplug) { -qerror_report (QERR_DEVICE_NO_HOTPLUG ,object_get_typename (OBJECT (pci_dev))); +qerror_report (/* QERR_DEVICE_NO_HOTPLUG */ 19 ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (pci_dev)));do_pci_unregister_device (pci_dev);return -1 ; }
@@ -1547,7 +1547,7 @@ static int pci_unplug_device(DeviceState *qdev)PCIDeviceClass *pc =PCI_DEVICE_GET_CLASS (dev);if (pc->no_hotplug) { -qerror_report (QERR_DEVICE_NO_HOTPLUG ,object_get_typename (OBJECT (dev))); +qerror_report (/* QERR_DEVICE_NO_HOTPLUG */ 19 ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (dev)));return -1 ; } return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
hw/qdev-monitor.c +11 -13
@@ -326,7 +326,7 @@ static BusState *qbus_find(const char *path) } bus =qbus_find_recursive (sysbus_get_default (), elem,NULL );if (!bus) { -qerror_report (QERR_BUS_NOT_FOUND , elem); +qerror_report (/* QERR_BUS_NOT_FOUND */ 7 ,"Bus 'bus=%s' not found" , elem);return NULL ; } pos = len;
@@ -349,7 +349,7 @@ static BusState *qbus_find(const char *path) pos += len; dev =qbus_find_dev (bus, elem);if (!dev) { -qerror_report (QERR_DEVICE_NOT_FOUND , elem); +qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_dev (bus); }
@@ -365,12 +365,12 @@ static BusState *qbus_find(const char *path)* one child bus accept it nevertheless */ switch (dev->num_child_bus) {case 0 : -qerror_report (QERR_DEVICE_NO_BUS , elem); +qerror_report (/* QERR_DEVICE_NO_BUS */ 18 ,"Device 'device=%s' has no child bus" , elem);return NULL ;case 1 :return QLIST_FIRST (&dev->child_bus);default : -qerror_report (QERR_DEVICE_MULTIPLE_BUSSES , elem); +qerror_report (/* QERR_DEVICE_MULTIPLE_BUSSES */ 17 ,"Device 'device=%s' has multiple child busses" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_bus (dev); }
@@ -386,7 +386,7 @@ static BusState *qbus_find(const char *path) pos += len; bus =qbus_find_bus (dev, elem);if (!bus) { -qerror_report (QERR_BUS_NOT_FOUND , elem); +qerror_report (/* QERR_BUS_NOT_FOUND */ 7 ,"Bus 'bus=%s' not found" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_bus (dev); }
@@ -405,7 +405,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) driver =qemu_opt_get (opts,"driver" );if (!driver) { -qerror_report (QERR_MISSING_PARAMETER ,"driver" ); +qerror_report (/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"driver" );return NULL ; }
@@ -421,7 +421,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) }if (!obj) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"driver" ,"device type" ); +qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"driver" ,"device type" );return NULL ; }
@@ -435,20 +435,18 @@ DeviceState *qdev_device_add(QemuOpts *opts)return NULL ; }if (strcmp (object_get_typename (OBJECT (bus)), k->bus_type) !=0 ) { -qerror_report (QERR_BAD_BUS_FOR_DEVICE , - driver,object_get_typename (OBJECT (bus))); +qerror_report (/* QERR_BAD_BUS_FOR_DEVICE */ 2 ,"Device 'device=%s' can't go on a bad_bus_type=%s bus" , driver,object_get_typename (OBJECT (bus)));return NULL ; } }else { bus =qbus_find_recursive (sysbus_get_default (),NULL , k->bus_type);if (!bus) { -qerror_report (QERR_NO_BUS_FOR_DEVICE , - driver, k->bus_type); +qerror_report (/* QERR_NO_BUS_FOR_DEVICE */ 43 ,"No 'bus=%s' bus found for device 'device=%s'" , driver, k->bus_type);return NULL ; } }if (qdev_hotplug && !bus->allow_hotplug) { -qerror_report (QERR_BUS_NO_HOTPLUG , bus->name); +qerror_report (/* QERR_BUS_NO_HOTPLUG */ 6 ,"Bus 'bus=%s' does not support hotplugging" , bus->name);return NULL ; }
@@ -479,7 +477,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)g_free (name); }if (qdev_init (qdev) <0 ) { -qerror_report (QERR_DEVICE_INIT_FAILED , driver); +qerror_report (/* QERR_DEVICE_INIT_FAILED */ 13 ,"Device 'device=%s' could not be initialized" , driver);return NULL ; } qdev->opts = opts;
hw/usb/bus.c +1 -2
@@ -303,8 +303,7 @@ int usb_register_companion(const char *masterbus, USBPort *ports[], }if (!bus || !bus->ops->register_companion) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"masterbus" , -"an USB masterbus" ); +qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" );if (bus) { error_printf_unless_qmp( "USB bus '%s' does not allow companion controllers\n",
hw/usb/hcd-ehci.c +2 -4
@@ -933,8 +933,7 @@ static int ehci_register_companion(USBBus *bus, USBPort *ports[],uint32_t i;if (firstport + portcount >NB_PORTS ) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"firstport" , -"firstport on masterbus" ); +qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"firstport" ,"firstport on masterbus" ); error_printf_unless_qmp( "firstport value of %u makes companion take ports %u - %u, which " "is outside of the valid range of 0 - %u\n", firstport, firstport,
@@ -944,8 +943,7 @@ static int ehci_register_companion(USBBus *bus, USBPort *ports[],for (i =0 ; i < portcount; i++) {if (s->companion_ports[firstport + i]) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"masterbus" , -"an USB masterbus" ); +qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" );error_printf_unless_qmp ("port %u on masterbus %s already has a companion assigned\n" , firstport + i, bus->qbus.name);
hw/usb/redirect.c +2 -3
@@ -902,7 +902,7 @@ static int usbredir_initfn(USBDevice *udev)int i;if (dev->cs ==NULL ) { -qerror_report (QERR_MISSING_PARAMETER ,"chardev" ); +qerror_report (/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"chardev" );return -1 ; }
@@ -911,8 +911,7 @@ static int usbredir_initfn(USBDevice *udev) &dev->filter_rules, &dev->filter_rules_count);if (i) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"filter" , -"a usb device filter string" ); +qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"filter" ,"a usb device filter string" );return -1 ; } }
monitor.c +24 -31
191 lines not on this page · raw message
qemu-option.c +1 -1
@@ -690,7 +690,7 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)if (i ==0 ) {/* empty list -> allow any */ ; }else { -qerror_report (QERR_INVALID_PARAMETER , name); +qerror_report (/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name);return -1 ; } }
qerror.c +7 -66
102 lines not on this page · raw message
qerror.h +1 -1
@@ -32,7 +32,7 @@ typedef struct QError { } QError;QString *qerror_human (const QError *qerror); -void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void qerror_report(int err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void qerror_report_err (Error *err);void assert_no_error (Error *err);char *qerror_format (const char *fmt,QDict *error);
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 10/14 error: error_set(): take an index and a human error message
In reply to Luiz CapitulinoThis commit does for error_set() the same change that last commit did for qerror_report().
TODO: fix long lines.
--- balloon.c | 10 +++--- block.c | 4 +-- block/qcow.c | 4 +-- block/stream.c | 2 +- block/vdi.c | 4 +-- block/vmdk.c | 4 +-- block/vpc.c | 4 +-- block/vvfat.c | 4 +-- blockdev.c | 69 ++++++++++++++++++++------------------- cpus.c | 13 ++++---- dump-stub.c | 2 +- dump.c | 18 +++++------ error.c | 12 +++++-- error.h | 2 +- hmp.c | 2 +- hw/9pfs/virtio-9p.c | 3 +- hw/ivshmem.c | 2 +- hw/pci-stub.c | 2 +- hw/qdev-addr.c | 6 ++-- hw/qdev-monitor.c | 2 +- hw/qdev-properties.c | 49 ++++++++++++---------------- hw/qdev.c | 6 ++-- json-parser.c | 2 +- migration.c | 6 ++-- monitor.c | 10 +++--- net.c | 20 ++++++------ qapi/qapi-visit-core.c | 22 +++++-------- qapi/qmp-dispatch.c | 14 ++++---- qapi/qmp-input-visitor.c | 22 +++++-------- qapi/string-input-visitor.c | 12 +++---- qemu-config.c | 2 +- qemu-ga.c | 4 +-- qemu-option.c | 18 +++++------ qemu-sockets.c | 22 ++++++------- qga/commands-posix.c | 78 ++++++++++++++++++++++----------------------- qga/commands-win32.c | 53 +++++++++++++----------------- qmp.c | 47 +++++++++++++-------------- qom/object.c | 20 ++++++------ savevm.c | 6 ++-- target-i386/cpu.c | 15 +++------ ui/vnc.c | 4 +-- 41 files changed, 273 insertions(+), 328 deletions(-)
balloon.c +5 -5
@@ -99,14 +99,14 @@ BalloonInfo *qmp_query_balloon(Error **errp)BalloonInfo *info;if (kvm_enabled () && !kvm_has_sync_mmu ()) { -error_set (errp,QERR_KVM_MISSING_CAP ,"synchronous MMU" ,"balloon" ); +error_set (errp,/* QERR_KVM_MISSING_CAP */ 38 ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" );return NULL ; } info =g_malloc0 (sizeof (*info));if (qemu_balloon_status (info) ==0 ) { -error_set (errp,QERR_DEVICE_NOT_ACTIVE ,"balloon" ); +error_set (errp,/* QERR_DEVICE_NOT_ACTIVE */ 20 ,"Device 'device=%s' has not been activated" ,"balloon" );qapi_free_BalloonInfo (info);return NULL ; }
@@ -117,16 +117,16 @@ BalloonInfo *qmp_query_balloon(Error **errp)void qmp_balloon (int64_t value,Error **errp) {if (kvm_enabled () && !kvm_has_sync_mmu ()) { -error_set (errp,QERR_KVM_MISSING_CAP ,"synchronous MMU" ,"balloon" ); +error_set (errp,/* QERR_KVM_MISSING_CAP */ 38 ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" );return ; }if (value <=0 ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"target" ,"a size" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"target" ,"a size" );return ; }if (qemu_balloon (value) ==0 ) { -error_set (errp,QERR_DEVICE_NOT_ACTIVE ,"balloon" ); +error_set (errp,/* QERR_DEVICE_NOT_ACTIVE */ 20 ,"Device 'device=%s' has not been activated" ,"balloon" ); } }
block.c +2 -2
@@ -4034,7 +4034,7 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,BlockJob *job;if (bs->job ||bdrv_in_use (bs)) { -error_set (errp,QERR_DEVICE_IN_USE ,bdrv_get_device_name (bs)); +error_set (errp,/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" ,bdrv_get_device_name (bs));return NULL ; }bdrv_set_in_use (bs,1 );
@@ -4079,7 +4079,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)Error *local_err =NULL ;if (!job->job_type->set_speed) { -error_set (errp,QERR_NOT_SUPPORTED ); +error_set (errp,/* QERR_NOT_SUPPORTED */ 44 ,"Not supported" );return ; } job->job_type->set_speed (job, speed, &local_err);
block/qcow.c +1 -3
@@ -180,9 +180,7 @@ static int qcow_open(BlockDriverState *bs, int flags) }/* Disable migration when qcow images are used */ -error_set (&s->migration_blocker, -QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , -"qcow" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"qcow" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);qemu_co_mutex_init (&s->lock);
block/stream.c +1 -1
@@ -168,7 +168,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)StreamBlockJob *s =container_of (job, StreamBlockJob, common);if (speed <0 ) { -error_set (errp,QERR_INVALID_PARAMETER ,"speed" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"speed" );return ; }ratelimit_set_speed (&s->limit, speed /BDRV_SECTOR_SIZE ,SLICE_TIME );
block/vdi.c +1 -3
@@ -440,9 +440,7 @@ static int vdi_open(BlockDriverState *bs, int flags) }/* Disable migration when vdi images are used */ -error_set (&s->migration_blocker, -QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , -"vdi" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vdi" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vmdk.c +1 -3
@@ -663,9 +663,7 @@ static int vmdk_open(BlockDriverState *bs, int flags)qemu_co_mutex_init (&s->lock);/* Disable migration when VMDK images are used */ -error_set (&s->migration_blocker, -QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , -"vmdk" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vmdk" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vpc.c +1 -3
@@ -255,9 +255,7 @@ static int vpc_open(BlockDriverState *bs, int flags)qemu_co_mutex_init (&s->lock);/* Disable migration when VHD images are used */ -error_set (&s->migration_blocker, -QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , -"vpc" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vpc" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vvfat.c +1 -3
@@ -1091,9 +1091,7 @@ DLOG(if (stderr == NULL) {/* Disable migration when vvfat is used rw */ if (s->qcow) { -error_set (&s->migration_blocker, -QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED , -"vvfat (rw)" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vvfat (rw)" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker); }
blockdev.c +34 -35
233 lines not on this page · raw message
cpus.c +6 -7
@@ -1246,14 +1246,13 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, }if (env ==NULL ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"cpu-index" , -"a CPU number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" );return ; } f =fopen (filename,"wb" );if (!f) { -error_set (errp,QERR_OPEN_FILE_FAILED , filename); +error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename);return ; }
@@ -1263,7 +1262,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, l = size;cpu_memory_rw_debug (env, addr, buf, l,0 );if (fwrite (buf,1 , l, f) != l) { -error_set (errp,QERR_IO_ERROR ); +error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); goto exit; } addr += l;
@@ -1283,7 +1282,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, f =fopen (filename,"wb" );if (!f) { -error_set (errp,QERR_OPEN_FILE_FAILED , filename); +error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename);return ; }
@@ -1293,7 +1292,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, l = size;cpu_physical_memory_rw (addr, buf, l,0 );if (fwrite (buf,1 , l, f) != l) { -error_set (errp,QERR_IO_ERROR ); +error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); goto exit; } addr += l;
@@ -1317,6 +1316,6 @@ void qmp_inject_nmi(Error **errp) } }#else -error_set (errp,QERR_UNSUPPORTED ); +error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" );#endif }
dump-stub.c +1 -1
@@ -21,7 +21,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, int64_t begin, bool has_length, int64_t length, Error **errp) { -error_set (errp ,QERR_UNSUPPORTED ); + error_set(errp, /* QERR_UNSUPPORTED */ 68, "this feature or command is not currently supported"); } int cpu_write_elf64_note(write_core_dump_function f,
dump.c +9 -9
@@ -721,7 +721,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, s->length = length; s->start =get_start_block (s);if (s->start ==-1 ) { -error_set (errp,QERR_INVALID_PARAMETER ,"begin" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"begin" ); goto cleanup; }
@@ -741,14 +741,14 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, ret =cpu_get_dump_info (&s->dump_info);if (ret <0 ) { -error_set (errp,QERR_UNSUPPORTED ); +error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); goto cleanup; } s->note_size =cpu_get_note_size (s->dump_info.d_class, s->dump_info.d_machine, nr_cpus);if (ret <0 ) { -error_set (errp,QERR_UNSUPPORTED ); +error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); goto cleanup; }
@@ -826,11 +826,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,int ret;if (has_begin && !has_length) { -error_set (errp,QERR_MISSING_PARAMETER ,"length" ); +error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"length" );return ; }if (!has_begin && has_length) { -error_set (errp,QERR_MISSING_PARAMETER ,"begin" ); +error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"begin" );return ; }
@@ -838,7 +838,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,if (strstart (file,"fd:" , &p)) { fd =monitor_get_fd (cur_mon, p);if (fd ==-1 ) { -error_set (errp,QERR_FD_NOT_FOUND , p); +error_set (errp,/* QERR_FD_NOT_FOUND */ 25 ,"File descriptor named 'name=%s' not found" , p);return ; } }
@@ -847,13 +847,13 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,if (strstart (file,"file:" , &p)) { fd =qemu_open (p,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,S_IRUSR );if (fd <0 ) { -error_set (errp,QERR_OPEN_FILE_FAILED , p); +error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , p);return ; } }if (fd ==-1 ) { -error_set (errp,QERR_INVALID_PARAMETER ,"protocol" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"protocol" );return ; }
@@ -866,7 +866,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, }if (create_vmcore (s) <0 && !error_is_set (s->errp)) { -error_set (errp,QERR_IO_ERROR ); +error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); }g_free (s);
error.c +9 -3
@@ -21,12 +21,14 @@ struct Error {QDict *obj;char *msg; +int err_class; }; -void error_set (Error **errp,const char *fmt, ...) +void error_set (Error **errp,int err_class,const char *fmt, ...) {Error *err;va_list ap; +char msg[2048 ];if (errp ==NULL ) {return ;
@@ -35,9 +37,12 @@ void error_set(Error **errp, 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->obj =build_error_dict (err_class, err->msg); + err->err_class = err_class; *errp = err; }
@@ -48,6 +53,7 @@ Error *error_copy(const Error *err) err_new =g_malloc0 (sizeof (*err)); err_new->msg =g_strdup (err->msg); + err_new->err_class = err->err_class; err_new->obj = err->obj;QINCREF (err_new->obj);
error.h +1 -1
@@ -26,7 +26,7 @@ typedef struct Error Error;* Currently, qerror.h defines these error formats. This function is not * meant to be used outside of QEMU. */ -void error_set(Error **err, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +void error_set(Error **err, int err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4);/** * Returns true if an indirect pointer to an error is pointing to a valid
hmp.c +1 -1
@@ -707,7 +707,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)if (!filename) {/* In the future, if 'snapshot-file' is not specified, the snapshot will be taken internally. Today it's actually required. */ -error_set (&errp,QERR_MISSING_PARAMETER ,"snapshot-file" ); +error_set (&errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"snapshot-file" );hmp_handle_error (mon, &errp);return ; }
hw/9pfs/virtio-9p.c +1 -2
@@ -985,8 +985,7 @@ static void v9fs_attach(void *opaque) qid.type, qid.version, qid.path); s->root_fid = fid;/* disable migration */ -error_set (&s->migration_blocker,QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION , - s->ctx.fs_root ? s->ctx.fs_root :"NULL" , s->tag); +error_set (&s->migration_blocker,/* QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION */ 69 ,"Migration is disabled when VirtFS export path 'path=%s' is mounted in the guest using mount_tag 'tag=%s'" , s->ctx.fs_root ? s->ctx.fs_root :"NULL" , s->tag);migrate_add_blocker (s->migration_blocker); out:put_fid (pdu, fidp);
hw/ivshmem.c +1 -1
@@ -681,7 +681,7 @@ static int pci_ivshmem_init(PCIDevice *dev) }if (s->role_val ==IVSHMEM_PEER ) { -error_set (&s->migration_blocker,QERR_DEVICE_FEATURE_BLOCKS_MIGRATION ,"ivshmem" ,"peer mode" ); +error_set (&s->migration_blocker,/* QERR_DEVICE_FEATURE_BLOCKS_MIGRATION */ 11 ,"Migration is disabled when using feature 'feature=%s' in device 'device=%s'" ,"ivshmem" ,"peer mode" );migrate_add_blocker (s->migration_blocker); }
hw/pci-stub.c +1 -1
@@ -25,7 +25,7 @@PciInfoList *qmp_query_pci (Error **errp) { -error_set (errp,QERR_UNSUPPORTED ); +error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" );return NULL ; }
hw/qdev-addr.c +2 -4
@@ -40,7 +40,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,int64_t value;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" );return ; }
@@ -52,9 +52,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,if ((uint64_t )value <= (uint64_t ) ~(target_phys_addr_t )0 ) { *ptr = value; }else { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , - dev->id?:"" , name, value, (uint64_t )0 , - (uint64_t ) ~(target_phys_addr_t )0 ); +error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" , dev->id?:"" , name, value, (uint64_t )0 , (uint64_t ) ~(target_phys_addr_t )0 ); } }
hw/qdev-monitor.c +1 -1
@@ -600,7 +600,7 @@ void qmp_device_del(const char *id, Error **errp) dev =qdev_find_recursive (sysbus_get_default (), id);if (NULL == dev) { -error_set (errp,QERR_DEVICE_NOT_FOUND , id); +error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id);return ; }
hw/qdev-properties.c +21 -28
167 lines not on this page · raw message
hw/qdev.c +3 -3
@@ -199,7 +199,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)DeviceClass *dc =DEVICE_GET_CLASS (dev);if (!dev->parent_bus->allow_hotplug) { -error_set (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name); +error_set (errp,/* QERR_BUS_NO_HOTPLUG */ 6 ,"Bus 'bus=%s' does not support hotplugging" , dev->parent_bus->name);return ; }assert (dc->unplug !=NULL );
@@ -207,7 +207,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) qdev_hot_removed = true;if (dc->unplug (dev) <0 ) { -error_set (errp,QERR_UNDEFINED_ERROR ); +error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" );return ; } }
@@ -570,7 +570,7 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,int ret;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" );return ; }
json-parser.c +1 -1
@@ -105,7 +105,7 @@ static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,error_free (ctxt->err); ctxt->err =NULL ; } -error_set (&ctxt->err,QERR_JSON_PARSE_ERROR , message); +error_set (&ctxt->err,/* QERR_JSON_PARSE_ERROR */ 36 ,"JSON parse error, message=%s" , message); }/**
migration.c +3 -3
@@ -412,7 +412,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, params.shared = inc;if (s->state ==MIG_STATE_ACTIVE ) { -error_set (errp,QERR_MIGRATION_ACTIVE ); +error_set (errp,/* QERR_MIGRATION_ACTIVE */ 39 ,"There\'s a migration process in progress" );return ; }
@@ -438,7 +438,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, ret =fd_start_outgoing_migration (s, p);#endif }else { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"uri" ,"a valid migration protocol" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"uri" ,"a valid migration protocol" );return ; }
@@ -446,7 +446,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,if (!error_is_set (errp)) {DPRINTF ("migration failed: %s\n" ,strerror (-ret));/* FIXME: we should return meaningful errors */ -error_set (errp,QERR_UNDEFINED_ERROR ); +error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); }return ; }
monitor.c +4 -6
@@ -626,8 +626,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,int ret =monitor_set_cpu (cpu_index);if (ret <0 ) { cur_mon = old_mon; -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"cpu-index" , -"a CPU number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" ); goto out; } }
@@ -2285,13 +2284,12 @@ void qmp_getfd(const char *fdname, Error **errp) fd =qemu_chr_fe_get_msgfd (cur_mon->chr);if (fd ==-1 ) { -error_set (errp,QERR_FD_NOT_SUPPLIED ); +error_set (errp,/* QERR_FD_NOT_SUPPLIED */ 26 ,"No file descriptor supplied via SCM_RIGHTS" );return ; }if (qemu_isdigit (fdname[0 ])) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"fdname" , -"a name not starting with a digit" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"fdname" ,"a name not starting with a digit" );return ; }
@@ -2328,7 +2326,7 @@ void qmp_closefd(const char *fdname, Error **errp)return ; } -error_set (errp,QERR_FD_NOT_FOUND , fdname); +error_set (errp,/* QERR_FD_NOT_FOUND */ 25 ,"File descriptor named 'name=%s' not found" , fdname); }static void do_loadvm (Monitor *mon,const QDict *qdict)
net.c +9 -11
@@ -1089,7 +1089,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) type =qemu_opt_get (opts,"type" );if (!type) { -error_set (errp,QERR_MISSING_PARAMETER ,"type" ); +error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"type" );return -1 ; }
@@ -1105,21 +1105,20 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) strcmp(type, "vde") != 0 && #endif strcmp(type, "socket") != 0) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"type" , -"a netdev backend type" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a netdev backend type" );return -1 ; }if (qemu_opt_get (opts,"vlan" )) { -error_set (errp,QERR_INVALID_PARAMETER ,"vlan" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"vlan" );return -1 ; }if (qemu_opt_get (opts,"name" )) { -error_set (errp,QERR_INVALID_PARAMETER ,"name" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"name" );return -1 ; }if (!qemu_opts_id (opts)) { -error_set (errp,QERR_MISSING_PARAMETER ,"id" ); +error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"id" );return -1 ; } }
@@ -1154,7 +1153,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) ret = net_client_types[i].init (opts, name, vlan);if (ret <0 ) {/* TODO push error reporting into init() methods */ -error_set (errp,QERR_DEVICE_INIT_FAILED , type); +error_set (errp,/* QERR_DEVICE_INIT_FAILED */ 13 ,"Device 'device=%s' could not be initialized" , type);return -1 ; } }
@@ -1162,8 +1161,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) } } -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"type" , -"a network client type" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a network client type" );return -1 ; }
@@ -1275,7 +1273,7 @@ void qmp_netdev_del(const char *id, Error **errp) vc =qemu_find_netdev (id);if (!vc) { -error_set (errp,QERR_DEVICE_NOT_FOUND , id); +error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id);return ; }
@@ -1338,7 +1336,7 @@ void qmp_set_link(const char *name, bool up, Error **errp) done:if (!vc) { -error_set (errp,QERR_DEVICE_NOT_FOUND , name); +error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , name);return ; }
qapi/qapi-visit-core.c +8 -14
@@ -107,8 +107,7 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT8_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"uint8_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint8_t" );return ; } *obj = value;
@@ -126,8 +125,7 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT16_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"uint16_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint16_t" );return ; } *obj = value;
@@ -145,8 +143,7 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT32_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"uint32_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint32_t" );return ; } *obj = value;
@@ -178,8 +175,7 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT8_MIN || value >INT8_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"int8_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int8_t" );return ; } *obj = value;
@@ -197,8 +193,7 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT16_MIN || value >INT16_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"int16_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int16_t" );return ; } *obj = value;
@@ -216,8 +211,7 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT32_MIN || value >INT32_MAX ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"int32_t" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int32_t" );return ; } *obj = value;
@@ -268,7 +262,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],assert (strings);while (strings[i++] !=NULL );if (value <0 || value >= i -1 ) { -error_set (errp,QERR_INVALID_PARAMETER , name ? name :"null" ); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name ? name :"null" );return ; }
@@ -298,7 +292,7 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], }if (strings[value] ==NULL ) { -error_set (errp,QERR_INVALID_PARAMETER , enum_str); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , enum_str);g_free (enum_str);return ; }
qapi/qmp-dispatch.c +6 -8
@@ -27,8 +27,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)QDict *dict =NULL ;if (qobject_type (request) !=QTYPE_QDICT ) { -error_set (errp,QERR_QMP_BAD_INPUT_OBJECT , -"request is not a dictionary" ); +error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT */ 55 ,"Expected 'expected=%s' in QMP input" ,"request is not a dictionary" );return NULL ; }
@@ -41,19 +40,18 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)if (!strcmp (arg_name,"execute" )) {if (qobject_type (arg_obj) !=QTYPE_QSTRING ) { -error_set (errp,QERR_QMP_BAD_INPUT_OBJECT_MEMBER ,"execute" , -"string" ); +error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT_MEMBER */ 56 ,"QMP input object member 'member=%s' expects 'expected=%s'" ,"execute" ,"string" );return NULL ; } has_exec_key = true; }else if (strcmp (arg_name,"arguments" )) { -error_set (errp,QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER , arg_name); +error_set (errp,/* QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER */ 57 ,"QMP input object member 'member=%s' is unexpected" , arg_name);return NULL ; } }if (!has_exec_key) { -error_set (errp,QERR_QMP_BAD_INPUT_OBJECT ,"execute" ); +error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT */ 55 ,"Expected 'expected=%s' in QMP input" ,"execute" );return NULL ; }
@@ -76,11 +74,11 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp) command =qdict_get_str (dict,"execute" ); cmd =qmp_find_command (command);if (cmd ==NULL ) { -error_set (errp,QERR_COMMAND_NOT_FOUND , command); +error_set (errp,/* QERR_COMMAND_NOT_FOUND */ 9 ,"The command name=%s has not been found" , command);return NULL ; }if (!cmd->enabled) { -error_set (errp,QERR_COMMAND_DISABLED , command); +error_set (errp,/* QERR_COMMAND_DISABLED */ 8 ,"The command name=%s has been disabled for this instance" , command);return NULL ; }
qapi/qmp-input-visitor.c +8 -14
@@ -70,7 +70,7 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp)GHashTable *h;if (qiv->nb_stack >=QIV_STACK_SIZE ) { -error_set (errp,QERR_BUFFER_OVERRUN ); +error_set (errp,/* QERR_BUFFER_OVERRUN */ 5 ,"An internal buffer overran" );return ; }
@@ -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_INPUT_OBJECT_MEMBER , key); +error_set (errp,/* QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER */ 57 ,"QMP input object member 'member=%s' is unexpected" , key); }g_hash_table_unref (top_ht); }
@@ -121,8 +121,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,Error *err =NULL ;if (!qobj ||qobject_type (qobj) !=QTYPE_QDICT ) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"QDict" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"QDict" );return ; }
@@ -150,8 +149,7 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp)QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QLIST ) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"list" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"list" );return ; }
@@ -202,8 +200,7 @@ static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QINT ) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"integer" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" );return ; }
@@ -217,8 +214,7 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QBOOL ) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"boolean" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" );return ; }
@@ -232,8 +228,7 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QSTRING ) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"string" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" );return ; }
@@ -248,8 +243,7 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,if (!qobj || (qobject_type (qobj) !=QTYPE_QFLOAT &&qobject_type (qobj) !=QTYPE_QINT )) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" );return ; }
qapi/string-input-visitor.c +4 -8
@@ -33,8 +33,7 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name, val =strtoll (siv->string, &endp,0 ); }if (!siv->string || errno || endp == siv->string || *endp) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"integer" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" );return ; }
@@ -61,8 +60,7 @@ static void parse_type_bool(Visitor *v, bool *obj, const char *name, } } -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"boolean" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" ); } static void parse_type_str(Visitor *v, char **obj, const char *name,
@@ -72,8 +70,7 @@ static void parse_type_str(Visitor *v, char **obj, const char *name,if (siv->string) { *obj =g_strdup (siv->string); }else { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"string" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" ); } }
@@ -89,8 +86,7 @@ static void parse_type_number(Visitor *v, double *obj, const char *name, val =strtod (siv->string, &endp); }if (!siv->string || errno || endp == siv->string || *endp) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" );return ; }
qemu-config.c +1 -1
@@ -654,7 +654,7 @@ static QemuOptsList *find_list(QemuOptsList **lists, const char *group,break ; }if (lists[i] ==NULL ) { -error_set (errp,QERR_INVALID_OPTION_GROUP , group); +error_set (errp,/* QERR_INVALID_OPTION_GROUP */ 29 ,"There is no option group 'group=%s'" , group); }return lists[i]; }
qemu-ga.c +2 -2
@@ -511,7 +511,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens) qdict =qdict_new ();if (!err) {g_warning ("failed to parse event: unknown error" ); -error_set (&err,QERR_JSON_PARSING ); +error_set (&err,/* QERR_JSON_PARSING */ 37 ,"Invalid JSON syntax" ); }else {g_warning ("failed to parse event: %s" ,error_get_pretty (err)); }
@@ -531,7 +531,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)QDECREF (qdict); qdict =qdict_new ();g_warning ("unrecognized payload format" ); -error_set (&err,QERR_UNSUPPORTED ); +error_set (&err,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" );qdict_put_obj (qdict,"error" ,error_get_qobject (err));error_free (err); }
qemu-option.c +9 -9
@@ -178,7 +178,7 @@ static void parse_option_bool(const char *name, const char *value, bool *ret, }else if (!strcmp (value,"off" )) { *ret =0 ; }else { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name,"'on' or 'off'" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"'on' or 'off'" ); } }else { *ret =1 ;
@@ -194,12 +194,12 @@ static void parse_option_number(const char *name, const char *value,if (value !=NULL ) { number =strtoull (value, &postfix,0 );if (*postfix !='\0' ) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name,"a number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a number" );return ; } *ret = number; }else { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name,"a number" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a number" ); } }
@@ -230,13 +230,13 @@ static void parse_option_size(const char *name, const char *value, *ret = (uint64_t ) sizef;break ;default : -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name,"a size" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a size" );error_printf_unless_qmp ("You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n" );return ; } }else { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , name,"a size" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a size" ); } }
@@ -629,7 +629,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,if (i ==0 ) {/* empty list -> allow any */ ; }else { -error_set (errp,QERR_INVALID_PARAMETER , name); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name);return ; } }
@@ -761,14 +761,14 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,if (id) {if (!id_wellformed (id)) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"id" ,"an identifier" ); +error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"id" ,"an identifier" );error_printf_unless_qmp ("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n" );return NULL ; } opts =qemu_opts_find (list, id);if (opts !=NULL ) {if (fail_if_exists && !list->merge_lists) { -error_set (errp,QERR_DUPLICATE_ID , id, list->name); +error_set (errp,/* QERR_DUPLICATE_ID */ 24 ,"Duplicate ID 'id=%s' for object=%s" , id, list->name);return NULL ; }else {return opts;
@@ -1089,7 +1089,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) } }if (desc[i].name ==NULL ) { -error_set (errp,QERR_INVALID_PARAMETER , opt->name); +error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , opt->name);return ; }
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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" );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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" );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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); }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_SOCK_BIND_FAILED ); +error_set (errp,/* QERR_SOCK_BIND_FAILED */ 60 ,"Failed to bind socket" ); } } }
@@ -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_SOCK_LISTEN_FAILED ); +error_set (errp,/* QERR_SOCK_LISTEN_FAILED */ 64 ,"Failed to set socket to listening mode" );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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" );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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" );return -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_INPROGRESS ); +error_set (errp,/* QERR_SOCK_CONNECT_INPROGRESS */ 62 ,"Connection can not be completed immediately" ); }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_SOCK_CONNECT_FAILED ); +error_set (errp,/* QERR_SOCK_CONNECT_FAILED */ 61 ,"Failed to connect to socket" );freeaddrinfo (res);return -1 ; }
@@ -479,7 +479,7 @@ int inet_listen(const char *str, char *ostr, int olen, } } }else { -error_set (errp,QERR_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); }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_SOCK_CREATE_FAILED ); +error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); }qemu_opts_del (opts);return sock;
qga/commands-posix.c +38 -40
299 lines not on this page · raw message
qga/commands-win32.c +22 -31
173 lines not on this page · raw message
qmp.c +23 -24
173 lines not on this page · raw message
qom/object.c +10 -10
@@ -683,7 +683,7 @@ ObjectProperty *object_property_find(Object *obj, const char *name, } } -error_set (errp,QERR_PROPERTY_NOT_FOUND ,"" , name); +error_set (errp,/* QERR_PROPERTY_NOT_FOUND */ 47 ,"Property 'device=%s.property=%s' not found" ,"" , name);return NULL ; }
@@ -714,7 +714,7 @@ void object_property_get(Object *obj, Visitor *v, const char *name, }if (!prop->get) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); }else { prop->get (obj, v, prop->opaque, name, errp); }
@@ -729,7 +729,7 @@ void object_property_set(Object *obj, Visitor *v, const char *name, }if (!prop->set) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); }else { prop->set (obj, v, prop->opaque, name, errp); }
@@ -756,7 +756,7 @@ char *object_property_get_str(Object *obj, const char *name, } qstring =qobject_to_qstring (ret);if (!qstring) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name,"string" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"string" ); retval =NULL ; }else { retval =g_strdup (qstring_get_str (qstring));
@@ -782,7 +782,7 @@ Object *object_property_get_link(Object *obj, const char *name,if (str && *str) { target =object_resolve_path (str,NULL );if (!target) { -error_set (errp,QERR_DEVICE_NOT_FOUND , str); +error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , str); } }
@@ -811,7 +811,7 @@ bool object_property_get_bool(Object *obj, const char *name, } qbool =qobject_to_qbool (ret);if (!qbool) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name,"boolean" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"boolean" ); retval = false; }else { retval =qbool_get_int (qbool);
@@ -842,7 +842,7 @@ int64_t object_property_get_int(Object *obj, const char *name, } qint =qobject_to_qint (ret);if (!qint) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name,"int" ); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"int" ); retval =-1 ; }else { retval =qint_get_int (qint);
@@ -979,16 +979,16 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, target =object_resolve_path_type (path, target_type, &ambiguous);if (ambiguous) { -error_set (errp,QERR_AMBIGUOUS_PATH , path); +error_set (errp,/* QERR_AMBIGUOUS_PATH */ 1 ,"Path 'path=%s' does not uniquely identify an object" , path); }else if (target) {object_ref (target); *child = target; }else { target =object_resolve_path (path, &ambiguous);if (target || ambiguous) { -error_set (errp,QERR_INVALID_PARAMETER_TYPE , name, target_type); +error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name, target_type); }else { -error_set (errp,QERR_DEVICE_NOT_FOUND , path); +error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , path); } }g_free (target_type);
savevm.c +3 -3
@@ -1555,7 +1555,7 @@ bool qemu_savevm_state_blocked(Error **errp) QTAILQ_FOREACH(se, &savevm_handlers, entry) {if (se->no_migrate) { -error_set (errp,QERR_MIGRATION_NOT_SUPPORTED , se->idstr); +error_set (errp,/* QERR_MIGRATION_NOT_SUPPORTED */ 41 ,"State blocked by non-migratable device 'device=%s'" , se->idstr);return true; } }
@@ -2182,13 +2182,13 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) f =qemu_fopen (filename,"wb" );if (!f) { -error_set (errp,QERR_OPEN_FILE_FAILED , filename); +error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename); goto the_end; } ret =qemu_save_device_state (f);qemu_fclose (f);if (ret <0 ) { -error_set (errp,QERR_IO_ERROR ); +error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); } the_end:
target-i386/cpu.c +5 -10
@@ -631,8 +631,7 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , - name ? name :"null" , value, min, max); +error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -670,8 +669,7 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , - name ? name :"null" , value, min, max); +error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -706,8 +704,7 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,return ; }if (value < min || value > max) { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , - name ? name :"null" , value, min, max); +error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -772,8 +769,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,int i;if (strlen (value) !=12 ) { -error_set (errp,QERR_PROPERTY_VALUE_BAD ,"" , -"vendor" , value); +error_set (errp,/* QERR_PROPERTY_VALUE_BAD */ 48 ,"Property 'device=%s.property=%s' doesn't take value 'value=%s'" ,"" ,"vendor" , value);return ; }
@@ -848,8 +844,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , - name ? name :"null" , value, min, max); +error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
ui/vnc.c +2 -2
@@ -373,7 +373,7 @@ VncInfo *qmp_query_vnc(Error **errp)if (getsockname (vnc_display->lsock, (struct sockaddr *)&sa, &salen) ==-1 ) { -error_set (errp,QERR_UNDEFINED_ERROR ); +error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); goto out_error; }
@@ -381,7 +381,7 @@ VncInfo *qmp_query_vnc(Error **errp) host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV) < 0) { -error_set (errp,QERR_UNDEFINED_ERROR ); +error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); goto out_error; }
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 11/14 qerror: drop qerror_table[] for good
In reply to Luiz CapitulinoLast commit deprecated it. Also drops the code that used it to generate error objects.
--- qerror.c | 95 -------------------------------------------------- qerror.h | 6 ---- scripts/qapi-errors.py | 26 -------------- 3 files changed, 127 deletions(-)
qerror.c +0 -95
@@ -144,101 +144,6 @@ static QError *qerror_from_info(int err_class, const char *fmt, va_list *va)return qerr; } -static void parse_error (const QErrorStringTable *entry,int c) -{ -fprintf (stderr,"expected '%c' in '%s'" , c, entry->desc); -abort (); -} - -static const char *append_field (QDict *error,QString *outstr, -const QErrorStringTable *entry, -const char *start) -{ -QObject *obj; -QDict *qdict; -QString *key_qs; -const char *end, *key; - -if (*start !='%' ) -parse_error (entry,'%' ); - start++; -if (*start !='(' ) -parse_error (entry,'(' ); - start++; - - end =strchr (start,')' ); -if (!end) -parse_error (entry,')' ); - - key_qs =qstring_from_substr (start,0 , end - start -1 ); - key =qstring_get_str (key_qs); - - qdict =qobject_to_qdict (qdict_get (error,"data" )); - obj =qdict_get (qdict, key); -if (!obj) { -abort (); - } - -switch (qobject_type (obj)) { -case QTYPE_QSTRING : -qstring_append (outstr,qdict_get_str (qdict, key)); -break ; -case QTYPE_QINT : -qstring_append_int (outstr,qdict_get_int (qdict, key)); -break ; -default : -abort (); - } - -QDECREF (key_qs); -return ++end; -} - -static QString *qerror_format_desc (QDict *error, -const QErrorStringTable *entry) -{ -QString *qstring; -const char *p; - -assert (entry !=NULL ); - - qstring =qstring_new (); - -for (p = entry->desc; *p !='\0' ;) { -if (*p !='%' ) { -qstring_append_chr (qstring, *p++); - }else if (*(p +1 ) =='%' ) { -qstring_append_chr (qstring,'%' ); - p +=2 ; - }else { - p =append_field (error, qstring, entry, p); - } - } - -return qstring; -} - -char *qerror_format (const char *fmt,QDict *error) -{ -const QErrorStringTable *entry =NULL ; -QString *qstr; -char *ret; -int i; - -for (i =0 ; qerror_table[i].error_fmt; i++) { -if (strcmp (qerror_table[i].error_fmt, fmt) ==0 ) { - entry = &qerror_table[i]; -break ; - } - } - - qstr =qerror_format_desc (error, entry); - ret =g_strdup (qstring_get_str (qstr)); -QDECREF (qstr); - -return ret; -} -/** * qerror_human(): Format QError data into human-readable string. */
qerror.h +0 -6
@@ -19,11 +19,6 @@#include "error.h" #include <stdarg.h> -typedef struct QErrorStringTable { -const char *desc; -const char *error_fmt; -}QErrorStringTable ; - typedef struct QError { QObject_HEAD; QDict *error;
@@ -35,7 +30,6 @@ QString *qerror_human(const QError *qerror); void qerror_report(int err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void qerror_report_err (Error *err);void assert_no_error (Error *err); -char *qerror_format (const char *fmt,QDict *error);QDict *build_error_dict (int err_class,const char *msg);#endif /* QERROR_H */
scripts/qapi-errors.py +0 -26
@@ -62,29 +62,6 @@ def gen_error_macro(err_domain): string += cur return 'QERR_' + string.upper() -def gen_error_def_table(exprs): - ret = mcgen(''' -static const QErrorStringTable qerror_table[] = { -''') - - for err in exprs: - macro = gen_error_macro(err['error']) - desc = err['description'] - ret += mcgen(''' - { - .error_fmt = %(error_macro)s, - .desc = "%(error_desc)s", - }, -''', - error_macro=macro, error_desc=desc) - - ret += mcgen(''' - {} -}; -''') - - return ret - def gen_error_data_obj(data): colon = '' data_str = ''
@@ -206,9 +183,6 @@ if __name__ == '__main__': ret = gen_error_def_prologue(error_header=h_file, prefix=prefix) fdef.write(ret) - ret = gen_error_def_table(exprs) - fdef.write(ret) - ret = gen_error_obj_table(exprs) fdef.write(ret)
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
Re: [Qemu-devel] [PATCH 11/14] qerror: drop qerror_table[] for good
Quoted 1 line · Luiz Capitulino
Last commit deprecated it.
Do you mean "Unused since last commit"?
Quoted 2 lines
Also drops the code that used it to generate
error objects.
PATCH 12/14 error: turn QERR_ macros into an enumeration
In reply to Luiz CapitulinoThe enum is called ErrClass, and is autogenerated.
FIXME: also converts error_is_type() and probably breaks other error
functions used to query the error object.
--- error.c | 24 ++---------------------- error.h | 3 ++- scripts/qapi-errors.py | 47 ++++++++++++++++++----------------------------- 3 files changed, 22 insertions(+), 52 deletions(-)
error.c +2 -22
@@ -102,29 +102,9 @@ void error_free(Error *err) } } -bool error_is_type (Error *err,const char *fmt) +bool error_is_type (Error *err,ErrClass err_class) { -const char *error_class; -char *ptr; -char *end; - -if (!err) { -return false; - } - - ptr =strstr (fmt,"'class': '" ); -assert (ptr !=NULL ); - ptr +=strlen ("'class': '" ); - - end =strchr (ptr,'\'' ); -assert (end !=NULL ); - - error_class =error_get_field (err,"class" ); -if (strlen (error_class) != end - ptr) { -return false; - } - -return strncmp (ptr, error_class, end - ptr) ==0 ; +return (err && (err->err_class == err_class)); }void error_propagate (Error **dst_err,Error *local_err)
error.h +2 -1
@@ -13,6 +13,7 @@#define ERROR_H #include "compiler.h" +#include "qapi-errors.h" #include <stdbool.h> /**
@@ -70,6 +71,6 @@ void error_free(Error *err);* Determine if an error is of a speific type (based on the qerror format). * Non-QEMU users should get the `class' field to identify the error type. */ -bool error_is_type (Error *err,const char *fmt); +bool error_is_type (Error *err,ErrClass err_class);#endif
scripts/qapi-errors.py +18 -29
80 lines not on this page · raw message
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 13/14 qerror: change all qerror_report() calls to use the ErrClass enum
In reply to Luiz Capitulino--- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- blockdev.c | 10 +++++----- hw/pci.c | 4 ++-- hw/qdev-monitor.c | 22 +++++++++++----------- hw/usb/bus.c | 2 +- hw/usb/hcd-ehci.c | 4 ++-- hw/usb/redirect.c | 4 ++-- monitor.c | 48 ++++++++++++++++++++++++------------------------ qemu-option.c | 2 +- 12 files changed, 52 insertions(+), 52 deletions(-)
block/cow.c +1 -1
@@ -81,7 +81,7 @@ static int cow_open(BlockDriverState *bs, int flags)char version[64 ];snprintf (version,sizeof (version),"COW version %d" , cow_header.version); -qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"cow" , version); +qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"cow" , version); ret = -ENOTSUP ; goto fail; }
block/qcow.c +1 -1
@@ -118,7 +118,7 @@ static int qcow_open(BlockDriverState *bs, int flags)if (header.version !=QCOW_VERSION ) {char version[64 ];snprintf (version,sizeof (version),"QCOW version %d" , header.version); -qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow" , version); +qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow" , version); ret = -ENOTSUP ; goto fail; }
block/qcow2.c +1 -1
@@ -192,7 +192,7 @@ static void GCC_FMT_ATTR(2, 3) report_unsupported(BlockDriverState *bs,vsnprintf (msg,sizeof (msg), fmt, ap);va_end (ap); -qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow2" , msg); +qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"qcow2" , msg); } static void report_unsupported_feature(BlockDriverState *bs,
block/qed.c +1 -1
@@ -397,7 +397,7 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)char buf[64 ];snprintf (buf,sizeof (buf),"%" PRIx64, s->header.features & ~QED_FEATURE_MASK ); -qerror_report (/* QERR_UNKNOWN_BLOCK_FORMAT_FEATURE */ 67 ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"QED" , buf); +qerror_report (QERR_UNKNOWN_BLOCK_FORMAT_FEATURE ,"'device=%s' uses a format=%s feature which is not supported by this qemu version: feature=%s" , bs->device_name,"QED" , buf);return -ENOTSUP ; }if (!qed_is_cluster_size_valid (s->header.cluster_size)) {
blockdev.c +5 -5
@@ -633,18 +633,18 @@ void do_commit(Monitor *mon, const QDict *qdict)if (!strcmp (device,"all" )) { ret =bdrv_commit_all ();if (ret == -EBUSY ) { -qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , device); +qerror_report (QERR_DEVICE_IN_USE ,"Device 'device=%s' is in use" , device);return ; } }else { bs =bdrv_find (device);if (!bs) { -qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , device); +qerror_report (QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , device);return ; } ret =bdrv_commit (bs);if (ret == -EBUSY ) { -qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , device); +qerror_report (QERR_DEVICE_IN_USE ,"Device 'device=%s' is in use" , device);return ; } }
@@ -984,11 +984,11 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) bs =bdrv_find (id);if (!bs) { -qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id); +qerror_report (QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , id);return -1 ; }if (bdrv_in_use (bs)) { -qerror_report (/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" , id); +qerror_report (QERR_DEVICE_IN_USE ,"Device 'device=%s' is in use" , id);return -1 ; }
hw/pci.c +2 -2
@@ -1506,7 +1506,7 @@ static int pci_qdev_init(DeviceState *qdev)if (pci_dev ==NULL )return -1 ;if (qdev->hotplugged && pc->no_hotplug) { -qerror_report (/* QERR_DEVICE_NO_HOTPLUG */ 19 ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (pci_dev))); +qerror_report (QERR_DEVICE_NO_HOTPLUG ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (pci_dev)));do_pci_unregister_device (pci_dev);return -1 ; }
@@ -1547,7 +1547,7 @@ static int pci_unplug_device(DeviceState *qdev)PCIDeviceClass *pc =PCI_DEVICE_GET_CLASS (dev);if (pc->no_hotplug) { -qerror_report (/* QERR_DEVICE_NO_HOTPLUG */ 19 ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (dev))); +qerror_report (QERR_DEVICE_NO_HOTPLUG ,"Device 'device=%s' does not support hotplugging" ,object_get_typename (OBJECT (dev)));return -1 ; } return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
hw/qdev-monitor.c +11 -11
@@ -326,7 +326,7 @@ static BusState *qbus_find(const char *path) } bus =qbus_find_recursive (sysbus_get_default (), elem,NULL );if (!bus) { -qerror_report (/* QERR_BUS_NOT_FOUND */ 7 ,"Bus 'bus=%s' not found" , elem); +qerror_report (QERR_BUS_NOT_FOUND ,"Bus 'bus=%s' not found" , elem);return NULL ; } pos = len;
@@ -349,7 +349,7 @@ static BusState *qbus_find(const char *path) pos += len; dev =qbus_find_dev (bus, elem);if (!dev) { -qerror_report (/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , elem); +qerror_report (QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_dev (bus); }
@@ -365,12 +365,12 @@ static BusState *qbus_find(const char *path)* one child bus accept it nevertheless */ switch (dev->num_child_bus) {case 0 : -qerror_report (/* QERR_DEVICE_NO_BUS */ 18 ,"Device 'device=%s' has no child bus" , elem); +qerror_report (QERR_DEVICE_NO_BUS ,"Device 'device=%s' has no child bus" , elem);return NULL ;case 1 :return QLIST_FIRST (&dev->child_bus);default : -qerror_report (/* QERR_DEVICE_MULTIPLE_BUSSES */ 17 ,"Device 'device=%s' has multiple child busses" , elem); +qerror_report (QERR_DEVICE_MULTIPLE_BUSSES ,"Device 'device=%s' has multiple child busses" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_bus (dev); }
@@ -386,7 +386,7 @@ static BusState *qbus_find(const char *path) pos += len; bus =qbus_find_bus (dev, elem);if (!bus) { -qerror_report (/* QERR_BUS_NOT_FOUND */ 7 ,"Bus 'bus=%s' not found" , elem); +qerror_report (QERR_BUS_NOT_FOUND ,"Bus 'bus=%s' not found" , elem);if (!monitor_cur_is_qmp ()) {qbus_list_bus (dev); }
@@ -405,7 +405,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) driver =qemu_opt_get (opts,"driver" );if (!driver) { -qerror_report (/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"driver" ); +qerror_report (QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"driver" );return NULL ; }
@@ -421,7 +421,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) }if (!obj) { -qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"driver" ,"device type" ); +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"driver" ,"device type" );return NULL ; }
@@ -435,18 +435,18 @@ DeviceState *qdev_device_add(QemuOpts *opts)return NULL ; }if (strcmp (object_get_typename (OBJECT (bus)), k->bus_type) !=0 ) { -qerror_report (/* QERR_BAD_BUS_FOR_DEVICE */ 2 ,"Device 'device=%s' can't go on a bad_bus_type=%s bus" , driver,object_get_typename (OBJECT (bus))); +qerror_report (QERR_BAD_BUS_FOR_DEVICE ,"Device 'device=%s' can't go on a bad_bus_type=%s bus" , driver,object_get_typename (OBJECT (bus)));return NULL ; } }else { bus =qbus_find_recursive (sysbus_get_default (),NULL , k->bus_type);if (!bus) { -qerror_report (/* QERR_NO_BUS_FOR_DEVICE */ 43 ,"No 'bus=%s' bus found for device 'device=%s'" , driver, k->bus_type); +qerror_report (QERR_NO_BUS_FOR_DEVICE ,"No 'bus=%s' bus found for device 'device=%s'" , driver, k->bus_type);return NULL ; } }if (qdev_hotplug && !bus->allow_hotplug) { -qerror_report (/* QERR_BUS_NO_HOTPLUG */ 6 ,"Bus 'bus=%s' does not support hotplugging" , bus->name); +qerror_report (QERR_BUS_NO_HOTPLUG ,"Bus 'bus=%s' does not support hotplugging" , bus->name);return NULL ; }
@@ -477,7 +477,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)g_free (name); }if (qdev_init (qdev) <0 ) { -qerror_report (/* QERR_DEVICE_INIT_FAILED */ 13 ,"Device 'device=%s' could not be initialized" , driver); +qerror_report (QERR_DEVICE_INIT_FAILED ,"Device 'device=%s' could not be initialized" , driver);return NULL ; } qdev->opts = opts;
hw/usb/bus.c +1 -1
@@ -303,7 +303,7 @@ int usb_register_companion(const char *masterbus, USBPort *ports[], }if (!bus || !bus->ops->register_companion) { -qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" ); +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" );if (bus) { error_printf_unless_qmp( "USB bus '%s' does not allow companion controllers\n",
hw/usb/hcd-ehci.c +2 -2
@@ -933,7 +933,7 @@ static int ehci_register_companion(USBBus *bus, USBPort *ports[],uint32_t i;if (firstport + portcount >NB_PORTS ) { -qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"firstport" ,"firstport on masterbus" ); +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"firstport" ,"firstport on masterbus" ); error_printf_unless_qmp( "firstport value of %u makes companion take ports %u - %u, which " "is outside of the valid range of 0 - %u\n", firstport, firstport,
@@ -943,7 +943,7 @@ static int ehci_register_companion(USBBus *bus, USBPort *ports[],for (i =0 ; i < portcount; i++) {if (s->companion_ports[firstport + i]) { -qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" ); +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"masterbus" ,"an USB masterbus" );error_printf_unless_qmp ("port %u on masterbus %s already has a companion assigned\n" , firstport + i, bus->qbus.name);
hw/usb/redirect.c +2 -2
@@ -902,7 +902,7 @@ static int usbredir_initfn(USBDevice *udev)int i;if (dev->cs ==NULL ) { -qerror_report (/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"chardev" ); +qerror_report (QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"chardev" );return -1 ; }
@@ -911,7 +911,7 @@ static int usbredir_initfn(USBDevice *udev) &dev->filter_rules, &dev->filter_rules_count);if (i) { -qerror_report (/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"filter" ,"a usb device filter string" ); +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"filter" ,"a usb device filter string" );return -1 ; } }
monitor.c +24 -24
184 lines not on this page · raw message
qemu-option.c +1 -1
@@ -690,7 +690,7 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)if (i ==0 ) {/* empty list -> allow any */ ; }else { -qerror_report (/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name); +qerror_report (QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" , name);return -1 ; } }
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
PATCH 14/14 error: change all error_set() calls to use the ErrClass enum
In reply to Luiz Capitulino--- balloon.c | 10 +++--- block.c | 4 +-- block/qcow.c | 2 +- block/stream.c | 2 +- block/vdi.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- block/vvfat.c | 2 +- blockdev.c | 68 ++++++++++++++++++++-------------------- cpus.c | 12 +++---- dump-stub.c | 2 +- dump.c | 18 +++++------ hmp.c | 2 +- hw/9pfs/virtio-9p.c | 2 +- hw/ivshmem.c | 2 +- hw/pci-stub.c | 2 +- hw/qdev-addr.c | 4 +-- hw/qdev-monitor.c | 2 +- hw/qdev-properties.c | 42 ++++++++++++------------- hw/qdev.c | 6 ++-- json-parser.c | 2 +- migration.c | 6 ++-- monitor.c | 8 ++--- net.c | 18 +++++------ qapi/qapi-visit-core.c | 16 +++++----- qapi/qmp-dispatch.c | 12 +++---- qapi/qmp-input-visitor.c | 16 +++++----- qapi/string-input-visitor.c | 8 ++--- qemu-config.c | 2 +- qemu-ga.c | 4 +-- qemu-option.c | 18 +++++------ qemu-sockets.c | 22 ++++++------- qga/commands-posix.c | 76 ++++++++++++++++++++++----------------------- qga/commands-win32.c | 44 +++++++++++++------------- qmp.c | 46 +++++++++++++-------------- qom/object.c | 20 ++++++------ savevm.c | 6 ++-- target-i386/cpu.c | 10 +++--- ui/vnc.c | 4 +-- 39 files changed, 263 insertions(+), 263 deletions(-)
balloon.c +5 -5
@@ -99,14 +99,14 @@ BalloonInfo *qmp_query_balloon(Error **errp)BalloonInfo *info;if (kvm_enabled () && !kvm_has_sync_mmu ()) { -error_set (errp,/* QERR_KVM_MISSING_CAP */ 38 ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" ); +error_set (errp,QERR_KVM_MISSING_CAP ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" );return NULL ; } info =g_malloc0 (sizeof (*info));if (qemu_balloon_status (info) ==0 ) { -error_set (errp,/* QERR_DEVICE_NOT_ACTIVE */ 20 ,"Device 'device=%s' has not been activated" ,"balloon" ); +error_set (errp,QERR_DEVICE_NOT_ACTIVE ,"Device 'device=%s' has not been activated" ,"balloon" );qapi_free_BalloonInfo (info);return NULL ; }
@@ -117,16 +117,16 @@ BalloonInfo *qmp_query_balloon(Error **errp)void qmp_balloon (int64_t value,Error **errp) {if (kvm_enabled () && !kvm_has_sync_mmu ()) { -error_set (errp,/* QERR_KVM_MISSING_CAP */ 38 ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" ); +error_set (errp,QERR_KVM_MISSING_CAP ,"Using KVM without capability=%s, feature=%s unavailable" ,"synchronous MMU" ,"balloon" );return ; }if (value <=0 ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"target" ,"a size" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"target" ,"a size" );return ; }if (qemu_balloon (value) ==0 ) { -error_set (errp,/* QERR_DEVICE_NOT_ACTIVE */ 20 ,"Device 'device=%s' has not been activated" ,"balloon" ); +error_set (errp,QERR_DEVICE_NOT_ACTIVE ,"Device 'device=%s' has not been activated" ,"balloon" ); } }
block.c +2 -2
@@ -4034,7 +4034,7 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,BlockJob *job;if (bs->job ||bdrv_in_use (bs)) { -error_set (errp,/* QERR_DEVICE_IN_USE */ 14 ,"Device 'device=%s' is in use" ,bdrv_get_device_name (bs)); +error_set (errp,QERR_DEVICE_IN_USE ,"Device 'device=%s' is in use" ,bdrv_get_device_name (bs));return NULL ; }bdrv_set_in_use (bs,1 );
@@ -4079,7 +4079,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)Error *local_err =NULL ;if (!job->job_type->set_speed) { -error_set (errp,/* QERR_NOT_SUPPORTED */ 44 ,"Not supported" ); +error_set (errp,QERR_NOT_SUPPORTED ,"Not supported" );return ; } job->job_type->set_speed (job, speed, &local_err);
block/qcow.c +1 -1
@@ -180,7 +180,7 @@ static int qcow_open(BlockDriverState *bs, int flags) }/* Disable migration when qcow images are used */ -error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"qcow" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"qcow" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);qemu_co_mutex_init (&s->lock);
block/stream.c +1 -1
@@ -168,7 +168,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)StreamBlockJob *s =container_of (job, StreamBlockJob, common);if (speed <0 ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"speed" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" ,"speed" );return ; }ratelimit_set_speed (&s->limit, speed /BDRV_SECTOR_SIZE ,SLICE_TIME );
block/vdi.c +1 -1
@@ -440,7 +440,7 @@ static int vdi_open(BlockDriverState *bs, int flags) }/* Disable migration when vdi images are used */ -error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vdi" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vdi" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vmdk.c +1 -1
@@ -663,7 +663,7 @@ static int vmdk_open(BlockDriverState *bs, int flags)qemu_co_mutex_init (&s->lock);/* Disable migration when VMDK images are used */ -error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vmdk" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vmdk" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vpc.c +1 -1
@@ -255,7 +255,7 @@ static int vpc_open(BlockDriverState *bs, int flags)qemu_co_mutex_init (&s->lock);/* Disable migration when VHD images are used */ -error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vpc" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vpc" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker);return 0 ;
block/vvfat.c +1 -1
@@ -1091,7 +1091,7 @@ DLOG(if (stderr == NULL) {/* Disable migration when vvfat is used rw */ if (s->qcow) { -error_set (&s->migration_blocker,/* QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED */ 4 ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vvfat (rw)" , bs->device_name,"live migration" ); +error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"Block format 'format=%s' used by device 'name=%s' does not support feature 'feature=%s'" ,"vvfat (rw)" , bs->device_name,"live migration" );migrate_add_blocker (s->migration_blocker); }
blockdev.c +34 -34
232 lines not on this page · raw message
cpus.c +6 -6
@@ -1246,13 +1246,13 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, }if (env ==NULL ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" );return ; } f =fopen (filename,"wb" );if (!f) { -error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename); +error_set (errp,QERR_OPEN_FILE_FAILED ,"Could not open 'filename=%s'" , filename);return ; }
@@ -1262,7 +1262,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, l = size;cpu_memory_rw_debug (env, addr, buf, l,0 );if (fwrite (buf,1 , l, f) != l) { -error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); +error_set (errp,QERR_IO_ERROR ,"An IO error has occurred" ); goto exit; } addr += l;
@@ -1282,7 +1282,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, f =fopen (filename,"wb" );if (!f) { -error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename); +error_set (errp,QERR_OPEN_FILE_FAILED ,"Could not open 'filename=%s'" , filename);return ; }
@@ -1292,7 +1292,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, l = size;cpu_physical_memory_rw (addr, buf, l,0 );if (fwrite (buf,1 , l, f) != l) { -error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); +error_set (errp,QERR_IO_ERROR ,"An IO error has occurred" ); goto exit; } addr += l;
@@ -1316,6 +1316,6 @@ void qmp_inject_nmi(Error **errp) } }#else -error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); +error_set (errp,QERR_UNSUPPORTED ,"this feature or command is not currently supported" );#endif }
dump-stub.c +1 -1
@@ -21,7 +21,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, int64_t begin, bool has_length, int64_t length, Error **errp) { - error_set(errp, /* QERR_UNSUPPORTED */ 68, "this feature or command is not currently supported"); + error_set(errp, QERR_UNSUPPORTED, "this feature or command is not currently supported"); } int cpu_write_elf64_note(write_core_dump_function f,
dump.c +9 -9
@@ -721,7 +721,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, s->length = length; s->start =get_start_block (s);if (s->start ==-1 ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"begin" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" ,"begin" ); goto cleanup; }
@@ -741,14 +741,14 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, ret =cpu_get_dump_info (&s->dump_info);if (ret <0 ) { -error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); +error_set (errp,QERR_UNSUPPORTED ,"this feature or command is not currently supported" ); goto cleanup; } s->note_size =cpu_get_note_size (s->dump_info.d_class, s->dump_info.d_machine, nr_cpus);if (ret <0 ) { -error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); +error_set (errp,QERR_UNSUPPORTED ,"this feature or command is not currently supported" ); goto cleanup; }
@@ -826,11 +826,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,int ret;if (has_begin && !has_length) { -error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"length" ); +error_set (errp,QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"length" );return ; }if (!has_begin && has_length) { -error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"begin" ); +error_set (errp,QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"begin" );return ; }
@@ -838,7 +838,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,if (strstart (file,"fd:" , &p)) { fd =monitor_get_fd (cur_mon, p);if (fd ==-1 ) { -error_set (errp,/* QERR_FD_NOT_FOUND */ 25 ,"File descriptor named 'name=%s' not found" , p); +error_set (errp,QERR_FD_NOT_FOUND ,"File descriptor named 'name=%s' not found" , p);return ; } }
@@ -847,13 +847,13 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,if (strstart (file,"file:" , &p)) { fd =qemu_open (p,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,S_IRUSR );if (fd <0 ) { -error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , p); +error_set (errp,QERR_OPEN_FILE_FAILED ,"Could not open 'filename=%s'" , p);return ; } }if (fd ==-1 ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"protocol" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" ,"protocol" );return ; }
@@ -866,7 +866,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, }if (create_vmcore (s) <0 && !error_is_set (s->errp)) { -error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); +error_set (errp,QERR_IO_ERROR ,"An IO error has occurred" ); }g_free (s);
hmp.c +1 -1
@@ -707,7 +707,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)if (!filename) {/* In the future, if 'snapshot-file' is not specified, the snapshot will be taken internally. Today it's actually required. */ -error_set (&errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"snapshot-file" ); +error_set (&errp,QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"snapshot-file" );hmp_handle_error (mon, &errp);return ; }
hw/9pfs/virtio-9p.c +1 -1
@@ -985,7 +985,7 @@ static void v9fs_attach(void *opaque) qid.type, qid.version, qid.path); s->root_fid = fid;/* disable migration */ -error_set (&s->migration_blocker,/* QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION */ 69 ,"Migration is disabled when VirtFS export path 'path=%s' is mounted in the guest using mount_tag 'tag=%s'" , s->ctx.fs_root ? s->ctx.fs_root :"NULL" , s->tag); +error_set (&s->migration_blocker,QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION ,"Migration is disabled when VirtFS export path 'path=%s' is mounted in the guest using mount_tag 'tag=%s'" , s->ctx.fs_root ? s->ctx.fs_root :"NULL" , s->tag);migrate_add_blocker (s->migration_blocker); out:put_fid (pdu, fidp);
hw/ivshmem.c +1 -1
@@ -681,7 +681,7 @@ static int pci_ivshmem_init(PCIDevice *dev) }if (s->role_val ==IVSHMEM_PEER ) { -error_set (&s->migration_blocker,/* QERR_DEVICE_FEATURE_BLOCKS_MIGRATION */ 11 ,"Migration is disabled when using feature 'feature=%s' in device 'device=%s'" ,"ivshmem" ,"peer mode" ); +error_set (&s->migration_blocker,QERR_DEVICE_FEATURE_BLOCKS_MIGRATION ,"Migration is disabled when using feature 'feature=%s' in device 'device=%s'" ,"ivshmem" ,"peer mode" );migrate_add_blocker (s->migration_blocker); }
hw/pci-stub.c +1 -1
@@ -25,7 +25,7 @@PciInfoList *qmp_query_pci (Error **errp) { -error_set (errp,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); +error_set (errp,QERR_UNSUPPORTED ,"this feature or command is not currently supported" );return NULL ; }
hw/qdev-addr.c +2 -2
@@ -40,7 +40,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,int64_t value;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); +error_set (errp,QERR_PERMISSION_DENIED ,"Insufficient permission to perform this operation" );return ; }
@@ -52,7 +52,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,if ((uint64_t )value <= (uint64_t ) ~(target_phys_addr_t )0 ) { *ptr = value; }else { -error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" , dev->id?:"" , name, value, (uint64_t )0 , (uint64_t ) ~(target_phys_addr_t )0 ); +error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" , dev->id?:"" , name, value, (uint64_t )0 , (uint64_t ) ~(target_phys_addr_t )0 ); } }
hw/qdev-monitor.c +1 -1
@@ -600,7 +600,7 @@ void qmp_device_del(const char *id, Error **errp) dev =qdev_find_recursive (sysbus_get_default (), id);if (NULL == dev) { -error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id); +error_set (errp,QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , id);return ; }
hw/qdev-properties.c +21 -21
160 lines not on this page · raw message
hw/qdev.c +3 -3
@@ -199,7 +199,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)DeviceClass *dc =DEVICE_GET_CLASS (dev);if (!dev->parent_bus->allow_hotplug) { -error_set (errp,/* QERR_BUS_NO_HOTPLUG */ 6 ,"Bus 'bus=%s' does not support hotplugging" , dev->parent_bus->name); +error_set (errp,QERR_BUS_NO_HOTPLUG ,"Bus 'bus=%s' does not support hotplugging" , dev->parent_bus->name);return ; }assert (dc->unplug !=NULL );
@@ -207,7 +207,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) qdev_hot_removed = true;if (dc->unplug (dev) <0 ) { -error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); +error_set (errp,QERR_UNDEFINED_ERROR ,"An undefined error has occurred" );return ; } }
@@ -570,7 +570,7 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,int ret;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); +error_set (errp,QERR_PERMISSION_DENIED ,"Insufficient permission to perform this operation" );return ; }
json-parser.c +1 -1
@@ -105,7 +105,7 @@ static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,error_free (ctxt->err); ctxt->err =NULL ; } -error_set (&ctxt->err,/* QERR_JSON_PARSE_ERROR */ 36 ,"JSON parse error, message=%s" , message); +error_set (&ctxt->err,QERR_JSON_PARSE_ERROR ,"JSON parse error, message=%s" , message); }/**
migration.c +3 -3
@@ -412,7 +412,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, params.shared = inc;if (s->state ==MIG_STATE_ACTIVE ) { -error_set (errp,/* QERR_MIGRATION_ACTIVE */ 39 ,"There\'s a migration process in progress" ); +error_set (errp,QERR_MIGRATION_ACTIVE ,"There\'s a migration process in progress" );return ; }
@@ -438,7 +438,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, ret =fd_start_outgoing_migration (s, p);#endif }else { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"uri" ,"a valid migration protocol" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"uri" ,"a valid migration protocol" );return ; }
@@ -446,7 +446,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,if (!error_is_set (errp)) {DPRINTF ("migration failed: %s\n" ,strerror (-ret));/* FIXME: we should return meaningful errors */ -error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); +error_set (errp,QERR_UNDEFINED_ERROR ,"An undefined error has occurred" ); }return ; }
monitor.c +4 -4
@@ -626,7 +626,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,int ret =monitor_set_cpu (cpu_index);if (ret <0 ) { cur_mon = old_mon; -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"cpu-index" ,"a CPU number" ); goto out; } }
@@ -2284,12 +2284,12 @@ void qmp_getfd(const char *fdname, Error **errp) fd =qemu_chr_fe_get_msgfd (cur_mon->chr);if (fd ==-1 ) { -error_set (errp,/* QERR_FD_NOT_SUPPLIED */ 26 ,"No file descriptor supplied via SCM_RIGHTS" ); +error_set (errp,QERR_FD_NOT_SUPPLIED ,"No file descriptor supplied via SCM_RIGHTS" );return ; }if (qemu_isdigit (fdname[0 ])) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"fdname" ,"a name not starting with a digit" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"fdname" ,"a name not starting with a digit" );return ; }
@@ -2326,7 +2326,7 @@ void qmp_closefd(const char *fdname, Error **errp)return ; } -error_set (errp,/* QERR_FD_NOT_FOUND */ 25 ,"File descriptor named 'name=%s' not found" , fdname); +error_set (errp,QERR_FD_NOT_FOUND ,"File descriptor named 'name=%s' not found" , fdname); }static void do_loadvm (Monitor *mon,const QDict *qdict)
net.c +9 -9
@@ -1089,7 +1089,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) type =qemu_opt_get (opts,"type" );if (!type) { -error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"type" ); +error_set (errp,QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"type" );return -1 ; }
@@ -1105,20 +1105,20 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) strcmp(type, "vde") != 0 && #endif strcmp(type, "socket") != 0) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a netdev backend type" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a netdev backend type" );return -1 ; }if (qemu_opt_get (opts,"vlan" )) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"vlan" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" ,"vlan" );return -1 ; }if (qemu_opt_get (opts,"name" )) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" ,"name" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" ,"name" );return -1 ; }if (!qemu_opts_id (opts)) { -error_set (errp,/* QERR_MISSING_PARAMETER */ 42 ,"Parameter 'name=%s' is missing" ,"id" ); +error_set (errp,QERR_MISSING_PARAMETER ,"Parameter 'name=%s' is missing" ,"id" );return -1 ; } }
@@ -1153,7 +1153,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) ret = net_client_types[i].init (opts, name, vlan);if (ret <0 ) {/* TODO push error reporting into init() methods */ -error_set (errp,/* QERR_DEVICE_INIT_FAILED */ 13 ,"Device 'device=%s' could not be initialized" , type); +error_set (errp,QERR_DEVICE_INIT_FAILED ,"Device 'device=%s' could not be initialized" , type);return -1 ; } }
@@ -1161,7 +1161,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) } } -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a network client type" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"type" ,"a network client type" );return -1 ; }
@@ -1273,7 +1273,7 @@ void qmp_netdev_del(const char *id, Error **errp) vc =qemu_find_netdev (id);if (!vc) { -error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , id); +error_set (errp,QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , id);return ; }
@@ -1336,7 +1336,7 @@ void qmp_set_link(const char *name, bool up, Error **errp) done:if (!vc) { -error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , name); +error_set (errp,QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , name);return ; }
qapi/qapi-visit-core.c +8 -8
@@ -107,7 +107,7 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT8_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint8_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint8_t" );return ; } *obj = value;
@@ -125,7 +125,7 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT16_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint16_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint16_t" );return ; } *obj = value;
@@ -143,7 +143,7 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp value = *obj; v->type_int (v, &value, name, errp);if (value <0 || value >UINT32_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint32_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"uint32_t" );return ; } *obj = value;
@@ -175,7 +175,7 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT8_MIN || value >INT8_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int8_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int8_t" );return ; } *obj = value;
@@ -193,7 +193,7 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT16_MIN || value >INT16_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int16_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int16_t" );return ; } *obj = value;
@@ -211,7 +211,7 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp) value = *obj; v->type_int (v, &value, name, errp);if (value <INT32_MIN || value >INT32_MAX ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int32_t" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name ? name :"null" ,"int32_t" );return ; } *obj = value;
@@ -262,7 +262,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],assert (strings);while (strings[i++] !=NULL );if (value <0 || value >= i -1 ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name ? name :"null" ); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" , name ? name :"null" );return ; }
@@ -292,7 +292,7 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], }if (strings[value] ==NULL ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , enum_str); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" , enum_str);g_free (enum_str);return ; }
qapi/qmp-dispatch.c +6 -6
@@ -27,7 +27,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)QDict *dict =NULL ;if (qobject_type (request) !=QTYPE_QDICT ) { -error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT */ 55 ,"Expected 'expected=%s' in QMP input" ,"request is not a dictionary" ); +error_set (errp,QERR_QMP_BAD_INPUT_OBJECT ,"Expected 'expected=%s' in QMP input" ,"request is not a dictionary" );return NULL ; }
@@ -40,18 +40,18 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)if (!strcmp (arg_name,"execute" )) {if (qobject_type (arg_obj) !=QTYPE_QSTRING ) { -error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT_MEMBER */ 56 ,"QMP input object member 'member=%s' expects 'expected=%s'" ,"execute" ,"string" ); +error_set (errp,QERR_QMP_BAD_INPUT_OBJECT_MEMBER ,"QMP input object member 'member=%s' expects 'expected=%s'" ,"execute" ,"string" );return NULL ; } has_exec_key = true; }else if (strcmp (arg_name,"arguments" )) { -error_set (errp,/* QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER */ 57 ,"QMP input object member 'member=%s' is unexpected" , arg_name); +error_set (errp,QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER ,"QMP input object member 'member=%s' is unexpected" , arg_name);return NULL ; } }if (!has_exec_key) { -error_set (errp,/* QERR_QMP_BAD_INPUT_OBJECT */ 55 ,"Expected 'expected=%s' in QMP input" ,"execute" ); +error_set (errp,QERR_QMP_BAD_INPUT_OBJECT ,"Expected 'expected=%s' in QMP input" ,"execute" );return NULL ; }
@@ -74,11 +74,11 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp) command =qdict_get_str (dict,"execute" ); cmd =qmp_find_command (command);if (cmd ==NULL ) { -error_set (errp,/* QERR_COMMAND_NOT_FOUND */ 9 ,"The command name=%s has not been found" , command); +error_set (errp,QERR_COMMAND_NOT_FOUND ,"The command name=%s has not been found" , command);return NULL ; }if (!cmd->enabled) { -error_set (errp,/* QERR_COMMAND_DISABLED */ 8 ,"The command name=%s has been disabled for this instance" , command); +error_set (errp,QERR_COMMAND_DISABLED ,"The command name=%s has been disabled for this instance" , command);return NULL ; }
qapi/qmp-input-visitor.c +8 -8
@@ -70,7 +70,7 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp)GHashTable *h;if (qiv->nb_stack >=QIV_STACK_SIZE ) { -error_set (errp,/* QERR_BUFFER_OVERRUN */ 5 ,"An internal buffer overran" ); +error_set (errp,QERR_BUFFER_OVERRUN ,"An internal buffer overran" );return ; }
@@ -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_INPUT_OBJECT_MEMBER */ 57 ,"QMP input object member 'member=%s' is unexpected" , key); +error_set (errp,QERR_QMP_EXTRA_INPUT_OBJECT_MEMBER ,"QMP input object member 'member=%s' is unexpected" , key); }g_hash_table_unref (top_ht); }
@@ -121,7 +121,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,Error *err =NULL ;if (!qobj ||qobject_type (qobj) !=QTYPE_QDICT ) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"QDict" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"QDict" );return ; }
@@ -149,7 +149,7 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp)QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QLIST ) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"list" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"list" );return ; }
@@ -200,7 +200,7 @@ static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QINT ) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" );return ; }
@@ -214,7 +214,7 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QBOOL ) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" );return ; }
@@ -228,7 +228,7 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,QObject *qobj =qmp_input_get_object (qiv, name);if (!qobj ||qobject_type (qobj) !=QTYPE_QSTRING ) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" );return ; }
@@ -243,7 +243,7 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,if (!qobj || (qobject_type (qobj) !=QTYPE_QFLOAT &&qobject_type (qobj) !=QTYPE_QINT )) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" );return ; }
qapi/string-input-visitor.c +4 -4
@@ -33,7 +33,7 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name, val =strtoll (siv->string, &endp,0 ); }if (!siv->string || errno || endp == siv->string || *endp) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"integer" );return ; }
@@ -60,7 +60,7 @@ static void parse_type_bool(Visitor *v, bool *obj, const char *name, } } -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"boolean" ); } static void parse_type_str(Visitor *v, char **obj, const char *name,
@@ -70,7 +70,7 @@ static void parse_type_str(Visitor *v, char **obj, const char *name,if (siv->string) { *obj =g_strdup (siv->string); }else { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"string" ); } }
@@ -86,7 +86,7 @@ static void parse_type_number(Visitor *v, double *obj, const char *name, val =strtod (siv->string, &endp); }if (!siv->string || errno || endp == siv->string || *endp) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name ? name :"null" ,"number" );return ; }
qemu-config.c +1 -1
@@ -654,7 +654,7 @@ static QemuOptsList *find_list(QemuOptsList **lists, const char *group,break ; }if (lists[i] ==NULL ) { -error_set (errp,/* QERR_INVALID_OPTION_GROUP */ 29 ,"There is no option group 'group=%s'" , group); +error_set (errp,QERR_INVALID_OPTION_GROUP ,"There is no option group 'group=%s'" , group); }return lists[i]; }
qemu-ga.c +2 -2
@@ -511,7 +511,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens) qdict =qdict_new ();if (!err) {g_warning ("failed to parse event: unknown error" ); -error_set (&err,/* QERR_JSON_PARSING */ 37 ,"Invalid JSON syntax" ); +error_set (&err,QERR_JSON_PARSING ,"Invalid JSON syntax" ); }else {g_warning ("failed to parse event: %s" ,error_get_pretty (err)); }
@@ -531,7 +531,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)QDECREF (qdict); qdict =qdict_new ();g_warning ("unrecognized payload format" ); -error_set (&err,/* QERR_UNSUPPORTED */ 68 ,"this feature or command is not currently supported" ); +error_set (&err,QERR_UNSUPPORTED ,"this feature or command is not currently supported" );qdict_put_obj (qdict,"error" ,error_get_qobject (err));error_free (err); }
qemu-option.c +9 -9
@@ -178,7 +178,7 @@ static void parse_option_bool(const char *name, const char *value, bool *ret, }else if (!strcmp (value,"off" )) { *ret =0 ; }else { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"'on' or 'off'" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name,"'on' or 'off'" ); } }else { *ret =1 ;
@@ -194,12 +194,12 @@ static void parse_option_number(const char *name, const char *value,if (value !=NULL ) { number =strtoull (value, &postfix,0 );if (*postfix !='\0' ) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a number" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name,"a number" );return ; } *ret = number; }else { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a number" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name,"a number" ); } }
@@ -230,13 +230,13 @@ static void parse_option_size(const char *name, const char *value, *ret = (uint64_t ) sizef;break ;default : -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a size" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name,"a size" );error_printf_unless_qmp ("You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n" );return ; } }else { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" , name,"a size" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" , name,"a size" ); } }
@@ -629,7 +629,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,if (i ==0 ) {/* empty list -> allow any */ ; }else { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , name); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" , name);return ; } }
@@ -761,14 +761,14 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,if (id) {if (!id_wellformed (id)) { -error_set (errp,/* QERR_INVALID_PARAMETER_VALUE */ 33 ,"Parameter 'name=%s' expects expected=%s" ,"id" ,"an identifier" ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"Parameter 'name=%s' expects expected=%s" ,"id" ,"an identifier" );error_printf_unless_qmp ("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n" );return NULL ; } opts =qemu_opts_find (list, id);if (opts !=NULL ) {if (fail_if_exists && !list->merge_lists) { -error_set (errp,/* QERR_DUPLICATE_ID */ 24 ,"Duplicate ID 'id=%s' for object=%s" , id, list->name); +error_set (errp,QERR_DUPLICATE_ID ,"Duplicate ID 'id=%s' for object=%s" , id, list->name);return NULL ; }else {return opts;
@@ -1089,7 +1089,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) } }if (desc[i].name ==NULL ) { -error_set (errp,/* QERR_INVALID_PARAMETER */ 30 ,"Invalid parameter 'name=%s'" , opt->name); +error_set (errp,QERR_INVALID_PARAMETER ,"Invalid parameter 'name=%s'" , opt->name);return ; }
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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" );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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" );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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" ); }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_SOCK_BIND_FAILED */ 60 ,"Failed to bind socket" ); +error_set (errp,QERR_SOCK_BIND_FAILED ,"Failed to bind socket" ); } } }
@@ -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_SOCK_LISTEN_FAILED */ 64 ,"Failed to set socket to listening mode" ); +error_set (errp,QERR_SOCK_LISTEN_FAILED ,"Failed to set socket to listening mode" );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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" );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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" );return -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_INPROGRESS */ 62 ,"Connection can not be completed immediately" ); +error_set (errp,QERR_SOCK_CONNECT_INPROGRESS ,"Connection can not be completed immediately" ); }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_SOCK_CONNECT_FAILED */ 61 ,"Failed to connect to socket" ); +error_set (errp,QERR_SOCK_CONNECT_FAILED ,"Failed to connect to socket" );freeaddrinfo (res);return -1 ; }
@@ -479,7 +479,7 @@ int inet_listen(const char *str, char *ostr, int olen, } } }else { -error_set (errp,/* QERR_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" ); }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_SOCK_CREATE_FAILED */ 63 ,"Failed to create socket" ); +error_set (errp,QERR_SOCK_CREATE_FAILED ,"Failed to create socket" ); }qemu_opts_del (opts);return sock;
qga/commands-posix.c +38 -38
297 lines not on this page · raw message
qga/commands-win32.c +22 -22
164 lines not on this page · raw message
qmp.c +23 -23
172 lines not on this page · raw message
qom/object.c +10 -10
@@ -683,7 +683,7 @@ ObjectProperty *object_property_find(Object *obj, const char *name, } } -error_set (errp,/* QERR_PROPERTY_NOT_FOUND */ 47 ,"Property 'device=%s.property=%s' not found" ,"" , name); +error_set (errp,QERR_PROPERTY_NOT_FOUND ,"Property 'device=%s.property=%s' not found" ,"" , name);return NULL ; }
@@ -714,7 +714,7 @@ void object_property_get(Object *obj, Visitor *v, const char *name, }if (!prop->get) { -error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); +error_set (errp,QERR_PERMISSION_DENIED ,"Insufficient permission to perform this operation" ); }else { prop->get (obj, v, prop->opaque, name, errp); }
@@ -729,7 +729,7 @@ void object_property_set(Object *obj, Visitor *v, const char *name, }if (!prop->set) { -error_set (errp,/* QERR_PERMISSION_DENIED */ 46 ,"Insufficient permission to perform this operation" ); +error_set (errp,QERR_PERMISSION_DENIED ,"Insufficient permission to perform this operation" ); }else { prop->set (obj, v, prop->opaque, name, errp); }
@@ -756,7 +756,7 @@ char *object_property_get_str(Object *obj, const char *name, } qstring =qobject_to_qstring (ret);if (!qstring) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"string" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"string" ); retval =NULL ; }else { retval =g_strdup (qstring_get_str (qstring));
@@ -782,7 +782,7 @@ Object *object_property_get_link(Object *obj, const char *name,if (str && *str) { target =object_resolve_path (str,NULL );if (!target) { -error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , str); +error_set (errp,QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , str); } }
@@ -811,7 +811,7 @@ bool object_property_get_bool(Object *obj, const char *name, } qbool =qobject_to_qbool (ret);if (!qbool) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"boolean" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"boolean" ); retval = false; }else { retval =qbool_get_int (qbool);
@@ -842,7 +842,7 @@ int64_t object_property_get_int(Object *obj, const char *name, } qint =qobject_to_qint (ret);if (!qint) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"int" ); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name,"int" ); retval =-1 ; }else { retval =qint_get_int (qint);
@@ -979,16 +979,16 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, target =object_resolve_path_type (path, target_type, &ambiguous);if (ambiguous) { -error_set (errp,/* QERR_AMBIGUOUS_PATH */ 1 ,"Path 'path=%s' does not uniquely identify an object" , path); +error_set (errp,QERR_AMBIGUOUS_PATH ,"Path 'path=%s' does not uniquely identify an object" , path); }else if (target) {object_ref (target); *child = target; }else { target =object_resolve_path (path, &ambiguous);if (target || ambiguous) { -error_set (errp,/* QERR_INVALID_PARAMETER_TYPE */ 32 ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name, target_type); +error_set (errp,QERR_INVALID_PARAMETER_TYPE ,"Invalid parameter type for 'name=%s', expected: expected=%s" , name, target_type); }else { -error_set (errp,/* QERR_DEVICE_NOT_FOUND */ 22 ,"Device 'device=%s' not found" , path); +error_set (errp,QERR_DEVICE_NOT_FOUND ,"Device 'device=%s' not found" , path); } }g_free (target_type);
savevm.c +3 -3
@@ -1555,7 +1555,7 @@ bool qemu_savevm_state_blocked(Error **errp) QTAILQ_FOREACH(se, &savevm_handlers, entry) {if (se->no_migrate) { -error_set (errp,/* QERR_MIGRATION_NOT_SUPPORTED */ 41 ,"State blocked by non-migratable device 'device=%s'" , se->idstr); +error_set (errp,QERR_MIGRATION_NOT_SUPPORTED ,"State blocked by non-migratable device 'device=%s'" , se->idstr);return true; } }
@@ -2182,13 +2182,13 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) f =qemu_fopen (filename,"wb" );if (!f) { -error_set (errp,/* QERR_OPEN_FILE_FAILED */ 45 ,"Could not open 'filename=%s'" , filename); +error_set (errp,QERR_OPEN_FILE_FAILED ,"Could not open 'filename=%s'" , filename); goto the_end; } ret =qemu_save_device_state (f);qemu_fclose (f);if (ret <0 ) { -error_set (errp,/* QERR_IO_ERROR */ 35 ,"An IO error has occurred" ); +error_set (errp,QERR_IO_ERROR ,"An IO error has occurred" ); } the_end:
target-i386/cpu.c +5 -5
@@ -631,7 +631,7 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max); +error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -669,7 +669,7 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max); +error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -704,7 +704,7 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,return ; }if (value < min || value > max) { -error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max); +error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
@@ -769,7 +769,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,int i;if (strlen (value) !=12 ) { -error_set (errp,/* QERR_PROPERTY_VALUE_BAD */ 48 ,"Property 'device=%s.property=%s' doesn't take value 'value=%s'" ,"" ,"vendor" , value); +error_set (errp,QERR_PROPERTY_VALUE_BAD ,"Property 'device=%s.property=%s' doesn't take value 'value=%s'" ,"" ,"vendor" , value);return ; }
@@ -844,7 +844,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,return ; }if (value < min || value > max) { -error_set (errp,/* QERR_PROPERTY_VALUE_OUT_OF_RANGE */ 52 ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max); +error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"Property 'device=%s.property=%s' doesn't take value value=%" PRId64" (minimum: min=%" PRId64", maximum: max=%" PRId64")" ,"" , name ? name :"null" , value, min, max);return ; }
ui/vnc.c +2 -2
@@ -373,7 +373,7 @@ VncInfo *qmp_query_vnc(Error **errp)if (getsockname (vnc_display->lsock, (struct sockaddr *)&sa, &salen) ==-1 ) { -error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); +error_set (errp,QERR_UNDEFINED_ERROR ,"An undefined error has occurred" ); goto out_error; }
@@ -381,7 +381,7 @@ VncInfo *qmp_query_vnc(Error **errp) host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV) < 0) { -error_set (errp,/* QERR_UNDEFINED_ERROR */ 66 ,"An undefined error has occurred" ); +error_set (errp,QERR_UNDEFINED_ERROR ,"An undefined error has occurred" ); goto out_error; }
Signature · 1 line
1.7.11.2.249.g31c7954.dirty
Quoted 4 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
Quoted 8 lines
to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
We should just stick with a simple QERR_GENERIC and call it a day. Let's not needlessly complicate existing code.
Regards,
Anthony Liguori
Quoted 92 lines
error_set()then uses that string and the 'device' argument to build the error object, which is a QDict. The human error message is fixed, and exists in the qerror_table[] array. That array is indexed, and the human error message is added to the error object.In the new way,
QERR_DEVICE_NOT_FOUNDis an enumeration value and the human error message is passed as an argument. qerror_table[] is gone. The error object is built by usingQERR_DEVICE_NOT_FOUNDas an index for a table containing all those json dict strings (this can, and probably will, be eliminated, as the QMP code can generate its error object from the Error object).An important detail is that, the error object data member is constructed by parsing the human message string and looking for name=value pairs. If a required data member (like 'device' above) is not found in the human message, a default value is used ('unknown' for strings and 0 for integers).
This series unlocks several possible simplification, like moving from:
struct Error { QDict *obj; const char *fmt; char *msg; };to:
struct Error { ErrClass err_class; char *msg; };But I haven't done it all yet.
Please, check individual patches for more details.
balloon.c | 10 +- block.c | 4 +- block/cow.c | 3 +- block/qcow.c | 7 +- block/qcow2.c | 3 +- block/qed.c | 3 +- block/stream.c | 2 +- block/vdi.c | 4 +- block/vmdk.c | 4 +- block/vpc.c | 4 +- block/vvfat.c | 4 +- blockdev.c | 79 +++++++------- configure | 10 -- cpus.c | 13 ++- dump-stub.c | 2 +- dump.c | 18 ++-- error.c | 45 ++------ error.h | 5 +- hmp.c | 2 +- hw/9pfs/virtio-9p.c | 3 +- hw/ivshmem.c | 2 +- hw/pci-stub.c | 2 +- hw/pci.c | 4 +- hw/qdev-addr.c | 6 +- hw/qdev-monitor.c | 26 +++-- hw/qdev-properties.c | 49 ++++----- hw/qdev.c | 6 +- hw/usb/bus.c | 3 +- hw/usb/hcd-ehci.c | 6 +- hw/usb/redirect.c | 5 +- json-parser.c | 2 +- migration.c | 6 +- monitor.c | 127 +++++------------------ net.c | 20 ++-- qapi/qapi-visit-core.c | 22 ++-- qapi/qmp-dispatch.c | 14 ++- qapi/qmp-input-visitor.c | 22 ++-- qapi/string-input-visitor.c | 12 +-- qemu-config.c | 2 +- qemu-ga.c | 4 +- qemu-option.c | 20 ++-- qemu-sockets.c | 22 ++-- qerror.c | 243 ++++++++++++++------------------------------ qerror.h | 22 +--- qga/commands-posix.c | 78 +++++++------- qga/commands-win32.c | 53 ++++------ qmp.c | 47 +++++---- qom/object.c | 20 ++-- savevm.c | 6 +- scripts/qapi-errors.py | 80 ++++++++------- target-i386/cpu.c | 15 +-- ui/vnc.c | 4 +- 52 files changed, 450 insertions(+), 725 deletions(-)
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 11 lines
Quoted 9 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);
Quoted 7 lines
Quoted 3 lines
In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.
Why even have error codes when everything should become QERR_GENERIC? Or am I misunderstanding?
Kevin
Quoted 16 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 15 lines
Quoted 12 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
Quoted 7 lines
Quoted 3 lines
This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
We don't gain anything by touching every user of error and the code gets more verbose. If we want to modify an existing error for some good reason, we can do so my changing error types.
Quoted 5 lines
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?
If we want to add an error code, we can do:
error_set(QERR_GENERIC, "domain", "My free form text")
And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")
Or pick your favorite short name.
Regards,
Anthony Liguori
Quoted 2 lines
Kevin
Quoted 18 lines · On Thu, 26 Jul 2012 07:41:07 -0500 Anthony Liguori <[email protected]> wrote:
Quoted 16 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 15 lines
Quoted 12 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
Correct.
Quoted 3 lines
We don't gain anything by touching every user of error and the code gets more verbose.
We do gain the possibility to have better and different human messages for the same error class. That's impossible today. And creating a different error class just to have a different error message is just crazy (which is what we do today, btw).
Now, if the problem you see is that we shouldn't touch current users but add a new function for new users to use (or change old users incrementally, when it matters), then we can discuss that.
Quoted 2 lines
If we want to modify an existing error for some good reason, we can do so my changing error types.
You mean, creating a new error class just to have a different human message? We have 70+ classes today, how many will we have in another year?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?
Quoted 7 lines
If we want to add an error code, we can do:
error_set(QERR_GENERIC, "domain", "My free form text")And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")
Would domain be the error classes we have today?
If error_setf() ends result is similar to what this series does with error_set(), then that might be acceptable, although I fear we keep adding new ways to report errors.
Quoted 35 lines · Luiz Capitulino
Quoted 18 lines · On Thu, 26 Jul 2012 07:41:07 -0500 Anthony Liguori <[email protected]> wrote:
Quoted 16 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 15 lines
Quoted 12 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
Correct.
Quoted 3 lines
We don't gain anything by touching every user of error and the code gets more verbose.
Quoted 8 lines
We do gain the possibility to have better and different human messages for the same error class. That's impossible today. And creating a different error class just to have a different error message is just crazy (which is what we do today, btw).
Now, if the problem you see is that we shouldn't touch current users but add a new function for new users to use (or change old users incrementally, when it matters), then we can discuss that.
Yup, that's what I've been saying.
Quoted 6 lines
Quoted 3 lines
If we want to modify an existing error for some good reason, we can do so my changing error types.
You mean, creating a new error class just to have a different human message? We have 70+ classes today, how many will we have in another year?
"changing error types" -> to use the new QERR_GENERIC one.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?If we want to add an error code, we can do:
Quoted 7 lines
Quoted 5 lines
error_set(QERR_GENERIC, "domain", "My free form text")And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")Would domain be the error classes we have today?
I'd be perfectly content with letting domain be a free form text that's managed by the subsystem and not centrally defined. If we also stick:
error_setf(errp, "domain", int_code, "My free form text")
Then we're GError compatible. If we throw away our existing error infrastructure and incrementally adopt GError, then that excites me :-)
Quoted 3 lines
If
error_setf()ends result is similar to what this series does witherror_set(), then that might be acceptable, although I fear we keep adding new ways to report errors.
I think having an end goal of using GError is a good way to avoid the never ending cycle of inventing a better mouse trap.
Regards,
Anthony Liguori
Quoted 31 lines · Anthony Liguori
Quoted 29 lines · Luiz Capitulino
Quoted 25 lines · On Thu, 26 Jul 2012 07:41:07 -0500 Anthony Liguori <[email protected]> wrote:
Quoted 23 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 11 lines
Quoted 9 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);Quoted 7 lines
Quoted 3 lines
In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
Quoted 5 lines
Quoted 5 lines
Correct.
Quoted 3 lines
We don't gain anything by touching every user of error and the code gets more verbose.
Of the 71 error types, two are unused, and 31 are used exactly once. For these 33, the code gets *less* verbose. For the 29 used twice or thrice, it's a wash.
Any added "verbosity" is a *feature*. It corrects the design mistake of factoring out the human-readable messages. "One size fits all human-readable error message" is an anti-feature.
Quoted 6 lines
Quoted 6 lines
We do gain the possibility to have better and different human messages for the same error class. That's impossible today. And creating a different error class
just to have a different error message is just crazy (which is what we do today, btw).
Quoted 6 lines
Quoted 4 lines
Now, if the problem you see is that we shouldn't touch current users but add a new function for new users to use (or change old users incrementally, when
it matters), then we can discuss that.Yup, that's what I've been saying.
I count four error reporting mechanisms in wide use:
1. ad hoc prints
2. error_report()
3. qerror_report()
4. error_set()
Are you seriously proposing to add a new one that doesn't replace any of the old ones?
There's no shame in getting yourself into a hole once in a while, only in continuing to dig.
Quoted 32 lines
Quoted 5 lines
Quoted 2 lines
If we want to modify an existing error for some good reason, we can do so my changing error types.
You mean, creating a new error class just to have a different human message? We have 70+ classes today, how many will we have in another year?
"changing error types" -> to use the new
QERR_GENERICone.Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?If we want to add an error code, we can do:
Quoted 7 lines
Quoted 5 lines
error_set(QERR_GENERIC, "domain", "My free form text")And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")Would domain be the error classes we have today?
I'd be perfectly content with letting domain be a free form text that's managed by the subsystem and not centrally defined. If we also stick:
error_setf(errp, "domain", int_code, "My free form text")Then we're GError compatible. If we throw away our existing error infrastructure and incrementally adopt GError, then that excites me :-)
Quoted 6 lines
Quoted 3 lines
If
error_setf()ends result is similar to what this series does witherror_set(), then that might be acceptable, although I fear we keep adding new ways to report errors.I think having an end goal of using GError is a good way to avoid the never ending cycle of inventing a better mouse trap.
I don't see what domain buys us. Please explain.
Am 26.07.2012 14:41, schrieb Anthony Liguori:
Quoted 22 lines
Quoted 20 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 18 lines
Quoted 4 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);Quoted 8 lines
to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
Quoted 7 lines
Quoted 3 lines
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
We don't gain anything by touching every user of error and the code gets more verbose. If we want to modify an existing error for some good reason, we can do so my changing error types.
We gain consistency instead of accumulating the relics of even more halfway completed direction changes.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?If we want to add an error code, we can do:
Quoted 7 lines
error_set(QERR_GENERIC, "domain", "My free form text")And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")Or pick your favorite short name.
You mentioned this domain thing before, and when asked you never explained what you really mean with it. Can you do so now, please?
Assuming that it's just some error class string, I don't really see the difference between error_set(QERR_FOO, "Free form") as implemented by this series and error_set(QERR_GENERIC, "FOO", "Free form").
Kevin
Quoted 27 lines · Kevin Wolf
Am 26.07.2012 14:41, schrieb Anthony Liguori:
Quoted 26 lines
Quoted 23 lines · Kevin Wolf
Am 26.07.2012 04:43, schrieb Anthony Liguori:
Quoted 11 lines
Quoted 9 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);Quoted 7 lines
Quoted 3 lines
In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
I believe this is mostly because it's a mechanical conversion. Once this is done, we can change error messages to better fit the individual cases.
Quoted 6 lines
Quoted 3 lines
We don't gain anything by touching every user of error and the code gets more verbose. If we want to modify an existing error for some good reason, we can do so my changing error types.
We gain consistency instead of accumulating the relics of even more halfway completed direction changes.
Sorry, but taking the "Device 'device=%s' not found" string and replicating a dozen times is not helpful at all. Having a single method to generate device not found errors is a Good Thing. Could it be a function around a string instead of JSON magic? Sure. But open coding is not a step forward.
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
We should just stick with a simple
QERR_GENERICand call it a day. Let's not needlessly complicate existing code.Why even have error codes when everything should become
QERR_GENERIC? Or am I misunderstanding?If we want to add an error code, we can do:
error_set(QERR_GENERIC, "domain", "My free form text")
Quoted 8 lines
Quoted 5 lines
And then yes, we can change this to:
error_setf(errp, "domain", "My free form text")Or pick your favorite short name.
You mentioned this domain thing before, and when asked you never explained what you really mean with it. Can you do so now, please?
http://developer.gnome.org/glib/stable/glib-Error-Reporting.html
In terms of GError, domain is a unique string which defines the meaning of the error codes. Most often, domain is either a library and/or module name.
So we would probably have a "qcow2" domain and a "block" domain to differientiate errors generated from qcow2 vs. the generic block layer.
Quoted 3 lines
Assuming that it's just some error class string, I don't really see the difference between
error_set(QERR_FOO, "Free form")as implemented by this series anderror_set(QERR_GENERIC, "FOO", "Free form").
I don't care about using free strings vs. #defines. I care about open coding strings that ought to be common and consistent.
Regards,
Anthony Liguori
Quoted 2 lines
Kevin
Quoted 11 lines · Anthony Liguori
Quoted 9 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);
Quoted 7 lines
Quoted 3 lines
In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
What we do in libvirt, is to define helper functions for reporting the specific error codes. So, as well as having the generic
error_set(errp, QERR_CODE, "format string", args)
you would have
error_set_device_not_found(errp, args)
which is just a #define
#define error_set_device_not_found(errp, args) \
error_set(errp, QERR_DEVICE_NOT_FOUND, "Device %s not found", args)for the most part this should avoid the duplication you're concerned about, while still letting use provided more detailed messsages.
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 30 lines · Daniel P. Berrange
Quoted 11 lines · Anthony Liguori
Quoted 9 lines · Luiz Capitulino
Basically, this series changes a call like:
error_set(errp, QERR_DEVICE_NOT_FOUND, device);to:
error_set(errp,
QERR_DEVICE_NOT_FOUND,"Device 'device=%s' not found", device);Quoted 7 lines
Quoted 3 lines
In the first call,
QERR_DEVICE_NOT_FOUNDis a string containing a json dict:"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"This is the wrong direction. Looking through the patch, this makes the code much more redundant overall. You have dozens of calls that are duplicating the same error message. This is not progress.
What we do in libvirt, is to define helper functions for reporting the specific error codes. So, as well as having the generic
error_set(errp, QERR_CODE, "format string", args)you would have
error_set_device_not_found(errp, args)
Quoted 7 lines
which is just a #define
#define error_set_device_not_found(errp, args) \ error_set(errp, QERR_DEVICE_NOT_FOUND, "Device %s not found", args)for the most part this should avoid the duplication you're concerned about, while still letting use provided more detailed messsages.
Yup. I suggested the same on IRC, modulo macro vs. function.
Unlike Anthony, I think this is a move in the right direction.
Il 26/07/2012 17:54, Markus Armbruster ha scritto:
Quoted 1 line
Unlike Anthony, I think this is a move in the right direction.
Me too, but I would like to understand how it fits with the qapi-schema-errors.json. Do we actually need a schema if the messages are flat?
Paolo
Quoted 6 lines · On Thu, 26 Jul 2012 18:03:20 +0200 Paolo Bonzini <[email protected]> wrote:
Il 26/07/2012 17:54, Markus Armbruster ha scritto:
Quoted 1 line
Unlike Anthony, I think this is a move in the right direction.
Me too, but I would like to understand how it fits with the qapi-schema-errors.json. Do we actually need a schema if the messages are flat?
Yes, we need it because we still an error object to obey (ie. the data member).
But we're talking about dropping that, so it might be possible to kill the schema.
Am 26.07.2012 18:37, schrieb Luiz Capitulino:
Quoted 6 lines
Quoted 3 lines · On Thu, 26 Jul 2012 18:03:20 +0200 Paolo Bonzini <[email protected]> wrote:
Il 26/07/2012 17:54, Markus Armbruster ha scritto:
Quoted 1 line
Unlike Anthony, I think this is a move in the right direction.
Quoted 8 lines
Quoted 3 lines
Me too, but I would like to understand how it fits with the qapi-schema-errors.json. Do we actually need a schema if the messages are flat?
Yes, we need it because we still an error object to obey (ie. the data member).
But we're talking about dropping that, so it might be possible to kill the schema.
I'm not so familiar with how all this error infrastructure is plugged together...
In a different thread that I mentioned recently (and still haven't found in my inbox), we were talking about changing the JSON encoding of errors where unused by libvirt. Specifically we were talking about having a field for the canonical QOM path of the affected object in place of the often-empty device ID.
Are you now discussing to drop any such elaborated QMP schemes in place of just one non-parsable human error message string?
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 19 lines · Andreas Färber
Am 26.07.2012 18:37, schrieb Luiz Capitulino:
Quoted 6 lines
Quoted 3 lines · On Thu, 26 Jul 2012 18:03:20 +0200 Paolo Bonzini <[email protected]> wrote:
Il 26/07/2012 17:54, Markus Armbruster ha scritto:
Quoted 1 line
Unlike Anthony, I think this is a move in the right direction.
Quoted 8 lines
Quoted 3 lines
Me too, but I would like to understand how it fits with the qapi-schema-errors.json. Do we actually need a schema if the messages are flat?
Yes, we need it because we still an error object to obey (ie. the data member).
But we're talking about dropping that, so it might be possible to kill the schema.
I'm not so familiar with how all this error infrastructure is plugged together...
Quoted 8 lines
In a different thread that I mentioned recently (and still haven't found in my inbox), we were talking about changing the JSON encoding of errors where unused by libvirt. Specifically we were talking about having a field for the canonical QOM path of the affected object in place of the often-empty device ID.
Are you now discussing to drop any such elaborated QMP schemes in place of just one non-parsable human error message string?
See the other note I sent out for a description of the plan. It's english string + error code.
Regards,
Anthony Liguori
Quoted 6 lines
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 16 lines · On Fri, 27 Jul 2012 15:17:15 +0200 Andreas Färber <[email protected]> wrote:
Am 26.07.2012 18:37, schrieb Luiz Capitulino:
Quoted 6 lines
Quoted 3 lines · On Thu, 26 Jul 2012 18:03:20 +0200 Paolo Bonzini <[email protected]> wrote:
Il 26/07/2012 17:54, Markus Armbruster ha scritto:
Quoted 1 line
Unlike Anthony, I think this is a move in the right direction.
Quoted 8 lines
Quoted 3 lines
Me too, but I would like to understand how it fits with the qapi-schema-errors.json. Do we actually need a schema if the messages are flat?
Yes, we need it because we still an error object to obey (ie. the data member).
But we're talking about dropping that, so it might be possible to kill the schema.
Quoted 8 lines
I'm not so familiar with how all this error infrastructure is plugged together...
In a different thread that I mentioned recently (and still haven't found in my inbox), we were talking about changing the JSON encoding of errors where unused by libvirt. Specifically we were talking about having a field for the canonical QOM path of the affected object in place of the often-empty device ID.
We don't send empty device IDs afaik, but that problem will have to be discussed again... Why does libvirt need the QOM path from the error message? Can't it be queried some other way?