qapi: Kill 'qapi/qmp/qerror.h' for good
Subsystems (2)
cover qapi: Kill 'qapi/qmp/qerror.h' for good
Hi,
This is kind of a selfish series. I'm really tired to grep and read this comment from 2015 in qapi/qmp/qerror.h:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Besides, these definitions are still added in recent code (see for example commit 09f9ec9913 from June 2023). So let's finish with this 8 years old technical debt.
Overall it took me 3h: 1h to find the correct Coccinelle doc about Python use and read it again [*], then 1h to adapt the script for each patch, rest is testing and writing comments, so the scripts used could be used as reference later.
Regards,
Phil.
[*] https://www.lrz.de/services/compute/courses/x_lecturenotes/hspc1w19.pdf
Philippe Mathieu-Daudé (21):
qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition
qapi: Inline and remove QERR_DEVICE_IN_USE definition
qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition
qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter)
qapi: Inline and remove QERR_INVALID_PARAMETER definition
qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value)
qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition
qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant param)
qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition
qapi: Inline and remove QERR_IO_ERROR definition
qapi: Inline and remove QERR_MIGRATION_ACTIVE definition
qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
qapi: Inline and remove QERR_MISSING_PARAMETER definition
qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition
qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition
qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition RFC qapi: Inline and remove QERR_UNSUPPORTED definition
qapi: Remove 'qapi/qmp/qerror.h' header
qga/qapi-schema.json | 5 +- include/qapi/qmp/qerror.h | 62 -------------------- backends/cryptodev-vhost-user.c | 5 +- backends/dbus-vmstate.c | 3 +- backends/rng-egd.c | 5 +- backends/rng-random.c | 4 +- block/gluster.c | 22 +++---- block/monitor/block-hmp-cmds.c | 7 +-- block/quorum.c | 4 +- block/snapshot.c | 5 +- block/vmdk.c | 9 ++- blockdev.c | 16 +++--- blockjob.c | 4 +- chardev/char-fe.c | 3 +- chardev/char.c | 4 +- dump/dump.c | 11 ++-- dump/win_dump.c | 5 +- hw/core/qdev-properties-system.c | 6 +- hw/core/qdev-properties.c | 3 +- hw/core/qdev.c | 4 +- hw/intc/openpic.c | 4 +- hw/ppc/spapr_pci.c | 5 +- hw/usb/redirect.c | 7 +-- migration/migration.c | 7 +-- migration/options.c | 99 +++++++++++++------------------- migration/page_cache.c | 9 ++- migration/ram.c | 5 +- migration/savevm.c | 7 +-- monitor/fds.c | 9 ++- monitor/hmp-cmds.c | 3 +- monitor/qmp-cmds.c | 4 +- net/filter-buffer.c | 4 +- net/filter.c | 8 +-- net/net.c | 10 ++-- qapi/opts-visitor.c | 12 ++-- qapi/qapi-forward-visitor.c | 3 +- qapi/qapi-util.c | 4 +- qapi/qapi-visit-core.c | 5 +- qapi/qobject-input-visitor.c | 53 ++++++++--------- qapi/string-input-visitor.c | 27 ++++----- qga/commands-bsd.c | 9 ++- qga/commands-posix.c | 47 ++++++++------- qga/commands-win32.c | 65 ++++++++++----------- qga/commands.c | 10 ++-- qom/object.c | 16 ++++-- qom/object_interfaces.c | 3 +- qom/qom-qmp-cmds.c | 8 +-- softmmu/balloon.c | 3 +- softmmu/cpus.c | 8 +-- softmmu/qdev-monitor.c | 24 ++++---- softmmu/rtc.c | 1 - softmmu/tpm.c | 8 +-- softmmu/vl.c | 5 +- target/arm/arm-qmp-cmds.c | 4 +- target/i386/cpu.c | 15 +++-- target/s390x/cpu_models_sysemu.c | 4 +- ui/input-barrier.c | 3 +- ui/ui-qmp-cmds.c | 7 +-- util/block-helpers.c | 4 +- util/qemu-option.c | 21 ++++--- scripts/qapi/visit.py | 5 +- 61 files changed, 305 insertions(+), 437 deletions(-) delete mode 100644 include/qapi/qmp/qerror.h
Signature · 1 line
2.41.0
PATCH 1/21 qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
Address the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- hw/ppc/spapr_pci.c | 4 ++-- softmmu/qdev-monitor.c | 8 +++++--- 3 files changed, 7 insertions(+), 8 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_BUS_NO_HOTPLUG \ - "Bus '%s' does not support hotplugging" -#define QERR_DEVICE_HAS_NO_MEDIUM \ "Device '%s' has no medium"
hw/ppc/spapr_pci.c +2 -2
@@ -1550,7 +1550,7 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_handler,* we need to let them know it's not enabled */ if (plugged_dev->hotplugged) { -error_setg (errp,QERR_BUS_NO_HOTPLUG , +error_setg (errp,"Bus '%s' does not support hotplugging" ,object_get_typename (OBJECT (phb)));return ; }
@@ -1671,7 +1671,7 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,SpaprDrc *drc =drc_from_dev (phb, pdev);if (!phb->dr_enabled) { -error_setg (errp,QERR_BUS_NO_HOTPLUG , +error_setg (errp,"Bus '%s' does not support hotplugging" ,object_get_typename (OBJECT (phb)));return ; }
softmmu/qdev-monitor.c +5 -3
@@ -656,7 +656,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,if (qdev_should_hide_device (opts, from_json, errp)) {if (bus && !qbus_is_hotpluggable (bus)) { -error_setg (errp,QERR_BUS_NO_HOTPLUG , bus->name); +error_setg (errp,"Bus '%s' does not support hotplugging" , + bus->name); }return NULL ; }else if (*errp) {
@@ -664,7 +665,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, }if (phase_check (PHASE_MACHINE_READY ) && bus && !qbus_is_hotpluggable (bus)) { -error_setg (errp,QERR_BUS_NO_HOTPLUG , bus->name); +error_setg (errp,"Bus '%s' does not support hotplugging" , bus->name);return NULL ; }
@@ -904,7 +905,8 @@ void qdev_unplug(DeviceState *dev, Error **errp) }if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) { -error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name); +error_setg (errp,"Bus '%s' does not support hotplugging" , + dev->parent_bus->name);return ; }
Signature · 1 line
2.41.0
PATCH 2/21 qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- block/snapshot.c | 4 ++-- blockdev.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_DEVICE_HAS_NO_MEDIUM \ - "Device '%s' has no medium" -#define QERR_DEVICE_IN_USE \ "Device '%s' is in use"
block/snapshot.c +2 -2
@@ -345,7 +345,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs,GLOBAL_STATE_CODE ();if (!drv) { -error_setg (errp,QERR_DEVICE_HAS_NO_MEDIUM ,bdrv_get_device_name (bs)); +error_setg (errp,"Device '%s' has no medium" ,bdrv_get_device_name (bs));return -ENOMEDIUM ; }if (!snapshot_id && !name) {
@@ -420,7 +420,7 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs,GLOBAL_STATE_CODE ();if (!drv) { -error_setg (errp,QERR_DEVICE_HAS_NO_MEDIUM ,bdrv_get_device_name (bs)); +error_setg (errp,"Device '%s' has no medium" ,bdrv_get_device_name (bs));return -ENOMEDIUM ; }if (!snapshot_id && !name) {
blockdev.c +1 -1
@@ -1422,7 +1422,7 @@ static void external_snapshot_action(TransactionAction *action,bdrv_drained_begin (state->old_bs);if (!bdrv_is_inserted (state->old_bs)) { -error_setg (errp,QERR_DEVICE_HAS_NO_MEDIUM , device); +error_setg (errp,"Device '%s' has no medium" , device); goto out; }
Signature · 1 line
2.41.0
PATCH 3/21 qapi: Inline and remove QERR_DEVICE_IN_USE definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- blockdev.c | 2 +- chardev/char-fe.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_DEVICE_IN_USE \ - "Device '%s' is in use" -#define QERR_DEVICE_NO_HOTPLUG \ "Device '%s' does not support hotplugging"
blockdev.c +1 -1
@@ -2345,7 +2345,7 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name, }if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_RESIZE ,NULL )) { -error_setg (errp,QERR_DEVICE_IN_USE , device); +error_setg (errp,"Device '%s' is in use" , device);return ; }
chardev/char-fe.c +1 -1
@@ -217,7 +217,7 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)return true; unavailable: -error_setg (errp,QERR_DEVICE_IN_USE , s->label); +error_setg (errp,"Device '%s' is in use" , s->label);return false; }
Signature · 1 line
2.41.0
PATCH 4/21 qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- hw/core/qdev.c | 3 ++- softmmu/qdev-monitor.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_DEVICE_NO_HOTPLUG \ - "Device '%s' does not support hotplugging" -#define QERR_INVALID_PARAMETER \ "Invalid parameter '%s'"
hw/core/qdev.c +2 -1
@@ -479,7 +479,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp)static int unattached_count;if (dev->hotplugged && !dc->hotpluggable) { -error_setg (errp,QERR_DEVICE_NO_HOTPLUG ,object_get_typename (obj)); +error_setg (errp,"Device '%s' does not support hotplugging" , +object_get_typename (obj));return ; }
softmmu/qdev-monitor.c +1 -1
@@ -911,7 +911,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) }if (!dc->hotpluggable) { -error_setg (errp,QERR_DEVICE_NO_HOTPLUG , +error_setg (errp,"Device '%s' does not support hotplugging" ,object_get_typename (OBJECT (dev)));return ; }
Signature · 1 line
2.41.0
PATCH 5/21 qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match@
expression errp;
constant param;
@@
error_setg(errp, QERR_INVALID_PARAMETER, param);
@script:python strformat depends on match@
param << match.param;
fixedfmt; // new var
@@
fixedfmt = f'"Invalid parameter \'{param[1:-1]}\'"' # Format skipping '"'.
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
constant match.param;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_INVALID_PARAMETER, param);
+ error_setg(errp, fixedfmt);--- dump/dump.c | 6 +++--- qga/commands.c | 2 +- ui/ui-qmp-cmds.c | 2 +- util/qemu-option.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
dump/dump.c +3 -3
@@ -1810,7 +1810,7 @@ static void dump_init(DumpState *s, int fd, bool has_format, s->fd = fd;if (has_filter && !length) { -error_setg (errp,QERR_INVALID_PARAMETER ,"length" ); +error_setg (errp,"Invalid parameter 'length'" ); goto cleanup; } s->filter_area_begin = begin;
@@ -1841,7 +1841,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,/* Is the filter filtering everything? */ if (validate_start_block (s) ==-1 ) { -error_setg (errp,QERR_INVALID_PARAMETER ,"begin" ); +error_setg (errp,"Invalid parameter 'begin'" ); goto cleanup; }
@@ -2145,7 +2145,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, }if (fd ==-1 ) { -error_setg (errp,QERR_INVALID_PARAMETER ,"protocol" ); +error_setg (errp,"Invalid parameter 'protocol'" );return ; }
qga/commands.c +1 -1
@@ -154,7 +154,7 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp) gei =guest_exec_info_find (pid);if (gei ==NULL ) { -error_setg (errp,QERR_INVALID_PARAMETER ,"pid" ); +error_setg (errp,"Invalid parameter 'pid'" );return NULL ; }
ui/ui-qmp-cmds.c +1 -1
@@ -44,7 +44,7 @@ void qmp_set_password(SetPasswordOptions *opts, Error **errp)assert (opts->protocol ==DISPLAY_PROTOCOL_VNC );if (opts->connected !=SET_PASSWORD_ACTION_KEEP ) {/* vnc supports "connected=keep" only */ -error_setg (errp,QERR_INVALID_PARAMETER ,"connected" ); +error_setg (errp,"Invalid parameter 'connected'" );return ; }/*
util/qemu-option.c +1 -1
@@ -612,7 +612,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,if (list->merge_lists) {if (id) { -error_setg (errp,QERR_INVALID_PARAMETER ,"id" ); +error_setg (errp,"Invalid parameter 'id'" );return NULL ; } opts =qemu_opts_find (list,NULL );
Signature · 1 line
2.41.0
PATCH 6/21 qapi: Inline and remove QERR_INVALID_PARAMETER definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using:
$ sed -i -e "s/QERR_INVALID_PARAMETER,/\"Invalid parameter '%s'\",/" \
$(git grep -lw QERR_INVALID_PARAMETER)then manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- monitor/hmp-cmds.c | 2 +- qapi/opts-visitor.c | 2 +- util/qemu-option.c | 8 ++++---- 4 files changed, 6 insertions(+), 9 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_INVALID_PARAMETER \ - "Invalid parameter '%s'" -#define QERR_INVALID_PARAMETER_TYPE \ "Invalid parameter type for '%s', expected: %s"
monitor/hmp-cmds.c +1 -1
@@ -138,7 +138,7 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict) }else {Error *err =NULL ; -error_setg (&err,QERR_INVALID_PARAMETER , op); +error_setg (&err,"Invalid parameter '%s'" , op);hmp_handle_error (mon, err); } }
qapi/opts-visitor.c +1 -1
@@ -184,7 +184,7 @@ opts_check_struct(Visitor *v, Error **errp)const QemuOpt *first; first =g_queue_peek_head (any); -error_setg (errp,QERR_INVALID_PARAMETER , first->name); +error_setg (errp,"Invalid parameter '%s'" , first->name);return false; }return true;
util/qemu-option.c +4 -4
@@ -498,7 +498,7 @@ static bool opt_validate(QemuOpt *opt, Error **errp) desc =find_desc_by_name (list->desc, opt->name);if (!desc && !opts_accepts_any (list)) { -error_setg (errp,QERR_INVALID_PARAMETER , opt->name); +error_setg (errp,"Invalid parameter '%s'" , opt->name);return false; }
@@ -531,7 +531,7 @@ bool qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val, desc =find_desc_by_name (list->desc, name);if (!desc && !opts_accepts_any (list)) { -error_setg (errp,QERR_INVALID_PARAMETER , name); +error_setg (errp,"Invalid parameter '%s'" , name);return false; }
@@ -554,7 +554,7 @@ bool qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val, desc =find_desc_by_name (list->desc, name);if (!desc && !opts_accepts_any (list)) { -error_setg (errp,QERR_INVALID_PARAMETER , name); +error_setg (errp,"Invalid parameter '%s'" , name);return false; }
@@ -1103,7 +1103,7 @@ bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) QTAILQ_FOREACH(opt, &opts->head, next) { opt->desc =find_desc_by_name (desc, opt->name);if (!opt->desc) { -error_setg (errp,QERR_INVALID_PARAMETER , opt->name); +error_setg (errp,"Invalid parameter '%s'" , opt->name);return false; }
Signature · 1 line
2.41.0
PATCH 7/21 qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match@
expression errp;
constant param;
constant value;
@@
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value);
@script:python strformat depends on match@
param << match.param;
value << match.value;
fixedfmt; // new var
@@
fixedfmt = f'"Invalid parameter type for \'{param[1:-1]}\', expected: {value[1:-1]}"'
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
constant match.param;
constant match.value;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value);
+ error_setg(errp, fixedfmt);--- target/arm/arm-qmp-cmds.c | 3 ++- target/s390x/cpu_models_sysemu.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
target/arm/arm-qmp-cmds.c +2 -1
@@ -154,7 +154,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,if (model->props) { qdict_in =qobject_to (QDict, model->props);if (!qdict_in) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" ); +error_setg (errp, +"Invalid parameter type for 'props', expected: dict" );return NULL ; } }
target/s390x/cpu_models_sysemu.c +2 -1
@@ -111,7 +111,8 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,if (info->props) { qdict =qobject_to (QDict, info->props);if (!qdict) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" ); +error_setg (errp, +"Invalid parameter type for 'props', expected: dict" );return ; } }
Signature · 1 line
2.41.0
Re: [PATCH 07/21] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
Quoted 60 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/Mechanical transformation using the following
coccinelle semantic patch:@match@ expression errp; constant param; constant value; @@ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value); @script:python strformat depends on match@ param << match.param; value << match.value; fixedfmt; // new var @@ fixedfmt = f'"Invalid parameter type for \'{param[1:-1]}\', expected: {value[1:-1]}"' coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ expression match.errp; constant match.param; constant match.value; identifier strformat.fixedfmt; @@ - error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value); + error_setg(errp, fixedfmt);Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/arm-qmp-cmds.c | 3 ++- target/s390x/cpu_models_sysemu.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)target/arm/arm-qmp-cmds.c +2
-1@@ -154,7 +154,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,if (model->props) { qdict_in =qobject_to (QDict, model->props);if (!qdict_in) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" ); +error_setg (errp, +"Invalid parameter type for 'props', expected: dict" );return NULL ; } }target/s390x/cpu_models_sysemu.c +0
-0
target/s390x/cpu_models_sysemu.c static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, · line 118
Quoted 9 lines
target/s390x/cpu_models_sysemu.c +2
-1@@ -111,7 +111,8 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,if (info->props) { qdict =qobject_to (QDict, info->props);if (!qdict) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" ); +error_setg (errp, +"Invalid parameter type for 'props', expected: dict" );return ; } }
PATCH 8/21 qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match@
expression errp;
expression param;
constant value;
@@
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value);
@script:python strformat depends on match@
value << match.value;
fixedfmt; // new var
@@
fixedfmt = f'"Invalid parameter type for \'%s\', expected: {value[1:-1]}"'
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
expression match.param;
constant match.value;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE, param, value);
+ error_setg(errp, fixedfmt, param);--- qapi/qobject-input-visitor.c | 32 ++++++++++++++++---------------- qapi/string-input-visitor.c | 8 ++++---- qom/object.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 24 deletions(-)
qapi/qobject-input-visitor.c +16 -16
@@ -288,8 +288,8 @@ static bool qobject_input_start_struct(Visitor *v, const char *name, void **obj,return false; }if (qobject_type (qobj) !=QTYPE_QDICT ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"object" ); +error_setg (errp,"Invalid parameter type for '%s', expected: object" , +full_name (qiv, name));return false; }
@@ -326,8 +326,8 @@ static bool qobject_input_start_list(Visitor *v, const char *name,return false; }if (qobject_type (qobj) !=QTYPE_QLIST ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"array" ); +error_setg (errp,"Invalid parameter type for '%s', expected: array" , +full_name (qiv, name));return false; }
@@ -405,8 +405,8 @@ static bool qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj, } qnum =qobject_to (QNum, qobj);if (!qnum || !qnum_get_try_int (qnum, obj)) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"integer" ); +error_setg (errp,"Invalid parameter type for '%s', expected: integer" , +full_name (qiv, name));return false; }return true;
@@ -494,8 +494,8 @@ static bool qobject_input_type_bool(Visitor *v, const char *name, bool *obj, } qbool =qobject_to (QBool, qobj);if (!qbool) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"boolean" ); +error_setg (errp,"Invalid parameter type for '%s', expected: boolean" , +full_name (qiv, name));return false; }
@@ -534,8 +534,8 @@ static bool qobject_input_type_str(Visitor *v, const char *name, char **obj, } qstr =qobject_to (QString, qobj);if (!qstr) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"string" ); +error_setg (errp,"Invalid parameter type for '%s', expected: string" , +full_name (qiv, name));return false; }
@@ -565,8 +565,8 @@ static bool qobject_input_type_number(Visitor *v, const char *name, double *obj, } qnum =qobject_to (QNum, qobj);if (!qnum) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"number" ); +error_setg (errp,"Invalid parameter type for '%s', expected: number" , +full_name (qiv, name));return false; }
@@ -587,8 +587,8 @@ static bool qobject_input_type_number_keyval(Visitor *v, const char *name,if (qemu_strtod_finite (str,NULL , &val)) {/* TODO report -ERANGE more nicely */ -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"number" ); +error_setg (errp,"Invalid parameter type for '%s', expected: number" , +full_name (qiv, name));return false; }
@@ -623,8 +623,8 @@ static bool qobject_input_type_null(Visitor *v, const char *name, }if (qobject_type (qobj) !=QTYPE_QNULL ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , -full_name (qiv, name),"null" ); +error_setg (errp,"Invalid parameter type for '%s', expected: null" , +full_name (qiv, name));return false; } *obj =qnull ();
qapi/string-input-visitor.c +4 -4
@@ -353,8 +353,8 @@ static bool parse_type_number(Visitor *v, const char *name, double *obj,assert (siv->lm ==LM_NONE );if (qemu_strtod_finite (siv->string,NULL , &val)) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"number" ); +error_setg (errp,"Invalid parameter type for '%s', expected: number" , + name ? name :"null" );return false; }
@@ -371,8 +371,8 @@ static bool parse_type_null(Visitor *v, const char *name, QNull **obj, *obj =NULL ;if (siv->string[0 ]) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name ? name :"null" , -"null" ); +error_setg (errp,"Invalid parameter type for '%s', expected: null" , + name ? name :"null" );return false; }
qom/object.c +8 -4
@@ -1443,7 +1443,8 @@ char *object_property_get_str(Object *obj, const char *name, } qstring =qobject_to (QString, ret);if (!qstring) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"string" ); +error_setg (errp,"Invalid parameter type for '%s', expected: string" , + name); retval =NULL ; }else { retval =g_strdup (qstring_get_str (qstring));
@@ -1504,7 +1505,8 @@ bool object_property_get_bool(Object *obj, const char *name, } qbool =qobject_to (QBool, ret);if (!qbool) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"boolean" ); +error_setg (errp,"Invalid parameter type for '%s', expected: boolean" , + name); retval = false; }else { retval =qbool_get_bool (qbool);
@@ -1537,7 +1539,8 @@ int64_t object_property_get_int(Object *obj, const char *name, qnum =qobject_to (QNum, ret);if (!qnum || !qnum_get_try_int (qnum, &retval)) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"int" ); +error_setg (errp,"Invalid parameter type for '%s', expected: int" , + name); retval =-1 ; }
@@ -1606,7 +1609,8 @@ uint64_t object_property_get_uint(Object *obj, const char *name, } qnum =qobject_to (QNum, ret);if (!qnum || !qnum_get_try_uint (qnum, &retval)) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"uint" ); +error_setg (errp,"Invalid parameter type for '%s', expected: uint" , + name); retval =0 ; }
Signature · 1 line
2.41.0
PATCH 9/21 qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Manual changes (escaping the format in qapi/visit.py). Remove the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- qom/object.c | 3 ++- scripts/qapi/visit.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_INVALID_PARAMETER_TYPE \ - "Invalid parameter type for '%s', expected: %s" -#define QERR_INVALID_PARAMETER_VALUE \ "Parameter '%s' expects %s"
qom/object.c +2 -1
@@ -1855,7 +1855,8 @@ static Object *object_resolve_link(Object *obj, const char *name, }else if (!target) { target =object_resolve_path (path, &ambiguous);if (target || ambiguous) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name, target_type); +error_setg (errp,"Invalid parameter type for '%s', expected: %s" , + name, target_type); }else {error_set (errp,ERROR_CLASS_DEVICE_NOT_FOUND ,"Device '%s' not found" , path);
scripts/qapi/visit.py +2 -2
@@ -278,8 +278,8 @@ def gen_visit_alternate(name: str, variants: QAPISchemaVariants) -> str: abort(); default: assert(visit_is_input(v)); - error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", - "%(name)s"); + error_setg(errp, "Invalid parameter type for '%%s', expected: %(name)s", + name ? name : "null"); /* Avoid passing invalid *obj to qapi_free_%(c_name)s() */ g_free(*obj); *obj = NULL;
Signature · 1 line
2.41.0
PATCH 10/21 qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match@
expression errp;
constant param;
constant value;
@@
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value);
@script:python strformat depends on match@
param << match.param;
value << match.value;
fixedfmt; // new var
@@
fixedfmt = "\"Parameter '%s' expects %s\"" % (param[1:-1], value[1:-1])
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
constant match.param;
constant match.value;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value);
+ error_setg(errp, fixedfmt);--- backends/cryptodev-vhost-user.c | 4 +- backends/rng-egd.c | 4 +- backends/rng-random.c | 3 +- block/quorum.c | 3 +- blockdev.c | 9 ++-- blockjob.c | 3 +- chardev/char.c | 3 +- hw/usb/redirect.c | 4 +- migration/migration.c | 4 +- migration/options.c | 94 +++++++++++++-------------------- migration/page_cache.c | 8 +-- migration/ram.c | 4 +- monitor/fds.c | 8 +-- monitor/qmp-cmds.c | 3 +- net/filter-buffer.c | 3 +- net/filter.c | 7 ++- net/net.c | 9 ++-- qga/commands-win32.c | 4 +- qom/object_interfaces.c | 2 +- qom/qom-qmp-cmds.c | 7 ++- softmmu/balloon.c | 2 +- softmmu/cpus.c | 3 +- softmmu/qdev-monitor.c | 11 ++-- ui/ui-qmp-cmds.c | 2 +- util/qemu-option.c | 3 +- 25 files changed, 88 insertions(+), 119 deletions(-)
backends/cryptodev-vhost-user.c +2 -2
@@ -136,8 +136,8 @@ cryptodev_vhost_claim_chardev(CryptoDevBackendVhostUser *s,Chardev *chr;if (s->chr_name ==NULL ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"chardev" ,"a valid character device" ); +error_setg (errp, +"Parameter 'chardev' expects a valid character device" );return NULL ; }
backends/rng-egd.c +2 -2
@@ -90,8 +90,8 @@ static void rng_egd_opened(RngBackend *b, Error **errp)Chardev *chr;if (s->chr_name ==NULL ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"chardev" ,"a valid character device" ); +error_setg (errp, +"Parameter 'chardev' expects a valid character device" );return ; }
backends/rng-random.c +1 -2
@@ -72,8 +72,7 @@ static void rng_random_opened(RngBackend *b, Error **errp)RngRandom *s =RNG_RANDOM (b);if (s->filename ==NULL ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"filename" ,"a valid filename" ); +error_setg (errp,"Parameter 'filename' expects a valid filename" ); }else { s->fd =qemu_open_old (s->filename,O_RDONLY |O_NONBLOCK );if (s->fd ==-1 ) {
block/quorum.c +1 -2
@@ -882,8 +882,7 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp) {if (threshold <1 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"vote-threshold" ,"a value >= 1" ); +error_setg (errp,"Parameter 'vote-threshold' expects a value >= 1" );return -ERANGE ; }
blockdev.c +4 -5
@@ -2340,7 +2340,7 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name, }if (size <0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"size" ,"a >0 size" ); +error_setg (errp,"Parameter 'size' expects a >0 size" );return ; }
@@ -2905,13 +2905,12 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, }if (granularity !=0 && (granularity <512 || granularity >1048576 *64 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"granularity" , -"a value in range [512B, 64MB]" ); +error_setg (errp, +"Parameter 'granularity' expects a value in range [512B, 64MB]" );return ; }if (granularity & (granularity -1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"granularity" , -"a power of 2" ); +error_setg (errp,"Parameter 'granularity' expects a power of 2" );return ; }
blockjob.c +1 -2
@@ -297,8 +297,7 @@ bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp)return false; }if (speed <0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"speed" , -"a non-negative value" ); +error_setg (errp,"Parameter 'speed' expects a non-negative value" );return false; }
chardev/char.c +1 -2
@@ -517,8 +517,7 @@ static const ChardevClass *char_get_class(const char *driver, Error **errp) }if (object_class_is_abstract (oc)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , -"an abstract device type" ); +error_setg (errp,"Parameter 'driver' expects an abstract device type" );return NULL ; }
hw/usb/redirect.c +2 -2
@@ -1435,8 +1435,8 @@ static void usbredir_realize(USBDevice *udev, Error **errp) &dev->filter_rules, &dev->filter_rules_count);if (i) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"filter" , -"a usb device filter string" ); +error_setg (errp, +"Parameter 'filter' expects a usb device filter string" );return ; } }
migration/migration.c +2 -2
@@ -1703,8 +1703,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, }else if (strstart (uri,"fd:" , &p)) {fd_start_outgoing_migration (s, p, &local_err); }else { -error_setg (&local_err,QERR_INVALID_PARAMETER_VALUE ,"uri" , -"a valid migration protocol" ); +error_setg (&local_err, +"Parameter 'uri' expects a valid migration protocol" );migrate_set_state (&s->state,MIGRATION_STATUS_SETUP ,MIGRATION_STATUS_FAILED );block_cleanup_parameters ();
migration/options.c +38 -56
192 lines not on this page · raw message
migration/page_cache.c +4 -4
@@ -45,15 +45,15 @@ PageCache *cache_init(uint64_t new_size, size_t page_size, Error **errp)PageCache *cache;if (new_size < page_size) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"cache size" , -"is smaller than one target page size" ); +error_setg (errp, +"Parameter 'cache size' expects is smaller than one target page size" );return NULL ; }/* round down to the nearest power of 2 */ if (!is_power_of_2 (num_pages)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"cache size" , -"is not a power of two number of pages" ); +error_setg (errp, +"Parameter 'cache size' expects is not a power of two number of pages" );return NULL ; }
migration/ram.c +2 -2
@@ -165,8 +165,8 @@ int xbzrle_cache_resize(uint64_t new_size, Error **errp)/* Check for truncation */ if (new_size != (size_t )new_size) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"cache size" , -"exceeding address space" ); +error_setg (errp, +"Parameter 'cache size' expects exceeding address space" );return -1 ; }
monitor/fds.c +4 -4
@@ -67,8 +67,8 @@ static bool monitor_add_fd(Monitor *mon, int fd, const char *fdname, Error **errif (qemu_isdigit (fdname[0 ])) {close (fd); -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"fdname" , -"a name not starting with a digit" ); +error_setg (errp, +"Parameter 'fdname' expects a name not starting with a digit" );return false; }
@@ -353,8 +353,8 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,if (has_fdset_id) {if (fdset_id <0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"fdset-id" , -"a non-negative value" ); +error_setg (errp, +"Parameter 'fdset-id' expects a non-negative value" );return NULL ; }/* Use specified fdset ID */
monitor/qmp-cmds.c +1 -2
@@ -173,8 +173,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,if (has_cpu_index) {int ret =monitor_set_cpu (&hmp.common, cpu_index);if (ret <0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"cpu-index" , -"a CPU number" ); +error_setg (errp,"Parameter 'cpu-index' expects a CPU number" ); goto out; } }
net/filter-buffer.c +1 -2
@@ -121,8 +121,7 @@ static void filter_buffer_setup(NetFilterState *nf, Error **errp)* or COLO use this filter to release packets on demand. */ if (!s->interval) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"interval" , -"a non-zero interval" ); +error_setg (errp,"Parameter 'interval' expects a non-zero interval" );return ; }
net/filter.c +3 -4
@@ -232,8 +232,7 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)NET_CLIENT_DRIVER_NIC , MAX_QUEUE_NUM);if (queues <1 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"netdev" , -"a network backend id" ); +error_setg (errp,"Parameter 'netdev' expects a network backend id" );return ; }else if (queues >1 ) {error_setg (errp,"multiqueue is not supported" );
@@ -251,8 +250,8 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)char *position_id;if (!g_str_has_prefix (nf->position,"id=" )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"position" , -"'head', 'tail' or 'id=<id>'" ); +error_setg (errp, +"Parameter 'position' expects 'head', 'tail' or 'id=<id>'" );return ; }
net/net.c +4 -5
@@ -1236,8 +1236,8 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) substrings =g_strsplit (ip6_net,"/" ,2 );if (!substrings || !substrings[0 ]) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"ipv6-net" , -"a valid IPv6 prefix" ); +error_setg (errp, +"Parameter 'ipv6-net' expects a valid IPv6 prefix" ); goto out; }
@@ -1247,8 +1247,7 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)if (substrings[1 ] &&qemu_strtoul (substrings[1 ],NULL ,10 , &prefix_len)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"ipv6-prefixlen" ,"a number" ); +error_setg (errp,"Parameter 'ipv6-prefixlen' expects a number" ); goto out; }
@@ -1283,7 +1282,7 @@ void netdev_add(QemuOpts *opts, Error **errp)void qmp_netdev_add (Netdev *netdev,Error **errp) {if (!id_wellformed (netdev->id)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"id" ,"an identifier" ); +error_setg (errp,"Parameter 'id' expects an identifier" );return ; }
qga/commands-win32.c +2 -2
@@ -328,8 +328,8 @@ void qmp_guest_shutdown(const char *mode, Error **errp) }else if (strcmp (mode,"reboot" ) ==0 ) { shutdown_flag |=EWX_REBOOT ; }else { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"mode" , -"'halt', 'powerdown', or 'reboot'" ); +error_setg (errp, +"Parameter 'mode' expects 'halt', 'powerdown', or 'reboot'" );return ; }
qom/object_interfaces.c +1 -1
@@ -84,7 +84,7 @@ Object *user_creatable_add_type(const char *type, const char *id,Error *local_err =NULL ;if (id !=NULL && !id_wellformed (id)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"id" ,"an identifier" ); +error_setg (errp,"Parameter 'id' expects an identifier" );error_append_hint (errp,"Identifiers consist of letters, digits, " "'-', '.', '_', starting with a letter.\n" );return NULL ;
qom/qom-qmp-cmds.c +3 -4
@@ -136,8 +136,8 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,if (!object_class_dynamic_cast (klass,TYPE_DEVICE ) ||object_class_is_abstract (klass)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"typename" , -"a non-abstract device type" ); +error_setg (errp, +"Parameter 'typename' expects a non-abstract device type" );return NULL ; }
@@ -194,8 +194,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, }if (!object_class_dynamic_cast (klass,TYPE_OBJECT )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"typename" , -"a QOM type" ); +error_setg (errp,"Parameter 'typename' expects a QOM type" );return NULL ; }
softmmu/balloon.c +1 -1
@@ -97,7 +97,7 @@ void qmp_balloon(int64_t target, Error **errp) }if (target <=0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"target" ,"a size" ); +error_setg (errp,"Parameter 'target' expects a size" );return ; }
softmmu/cpus.c +1 -2
@@ -753,8 +753,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, cpu =qemu_get_cpu (cpu_index);if (cpu ==NULL ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"cpu-index" , -"a CPU number" ); +error_setg (errp,"Parameter 'cpu-index' expects a CPU number" );return ; }
softmmu/qdev-monitor.c +5 -6
@@ -246,16 +246,15 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp) }if (object_class_is_abstract (oc)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , -"a non-abstract device type" ); +error_setg (errp, +"Parameter 'driver' expects a non-abstract device type" );return NULL ; } dc =DEVICE_CLASS (oc);if (!dc->user_creatable || (phase_check (PHASE_MACHINE_READY ) && !dc->hotpluggable)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , -"a pluggable device type" ); +error_setg (errp,"Parameter 'driver' expects a pluggable device type" );return NULL ; }
@@ -263,8 +262,8 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)/* sysbus devices need to be allowed by the machine */ MachineClass *mc =MACHINE_CLASS (object_get_class (qdev_get_machine ()));if (!device_type_is_dynamic_sysbus (mc, *driver)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , -"a dynamic sysbus device type for the machine" ); +error_setg (errp, +"Parameter 'driver' expects a dynamic sysbus device type for the machine" );return NULL ; } }
ui/ui-qmp-cmds.c +1 -1
@@ -209,7 +209,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,return ; } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"protocol" ,"'spice'" ); +error_setg (errp,"Parameter 'protocol' expects 'spice'" ); }#ifdef CONFIG_PNG
util/qemu-option.c +1 -2
@@ -622,8 +622,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, }else if (id) {assert (fail_if_exists);if (!id_wellformed (id)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"id" , -"an identifier" ); +error_setg (errp,"Parameter 'id' expects an identifier" );error_append_hint (errp,"Identifiers consist of letters, digits, " "'-', '.', '_', starting with a letter.\n" );return NULL ;
Signature · 1 line
2.41.0
Re: [PATCH 10/21] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
Quoted 35 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/Mechanical transformation using the following
coccinelle semantic patch:@match@ expression errp; constant param; constant value; @@ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value); @script:python strformat depends on match@ param << match.param; value << match.value; fixedfmt; // new var @@ fixedfmt = "\"Parameter '%s' expects %s\"" % (param[1:-1], value[1:-1]) coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ expression match.errp; constant match.param; constant match.value; identifier strformat.fixedfmt; @@ - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value); + error_setg(errp, fixedfmt);
Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
And like the approach, but
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 2910
Quoted 6 lines
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {blockdev.c +2
-2-error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"granularity" , -"a value in range [512B, 64MB]" ); +error_setg (errp, +"Parameter 'granularity' expects a value in range [512B, 64MB]" );return ;
There are several lines like this one that become way bigger than 80 characters.
Later, Juan.
PD. No, I have no clue about how to convince coccinelle to obey qemu
indentation rules.
Re: [PATCH 10/21] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
Quoted 49 lines · Juan Quintela
Quoted 35 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/Mechanical transformation using the following
coccinelle semantic patch:@match@ expression errp; constant param; constant value; @@ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value); @script:python strformat depends on match@ param << match.param; value << match.value; fixedfmt; // new var @@ fixedfmt = "\"Parameter '%s' expects %s\"" % (param[1:-1], value[1:-1]) coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ expression match.errp; constant match.param; constant match.value; identifier strformat.fixedfmt; @@ - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value); + error_setg(errp, fixedfmt);Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Juan Quintela <[email protected]>And like the approach, but
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 2910
Quoted 6 lines
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {blockdev.c +2
-2-error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"granularity" , -"a value in range [512B, 64MB]" ); +error_setg (errp, +"Parameter 'granularity' expects a value in range [512B, 64MB]" );return ;
Quoted 2 lines
There are several lines like this one that become way bigger than 80 characters.
Yes, I just realized I forgot to run checkpatch.pl :/
Now done, this is the single patch producing:
ERROR: line over 90 characters
Quoted 4 lines
Later, Juan.
PD. No, I have no clue about how to convince coccinelle to obey qemu
indentation rules.
Well this use Python, so we could check the length and split (returning some tuple) but:
$ ./scripts/checkpatch.pl origin/master.. | fgrep 'ERROR:' | wc -l
10So I guess I'll just manually adapt :)
PATCH 11/21 qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant param)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match@
identifier errp;
expression param; // not constant
constant value;
@@
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value);
@script:python strformat depends on match@
param << match.param;
value << match.value;
fixedfmt; // new var
@@
fixedfmt = f"\"Parameter '%s' expects {value[1:-1]}\""
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
identifier match.errp;
expression match.param;
constant match.value;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, param, value);
+ error_setg(errp, fixedfmt, param);--- hw/core/qdev-properties-system.c | 5 +++-- qapi/opts-visitor.c | 3 +-- qapi/qapi-util.c | 3 +-- qapi/qobject-input-visitor.c | 18 ++++++++---------- qapi/string-input-visitor.c | 18 ++++++++++-------- util/qemu-option.c | 7 ++++--- 6 files changed, 27 insertions(+), 27 deletions(-)
hw/core/qdev-properties-system.c +3 -2
@@ -769,8 +769,9 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,return ; }if (value <-1 || value >255 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , - name ? name :"null" ,"a value between -1 and 255" ); +error_setg (errp, +"Parameter '%s' expects a value between -1 and 255" , + name ? name :"null" );return ; } *ptr = value;
qapi/opts-visitor.c +1 -2
@@ -515,8 +515,7 @@ opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp) err =qemu_strtosz (opt->str ? opt->str :"" ,NULL , obj);if (err <0 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , opt->name, -"a size value" ); +error_setg (errp,"Parameter '%s' expects a size value" , opt->name);return false; }
qapi/qapi-util.c +1 -2
@@ -101,8 +101,7 @@ bool qapi_bool_parse(const char *name, const char *value, bool *obj, Error **errreturn true; } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name, -"'on' or 'off'" ); +error_setg (errp,"Parameter '%s' expects 'on' or 'off'" , name);return false; }
qapi/qobject-input-visitor.c +8 -10
@@ -424,8 +424,8 @@ static bool qobject_input_type_int64_keyval(Visitor *v, const char *name,if (qemu_strtoi64 (str,NULL ,0 , obj) <0 ) {/* TODO report -ERANGE more nicely */ -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -full_name (qiv, name),"integer" ); +error_setg (errp,"Parameter '%s' expects integer" , +full_name (qiv, name));return false; }return true;
@@ -458,8 +458,7 @@ static bool qobject_input_type_uint64(Visitor *v, const char *name, } err: -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -full_name (qiv, name),"uint64" ); +error_setg (errp,"Parameter '%s' expects uint64" ,full_name (qiv, name));return false; }
@@ -475,8 +474,8 @@ static bool qobject_input_type_uint64_keyval(Visitor *v, const char *name,if (qemu_strtou64 (str,NULL ,0 , obj) <0 ) {/* TODO report -ERANGE more nicely */ -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -full_name (qiv, name),"integer" ); +error_setg (errp,"Parameter '%s' expects integer" , +full_name (qiv, name));return false; }return true;
@@ -514,8 +513,8 @@ static bool qobject_input_type_bool_keyval(Visitor *v, const char *name, }if (!qapi_bool_parse (name, str, obj,NULL )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -full_name (qiv, name),"'on' or 'off'" ); +error_setg (errp,"Parameter '%s' expects 'on' or 'off'" , +full_name (qiv, name));return false; }return true;
@@ -643,8 +642,7 @@ static bool qobject_input_type_size_keyval(Visitor *v, const char *name,if (qemu_strtosz (str,NULL , obj) <0 ) {/* TODO report -ERANGE more nicely */ -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -full_name (qiv, name),"size" ); +error_setg (errp,"Parameter '%s' expects size" ,full_name (qiv, name));return false; }return true;
qapi/string-input-visitor.c +10 -8
@@ -189,16 +189,17 @@ static bool parse_type_int64(Visitor *v, const char *name, int64_t *obj,case LM_NONE :/* just parse a simple int64, bail out if not completely consumed */ if (qemu_strtoi64 (siv->string,NULL ,0 , &val)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , - name ? name :"null" ,"int64" ); +error_setg (errp,"Parameter '%s' expects int64" , + name ? name :"null" );return false; } *obj = val;return true;case LM_UNPARSED :if (try_parse_int64_list_entry (siv, obj)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"list of int64 values or ranges" ); +error_setg (errp, +"Parameter '%s' expects list of int64 values or ranges" , + name ? name :"null" );return false; }assert (siv->lm ==LM_INT64_RANGE );
@@ -279,16 +280,17 @@ static bool parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,case LM_NONE :/* just parse a simple uint64, bail out if not completely consumed */ if (qemu_strtou64 (siv->string,NULL ,0 , &val)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"uint64" ); +error_setg (errp,"Parameter '%s' expects uint64" , + name ? name :"null" );return false; } *obj = val;return true;case LM_UNPARSED :if (try_parse_uint64_list_entry (siv, obj)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" , -"list of uint64 values or ranges" ); +error_setg (errp, +"Parameter '%s' expects list of uint64 values or ranges" , + name ? name :"null" );return false; }assert (siv->lm ==LM_UINT64_RANGE );
util/qemu-option.c +4 -3
@@ -101,7 +101,7 @@ static bool parse_option_number(const char *name, const char *value,return false; }if (err) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name,"a number" ); +error_setg (errp,"Parameter '%s' expects a number" , name);return false; } *ret = number;
@@ -142,8 +142,9 @@ bool parse_option_size(const char *name, const char *value,return false; }if (err) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name, -"a non-negative number below 2^64" ); +error_setg (errp, +"Parameter '%s' expects a non-negative number below 2^64" , + name);error_append_hint (errp,"Optional suffix k, M, G, T, P or E means" " kilo-, mega-, giga-, tera-, peta-\n" "and exabytes, respectively.\n" );
Signature · 1 line
2.41.0
PATCH 12/21 qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Manually modify the error_report() call in softmmu/tpm.c, then use sed to mechanically transform the rest. Finally remove the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- qapi/opts-visitor.c | 4 ++-- qapi/qapi-visit-core.c | 4 ++-- softmmu/tpm.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_INVALID_PARAMETER_VALUE \ - "Parameter '%s' expects %s" -#define QERR_IO_ERROR \ "An IO error has occurred"
qapi/opts-visitor.c +2 -2
@@ -441,7 +441,7 @@ opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) } } } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , opt->name, +error_setg (errp,"Parameter '%s' expects %s" , opt->name, (ov->list_mode ==LM_NONE ) ?"an int64 value" :"an int64 value or range" );return false;
@@ -494,7 +494,7 @@ opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) } } } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , opt->name, +error_setg (errp,"Parameter '%s' expects %s" , opt->name, (ov->list_mode ==LM_NONE ) ?"a uint64 value" :"a uint64 value or range" );return false;
qapi/qapi-visit-core.c +2 -2
@@ -194,7 +194,7 @@ static bool visit_type_uintN(Visitor *v, uint64_t *obj, const char *name, }if (value > max) {assert (v->type ==VISITOR_INPUT ); -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +error_setg (errp,"Parameter '%s' expects %s" , name ? name :"null" , type);return false; }
@@ -262,7 +262,7 @@ static bool visit_type_intN(Visitor *v, int64_t *obj, const char *name, }if (value < min || value > max) {assert (v->type ==VISITOR_INPUT ); -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +error_setg (errp,"Parameter '%s' expects %s" , name ? name :"null" , type);return false; }
softmmu/tpm.c +1 -2
@@ -120,8 +120,7 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) i =qapi_enum_parse (&TpmType_lookup, value,-1 ,NULL ); be = i >=0 ?tpm_be_find_by_type (i) :NULL ;if (be ==NULL ) { -error_report (QERR_INVALID_PARAMETER_VALUE , -"type" ,"a TPM backend type" ); +error_report ("Parameter 'type' expects a TPM backend type" );tpm_display_backend_drivers ();return 1 ; }
Signature · 1 line
2.41.0
Re: [PATCH 12/21] qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition
Quoted 8 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Quoted 5 lines
Manually modify the
error_report()call insoftmmu/tpm.c, then use sed to mechanically transform the rest. Finally remove the definition ininclude/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 79 lines
--- include/qapi/qmp/qerror.h | 3 --- qapi/opts-visitor.c | 4 ++-- qapi/qapi-visit-core.c | 4 ++-- softmmu/tpm.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-)include/qapi/qmp/qerror.h +0
-3@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_INVALID_PARAMETER_VALUE \ - "Parameter '%s' expects %s" -#define QERR_IO_ERROR \ "An IO error has occurred"qapi/opts-visitor.c +2
-2@@ -441,7 +441,7 @@ opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) } } } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , opt->name, +error_setg (errp,"Parameter '%s' expects %s" , opt->name, (ov->list_mode ==LM_NONE ) ?"an int64 value" :"an int64 value or range" );return false;@@ -494,7 +494,7 @@ opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) } } } -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , opt->name, +error_setg (errp,"Parameter '%s' expects %s" , opt->name, (ov->list_mode ==LM_NONE ) ?"a uint64 value" :"a uint64 value or range" );return false;qapi/qapi-visit-core.c +2
-2@@ -194,7 +194,7 @@ static bool visit_type_uintN(Visitor *v, uint64_t *obj, const char *name, }if (value > max) {assert (v->type ==VISITOR_INPUT ); -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +error_setg (errp,"Parameter '%s' expects %s" , name ? name :"null" , type);return false; }@@ -262,7 +262,7 @@ static bool visit_type_intN(Visitor *v, int64_t *obj, const char *name, }if (value < min || value > max) {assert (v->type ==VISITOR_INPUT ); -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +error_setg (errp,"Parameter '%s' expects %s" , name ? name :"null" , type);return false; }softmmu/tpm.c +1
-2@@ -120,8 +120,7 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) i =qapi_enum_parse (&TpmType_lookup, value,-1 ,NULL ); be = i >=0 ?tpm_be_find_by_type (i) :NULL ;if (be ==NULL ) { -error_report (QERR_INVALID_PARAMETER_VALUE , -"type" ,"a TPM backend type" ); +error_report ("Parameter 'type' expects a TPM backend type" );tpm_display_backend_drivers ();return 1 ; }
PATCH 13/21 qapi: Inline and remove QERR_IO_ERROR definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using:
$ sed -i -e 's/QERR_IO_ERROR/"An IO error has occurred"/' \
$(git grep -wl QERR_IO_ERROR)then manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- block/vmdk.c | 8 ++++---- blockdev.c | 2 +- dump/win_dump.c | 4 ++-- migration/savevm.c | 4 ++-- softmmu/cpus.c | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_IO_ERROR \ - "An IO error has occurred" -#define QERR_MIGRATION_ACTIVE \ "There's a migration process in progress"
block/vmdk.c +4 -4
@@ -2246,12 +2246,12 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress,/* write all the data */ ret =blk_co_pwrite (blk,0 ,sizeof (magic), &magic,0 );if (ret <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto exit; } ret =blk_co_pwrite (blk,sizeof (magic),sizeof (header), &header,0 );if (ret <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto exit; }
@@ -2271,7 +2271,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, ret =blk_co_pwrite (blk,le64_to_cpu (header.rgd_offset) *BDRV_SECTOR_SIZE , gd_buf_size, gd_buf,0 );if (ret <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto exit; }
@@ -2283,7 +2283,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, ret =blk_co_pwrite (blk,le64_to_cpu (header.gd_offset) *BDRV_SECTOR_SIZE , gd_buf_size, gd_buf,0 );if (ret <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); } ret =0 ;
blockdev.c +1 -1
@@ -1433,7 +1433,7 @@ static void external_snapshot_action(TransactionAction *action,if (!bdrv_is_read_only (state->old_bs)) {if (bdrv_flush (state->old_bs)) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto out; } }
dump/win_dump.c +2 -2
@@ -67,7 +67,7 @@ static size_t write_run(uint64_t base_page, uint64_t page_count, l =qemu_write_full (fd, buf, len);cpu_physical_memory_unmap (buf, addr, false, len);if (l != len) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" );return 0 ; }
@@ -459,7 +459,7 @@ void create_win_dump(DumpState *s, Error **errp) s->written_size =qemu_write_full (s->fd, h, hdr_size);if (s->written_size != hdr_size) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto out_restore; }
migration/savevm.c +2 -2
@@ -3099,7 +3099,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,object_unref (OBJECT (ioc)); ret =qemu_save_device_state (f);if (ret <0 ||qemu_fclose (f) <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); }else {/* libxl calls the QMP command "stop" before calling * "xen-save-devices-state" and in case of migration failure, libxl
@@ -3148,7 +3148,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp) ret =qemu_loadvm_state (f);qemu_fclose (f);if (ret <0 ) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); }migration_incoming_state_destroy (); }
softmmu/cpus.c +2 -2
@@ -773,7 +773,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, goto exit; }if (fwrite (buf,1 , l, f) != l) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto exit; } addr += l;
@@ -803,7 +803,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, l = size;cpu_physical_memory_read (addr, buf, l);if (fwrite (buf,1 , l, f) != l) { -error_setg (errp,QERR_IO_ERROR ); +error_setg (errp,"An IO error has occurred" ); goto exit; } addr += l;
Signature · 1 line
2.41.0
Re: [PATCH 13/21] qapi: Inline and remove QERR_IO_ERROR definition
Quoted 8 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Quoted 8 lines
Mechanical transformation using:
$ sed -i -e 's/QERR_IO_ERROR/"An IO error has occurred"/' \ $(git grep -wl QERR_IO_ERROR)then manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
PATCH 14/21 qapi: Inline and remove QERR_MIGRATION_ACTIVE definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- migration/migration.c | 2 +- migration/options.c | 4 ++-- migration/savevm.c | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_MIGRATION_ACTIVE \ - "There's a migration process in progress" -#define QERR_MISSING_PARAMETER \ "Parameter '%s' is missing"
migration/migration.c +1 -1
@@ -1616,7 +1616,7 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, }if (migration_is_running (s->state)) { -error_setg (errp,QERR_MIGRATION_ACTIVE ); +error_setg (errp,"There's a migration process in progress" );return false; }
migration/options.c +2 -2
@@ -618,7 +618,7 @@ bool migrate_cap_set(int cap, bool value, Error **errp)bool new_caps[MIGRATION_CAPABILITY__MAX ];if (migration_is_running (s->state)) { -error_setg (errp,QERR_MIGRATION_ACTIVE ); +error_setg (errp,"There's a migration process in progress" );return false; }
@@ -662,7 +662,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,bool new_caps[MIGRATION_CAPABILITY__MAX ];if (migration_is_running (s->state) ||migration_in_colo_state ()) { -error_setg (errp,QERR_MIGRATION_ACTIVE ); +error_setg (errp,"There's a migration process in progress" );return ; }
migration/savevm.c +1 -1
@@ -1634,7 +1634,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)MigrationStatus status;if (migration_is_running (ms->state)) { -error_setg (errp,QERR_MIGRATION_ACTIVE ); +error_setg (errp,"There's a migration process in progress" );return -EINVAL ; }
Signature · 1 line
2.41.0
Re: [PATCH 14/21] qapi: Inline and remove QERR_MIGRATION_ACTIVE definition
Quoted 8 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Quoted 4 lines
Mechanical transformation using sed, manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
PATCH 15/21 qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patches:
@match@
expression errp;
constant param;
@@
error_setg(errp, QERR_MISSING_PARAMETER, param);
@script:python strformat depends on match@
param << match.param;
fixedfmt; // new var
@@
if param[0] == '"': # Format skipping '"',
fixedfmt = f'"Parameter \'{param[1:-1]}\' is missing"'
else: # or use definition.
fixedfmt = f'"Parameter " {param} " is missing"'
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
constant match.param;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_MISSING_PARAMETER, param);
+ error_setg(errp, fixedfmt);and:
@match@
constant param;
@@
error_report(QERR_MISSING_PARAMETER, param);
@script:python strformat depends on match@
param << match.param;
fixedfmt; // new var
@@
fixedfmt = f'"Parameter \'{param[1:-1]}\' is missing"'
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
constant match.param;
identifier strformat.fixedfmt;
@@
- error_report(QERR_MISSING_PARAMETER, param);
+ error_report(fixedfmt);--- backends/dbus-vmstate.c | 2 +- block/gluster.c | 21 +++++++++++---------- block/monitor/block-hmp-cmds.c | 6 +++--- dump/dump.c | 4 ++-- hw/usb/redirect.c | 2 +- softmmu/qdev-monitor.c | 2 +- softmmu/tpm.c | 4 ++-- softmmu/vl.c | 4 ++-- ui/input-barrier.c | 2 +- ui/ui-qmp-cmds.c | 2 +- 10 files changed, 25 insertions(+), 24 deletions(-)
backends/dbus-vmstate.c +1 -1
@@ -413,7 +413,7 @@ dbus_vmstate_complete(UserCreatable *uc, Error **errp) }if (!self->dbus_addr) { -error_setg (errp,QERR_MISSING_PARAMETER ,"addr" ); +error_setg (errp,"Parameter 'addr' is missing" );return ; }
block/gluster.c +11 -10
@@ -530,20 +530,20 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, num_servers =qdict_array_entries (options,GLUSTER_OPT_SERVER_PATTERN );if (num_servers <1 ) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,"server" ); +error_setg (&local_err,"Parameter 'server' is missing" ); goto out; } ptr =qemu_opt_get (opts,GLUSTER_OPT_VOLUME );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_VOLUME ); +error_setg (&local_err,"Parameter " GLUSTER_OPT_VOLUME " is missing" ); goto out; } gconf->volume =g_strdup (ptr); ptr =qemu_opt_get (opts,GLUSTER_OPT_PATH );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_PATH ); +error_setg (&local_err,"Parameter " GLUSTER_OPT_PATH " is missing" ); goto out; } gconf->path =g_strdup (ptr);
@@ -562,7 +562,8 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, ptr =qemu_opt_get (opts,GLUSTER_OPT_TYPE );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_TYPE ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_TYPE " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out;
@@ -592,16 +593,16 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, ptr =qemu_opt_get (opts,GLUSTER_OPT_HOST );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_HOST ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_HOST " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; } gsconf->u.inet.host =g_strdup (ptr); ptr =qemu_opt_get (opts,GLUSTER_OPT_PORT );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_PORT ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_PORT " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; }
@@ -648,8 +649,8 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, goto out; }if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_PATH ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_PATH " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; }
block/monitor/block-hmp-cmds.c +3 -3
@@ -252,7 +252,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) };if (!filename) { -error_setg (&err,QERR_MISSING_PARAMETER ,"target" ); +error_setg (&err,"Parameter 'target' is missing" ); goto end; }qmp_drive_mirror (&mirror, &err);
@@ -281,7 +281,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) };if (!filename) { -error_setg (&err,QERR_MISSING_PARAMETER ,"target" ); +error_setg (&err,"Parameter 'target' is missing" ); goto end; }
@@ -356,7 +356,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)* In the future, if 'snapshot-file' is not specified, the snapshot * will be taken internally. Today it's actually required. */ -error_setg (&err,QERR_MISSING_PARAMETER ,"snapshot-file" ); +error_setg (&err,"Parameter 'snapshot-file' is missing" ); goto end; }
dump/dump.c +2 -2
@@ -2096,11 +2096,11 @@ void qmp_dump_guest_memory(bool paging, const char *file,return ; }if (has_begin && !has_length) { -error_setg (errp,QERR_MISSING_PARAMETER ,"length" ); +error_setg (errp,"Parameter 'length' is missing" );return ; }if (!has_begin && has_length) { -error_setg (errp,QERR_MISSING_PARAMETER ,"begin" ); +error_setg (errp,"Parameter 'begin' is missing" );return ; }if (has_detach) {
hw/usb/redirect.c +1 -1
@@ -1426,7 +1426,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp)int i;if (!qemu_chr_fe_backend_connected (&dev->cs)) { -error_setg (errp,QERR_MISSING_PARAMETER ,"chardev" ); +error_setg (errp,"Parameter 'chardev' is missing" );return ; }
softmmu/qdev-monitor.c +1 -1
@@ -622,7 +622,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, driver =qdict_get_try_str (opts,"driver" );if (!driver) { -error_setg (errp,QERR_MISSING_PARAMETER ,"driver" ); +error_setg (errp,"Parameter 'driver' is missing" );return NULL ; }
softmmu/tpm.c +2 -2
@@ -106,13 +106,13 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) id =qemu_opts_id (opts);if (id ==NULL ) { -error_report (QERR_MISSING_PARAMETER ,"id" ); +error_report ("Parameter 'id' is missing" );return 1 ; } value =qemu_opt_get (opts,"type" );if (!value) { -error_report (QERR_MISSING_PARAMETER ,"type" ); +error_report ("Parameter 'type' is missing" );tpm_display_backend_drivers ();return 1 ; }
softmmu/vl.c +2 -2
@@ -1801,7 +1801,7 @@ static void object_option_parse(const char *optarg) type =qemu_opt_get (opts,"qom-type" );if (!type) { -error_setg (&error_fatal,QERR_MISSING_PARAMETER ,"qom-type" ); +error_setg (&error_fatal,"Parameter 'qom-type' is missing" ); }if (user_creatable_print_help (type, opts)) {exit (0 );
@@ -2266,7 +2266,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)bool qtest_with_kvm;if (!acc) { -error_setg (errp,QERR_MISSING_PARAMETER ,"accel" ); +error_setg (errp,"Parameter 'accel' is missing" ); goto bad; }
ui/input-barrier.c +1 -1
@@ -493,7 +493,7 @@ static void input_barrier_complete(UserCreatable *uc, Error **errp)Error *local_err =NULL ;if (!ib->name) { -error_setg (errp,QERR_MISSING_PARAMETER ,"name" ); +error_setg (errp,"Parameter 'name' is missing" );return ; }
ui/ui-qmp-cmds.c +1 -1
@@ -195,7 +195,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname, }if (!has_port && !has_tls_port) { -error_setg (errp,QERR_MISSING_PARAMETER ,"port/tls-port" ); +error_setg (errp,"Parameter 'port/tls-port' is missing" );return ; }
Signature · 1 line
2.41.0
Re: [PATCH 15/21] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
Quoted 56 lines · Philippe Mathieu-Daudé
Address the comment added in commit
4629ed1e98
("qerror: Finally unused, clean up"), from 2015:/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/Mechanical transformation using the following
coccinelle semantic patches:@match@ expression errp; constant param; @@ error_setg(errp, QERR_MISSING_PARAMETER, param); @script:python strformat depends on match@ param << match.param; fixedfmt; // new var @@ if param[0] == '"': # Format skipping '"', fixedfmt = f'"Parameter \'{param[1:-1]}\' is missing"' else: # or use definition. fixedfmt = f'"Parameter " {param} " is missing"' coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ expression match.errp; constant match.param; identifier strformat.fixedfmt; @@ - error_setg(errp, QERR_MISSING_PARAMETER, param); + error_setg(errp, fixedfmt);and:
@match@ constant param; @@ error_report(QERR_MISSING_PARAMETER, param); @script:python strformat depends on match@ param << match.param; fixedfmt; // new var @@ fixedfmt = f'"Parameter \'{param[1:-1]}\' is missing"' coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ constant match.param; identifier strformat.fixedfmt; @@ - error_report(QERR_MISSING_PARAMETER, param); + error_report(fixedfmt);
Quoted 1 line
Signed-off-by Philippe Mathieu-Daud <[email protected]>
Quoted 239 lines
--- backends/dbus-vmstate.c | 2 +- block/gluster.c | 21 +++++++++++---------- block/monitor/block-hmp-cmds.c | 6 +++--- dump/dump.c | 4 ++-- hw/usb/redirect.c | 2 +- softmmu/qdev-monitor.c | 2 +- softmmu/tpm.c | 4 ++-- softmmu/vl.c | 4 ++-- ui/input-barrier.c | 2 +- ui/ui-qmp-cmds.c | 2 +- 10 files changed, 25 insertions(+), 24 deletions(-)backends/dbus-vmstate.c +1
-1@@ -413,7 +413,7 @@ dbus_vmstate_complete(UserCreatable *uc, Error **errp) }if (!self->dbus_addr) { -error_setg (errp,QERR_MISSING_PARAMETER ,"addr" ); +error_setg (errp,"Parameter 'addr' is missing" );return ; }block/gluster.c +11
-10@@ -530,20 +530,20 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, num_servers =qdict_array_entries (options,GLUSTER_OPT_SERVER_PATTERN );if (num_servers <1 ) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,"server" ); +error_setg (&local_err,"Parameter 'server' is missing" ); goto out; } ptr =qemu_opt_get (opts,GLUSTER_OPT_VOLUME );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_VOLUME ); +error_setg (&local_err,"Parameter " GLUSTER_OPT_VOLUME " is missing" ); goto out; } gconf->volume =g_strdup (ptr); ptr =qemu_opt_get (opts,GLUSTER_OPT_PATH );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_PATH ); +error_setg (&local_err,"Parameter " GLUSTER_OPT_PATH " is missing" ); goto out; } gconf->path =g_strdup (ptr);@@ -562,7 +562,8 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, ptr =qemu_opt_get (opts,GLUSTER_OPT_TYPE );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER ,GLUSTER_OPT_TYPE ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_TYPE " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out;@@ -592,16 +593,16 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, ptr =qemu_opt_get (opts,GLUSTER_OPT_HOST );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_HOST ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_HOST " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; } gsconf->u.inet.host =g_strdup (ptr); ptr =qemu_opt_get (opts,GLUSTER_OPT_PORT );if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_PORT ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_PORT " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; }@@ -648,8 +649,8 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, goto out; }if (!ptr) { -error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_PATH ); +error_setg (&local_err, +"Parameter " GLUSTER_OPT_PATH " is missing" );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; }block/monitor/block-hmp-cmds.c +3
-3@@ -252,7 +252,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) };if (!filename) { -error_setg (&err,QERR_MISSING_PARAMETER ,"target" ); +error_setg (&err,"Parameter 'target' is missing" ); goto end; }qmp_drive_mirror (&mirror, &err);@@ -281,7 +281,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) };if (!filename) { -error_setg (&err,QERR_MISSING_PARAMETER ,"target" ); +error_setg (&err,"Parameter 'target' is missing" ); goto end; }@@ -356,7 +356,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)* In the future, if 'snapshot-file' is not specified, the snapshot * will be taken internally. Today it's actually required. */ -error_setg (&err,QERR_MISSING_PARAMETER ,"snapshot-file" ); +error_setg (&err,"Parameter 'snapshot-file' is missing" ); goto end; }dump/dump.c +2
-2@@ -2096,11 +2096,11 @@ void qmp_dump_guest_memory(bool paging, const char *file,return ; }if (has_begin && !has_length) { -error_setg (errp,QERR_MISSING_PARAMETER ,"length" ); +error_setg (errp,"Parameter 'length' is missing" );return ; }if (!has_begin && has_length) { -error_setg (errp,QERR_MISSING_PARAMETER ,"begin" ); +error_setg (errp,"Parameter 'begin' is missing" );return ; }if (has_detach) {hw/usb/redirect.c +1
-1@@ -1426,7 +1426,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp)int i;if (!qemu_chr_fe_backend_connected (&dev->cs)) { -error_setg (errp,QERR_MISSING_PARAMETER ,"chardev" ); +error_setg (errp,"Parameter 'chardev' is missing" );return ; }softmmu/qdev-monitor.c +1
-1@@ -622,7 +622,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, driver =qdict_get_try_str (opts,"driver" );if (!driver) { -error_setg (errp,QERR_MISSING_PARAMETER ,"driver" ); +error_setg (errp,"Parameter 'driver' is missing" );return NULL ; }softmmu/tpm.c +2
-2@@ -106,13 +106,13 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) id =qemu_opts_id (opts);if (id ==NULL ) { -error_report (QERR_MISSING_PARAMETER ,"id" ); +error_report ("Parameter 'id' is missing" );return 1 ; } value =qemu_opt_get (opts,"type" );if (!value) { -error_report (QERR_MISSING_PARAMETER ,"type" ); +error_report ("Parameter 'type' is missing" );tpm_display_backend_drivers ();return 1 ; }softmmu/vl.c +2
-2@@ -1801,7 +1801,7 @@ static void object_option_parse(const char *optarg) type =qemu_opt_get (opts,"qom-type" );if (!type) { -error_setg (&error_fatal,QERR_MISSING_PARAMETER ,"qom-type" ); +error_setg (&error_fatal,"Parameter 'qom-type' is missing" ); }if (user_creatable_print_help (type, opts)) {exit (0 );@@ -2266,7 +2266,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)bool qtest_with_kvm;if (!acc) { -error_setg (errp,QERR_MISSING_PARAMETER ,"accel" ); +error_setg (errp,"Parameter 'accel' is missing" ); goto bad; }ui/input-barrier.c +1
-1@@ -493,7 +493,7 @@ static void input_barrier_complete(UserCreatable *uc, Error **errp)Error *local_err =NULL ;if (!ib->name) { -error_setg (errp,QERR_MISSING_PARAMETER ,"name" ); +error_setg (errp,"Parameter 'name' is missing" );return ; }ui/ui-qmp-cmds.c +1
-1@@ -195,7 +195,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname, }if (!has_port && !has_tls_port) { -error_setg (errp,QERR_MISSING_PARAMETER ,"port/tls-port" ); +error_setg (errp,"Parameter 'port/tls-port' is missing" );return ; }
PATCH 16/21 qapi: Inline and remove QERR_MISSING_PARAMETER definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- qapi/opts-visitor.c | 2 +- qapi/qapi-forward-visitor.c | 2 +- qapi/qobject-input-visitor.c | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_MISSING_PARAMETER \ - "Parameter '%s' is missing" -#define QERR_PROPERTY_VALUE_BAD \ "Property '%s.%s' doesn't take value '%s'"
qapi/opts-visitor.c +1 -1
@@ -218,7 +218,7 @@ lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp) list =g_hash_table_lookup (ov->unprocessed_opts, name);if (!list) { -error_setg (errp,QERR_MISSING_PARAMETER , name); +error_setg (errp,"Parameter '%s' is missing" , name); }return list; }
qapi/qapi-forward-visitor.c +1 -1
@@ -49,7 +49,7 @@ static bool forward_field_translate_name(ForwardFieldVisitor *v, const char **na *name = v->to;return true; } -error_setg (errp,QERR_MISSING_PARAMETER , *name); +error_setg (errp,"Parameter '%s' is missing" , *name);return false; }
qapi/qobject-input-visitor.c +1 -1
@@ -168,7 +168,7 @@ static QObject *qobject_input_get_object(QObjectInputVisitor *qiv,QObject *obj =qobject_input_try_get_object (qiv, name, consume);if (!obj) { -error_setg (errp,QERR_MISSING_PARAMETER ,full_name (qiv, name)); +error_setg (errp,"Parameter '%s' is missing" ,full_name (qiv, name)); }return obj; }
Signature · 1 line
2.41.0
PATCH 17/21 qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Manual change. Remove the definition ininclude/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- hw/core/qdev-properties.c | 2 +- target/i386/cpu.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_PROPERTY_VALUE_BAD \ - "Property '%s.%s' doesn't take value '%s'" -#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
hw/core/qdev-properties.c +1 -1
@@ -682,7 +682,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,break ;default :case -EINVAL : -error_setg (errp,QERR_PROPERTY_VALUE_BAD , +error_setg (errp,"Property '%s.%s' doesn't take value '%s'" ,object_get_typename (obj), name, value);break ;case -ENOENT :
target/i386/cpu.c +1 -1
@@ -5190,7 +5190,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,int i;if (strlen (value) !=CPUID_VENDOR_SZ ) { -error_setg (errp,QERR_PROPERTY_VALUE_BAD ,"" ,"vendor" , value); +error_setg (errp,"Property 'vendor' doesn't take value '%s'" , value);return ; }
Signature · 1 line
2.41.0
PATCH 18/21 qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using sed, manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- hw/intc/openpic.c | 3 ++- target/i386/cpu.c | 12 ++++++++---- util/block-helpers.c | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ - "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")" -#define QERR_QGA_COMMAND_FAILED \ "Guest agent command failed, error was '%s'"
hw/intc/openpic.c +2 -1
@@ -1535,7 +1535,8 @@ static void openpic_realize(DeviceState *dev, Error **errp) };if (opp->nb_cpus >MAX_CPU ) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , +error_setg (errp,"Property %s.%s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" ,TYPE_OPENPIC ,"nb_cpus" , (uint64_t )opp->nb_cpus, (uint64_t )0 , (uint64_t )MAX_CPU );return ;
target/i386/cpu.c +8 -4
@@ -5086,7 +5086,8 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v,return ; }if (value < min || value > max) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , +error_setg (errp,"Property %s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" , name ? name :"null" , value, min, max);return ; }
@@ -5126,7 +5127,8 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v,return ; }if (value < min || value > max) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , +error_setg (errp,"Property %s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" , name ? name :"null" , value, min, max);return ; }
@@ -5161,7 +5163,8 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,return ; }if (value < min || value > max) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , +error_setg (errp,"Property %s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" , name ? name :"null" , value, min, max);return ; }
@@ -5263,7 +5266,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,return ; }if (value < min || value > max) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE ,"" , +error_setg (errp,"Property %s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" , name ? name :"null" , value, min, max);return ; }
util/block-helpers.c +2 -1
@@ -30,7 +30,8 @@ void check_block_size(const char *id, const char *name, int64_t value, {/* value of 0 means "unset" */ if (value && (value <MIN_BLOCK_SIZE || value >MAX_BLOCK_SIZE )) { -error_setg (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , +error_setg (errp,"Property %s.%s doesn't take value %" PRId64 +" (minimum: %" PRId64", maximum: %" PRId64")" , id, name, value,MIN_BLOCK_SIZE ,MAX_BLOCK_SIZE );return ; }
Signature · 1 line
2.41.0
PATCH 19/21 qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using the following
coccinelle semantic patch:
@match exists@
expression errp;
expression errmsg;
@@
error_setg(errp, QERR_QGA_COMMAND_FAILED, errmsg);
@script:python strformat depends on match@
errmsg << match.errmsg;
fixedfmt; // new var
@@
# Format skipping '"'.
fixedfmt = f'"Guest agent command failed, error was \'{errmsg[1:-1]}\'"'
coccinelle.fixedfmt = cocci.make_ident(fixedfmt)
@replace@
expression match.errp;
expression match.errmsg;
identifier strformat.fixedfmt;
@@
- error_setg(errp, QERR_QGA_COMMAND_FAILED, errmsg);
+ error_setg(errp, fixedfmt);then manually removing the definition in include/qapi/qmp/qerror.h.
--- include/qapi/qmp/qerror.h | 3 --- qga/commands-win32.c | 38 ++++++++++++++++++++------------------ qga/commands.c | 7 ++++--- 3 files changed, 24 insertions(+), 24 deletions(-)
include/qapi/qmp/qerror.h +0 -3
@@ -17,9 +17,6 @@* add new ones! */ -#define QERR_QGA_COMMAND_FAILED \ - "Guest agent command failed, error was '%s'" -#define QERR_UNSUPPORTED \ "this feature or command is not currently supported"
qga/commands-win32.c +20 -18
@@ -245,7 +245,8 @@ int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp) done:if (gerr) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , gerr->message); +error_setg (errp, +"Guest agent command failed, error was 'err -> messag'" );g_error_free (gerr); }g_free (w_path);
@@ -279,8 +280,8 @@ static void acquire_privilege(const char *name, Error **errp) TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {if (!LookupPrivilegeValue (NULL , name, &priv.Privileges[0 ].Luid)) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"no luid for requested privilege" ); +error_setg (errp, +"Guest agent command failed, error was 'no luid for requested privilege'" ); goto out; }
@@ -288,14 +289,14 @@ static void acquire_privilege(const char *name, Error **errp) priv.Privileges[0 ].Attributes =SE_PRIVILEGE_ENABLED ;if (!AdjustTokenPrivileges (token, FALSE, &priv,0 ,NULL ,0 )) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"unable to acquire requested privilege" ); +error_setg (errp, +"Guest agent command failed, error was 'unable to acquire requested privilege'" ); goto out; } }else { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"failed to open privilege token" ); +error_setg (errp, +"Guest agent command failed, error was 'failed to open privilege token'" ); } out:
@@ -309,8 +310,8 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque, {HANDLE thread =CreateThread (NULL ,0 , func, opaque,0 ,NULL );if (!thread) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"failed to dispatch asynchronous command" ); +error_setg (errp, +"Guest agent command failed, error was 'failed to dispatch asynchronous command'" ); } }
@@ -1423,22 +1424,22 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp)ZeroMemory (&sys_pwr_caps,sizeof (sys_pwr_caps));if (!GetPwrCapabilities (&sys_pwr_caps)) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"failed to determine guest suspend capabilities" ); +error_setg (errp, +"Guest agent command failed, error was 'failed to determine guest suspend capabilities'" );return ; }switch (mode) {case GUEST_SUSPEND_MODE_DISK :if (!sys_pwr_caps.SystemS4) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"suspend-to-disk not supported by OS" ); +error_setg (errp, +"Guest agent command failed, error was 'suspend-to-disk not supported by OS'" ); }break ;case GUEST_SUSPEND_MODE_RAM :if (!sys_pwr_caps.SystemS3) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"suspend-to-ram not supported by OS" ); +error_setg (errp, +"Guest agent command failed, error was 'suspend-to-ram not supported by OS'" ); }break ;default :
@@ -1971,7 +1972,8 @@ void qmp_guest_set_user_password(const char *username, done:if (gerr) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , gerr->message); +error_setg (errp, +"Guest agent command failed, error was 'err -> messag'" );g_error_free (gerr); }g_free (user);
@@ -2180,8 +2182,8 @@ static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp)HMODULE module =GetModuleHandle ("ntdll" );PVOID fun =GetProcAddress (module,"RtlGetVersion" );if (fun ==NULL ) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"Failed to get address of RtlGetVersion" ); +error_setg (errp, +"Guest agent command failed, error was 'Failed to get address of RtlGetVersion'" );return ; }
qga/commands.c +4 -3
@@ -475,7 +475,8 @@ GuestExec *qmp_guest_exec(const char *path, guest_exec_task_setup, &has_merge, &pid, input_data ? &in_fd :NULL , has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr);if (!ret) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , gerr->message); +error_setg (errp, +"Guest agent command failed, error was 'err -> messag'" );g_error_free (gerr); goto done; }
@@ -586,8 +587,8 @@ GuestTimezone *qmp_guest_get_timezone(Error **errp) info =g_new0 (GuestTimezone,1 ); tz =g_time_zone_new_local ();if (tz ==NULL ) { -error_setg (errp,QERR_QGA_COMMAND_FAILED , -"Couldn't retrieve local timezone" ); +error_setg (errp, +"Guest agent command failed, error was 'Couldn't retrieve local timezone'" ); goto error; }
Signature · 1 line
2.41.0
RFC PATCH 20/21 qapi: Inline and remove QERR_UNSUPPORTED definition
In reply to Philippe Mathieu-DaudéAddress the comment added in commit 4629ed1e98
("qerror: Finally unused, clean up"), from 2015:
/*
* These macros will go away, please don't use
* in new code, and do not add new ones!
*/
Mechanical transformation using:
$ sed -i -e 's/QERR_UNSUPPORTED/"this feature or command is not currently supported"/' \
$(git grep -wl QERR_UNSUPPORTED)then manually removing the definition in include/qapi/qmp/qerror.h.
---
RFC: Not sure what is the best way to change the comment
in qga/qapi-schema.json...
--- qga/qapi-schema.json | 5 +++-- include/qapi/qmp/qerror.h | 3 --- qga/commands-bsd.c | 8 +++---- qga/commands-posix.c | 46 +++++++++++++++++++-------------------- qga/commands-win32.c | 22 +++++++++---------- 5 files changed, 41 insertions(+), 43 deletions(-)
qga/qapi-schema.json +3 -2
@@ -6,8 +6,9 @@ # # "unsupported" is a higher-level error than the errors that # individual commands might document. The caller should always be -# prepared to receive QERR_UNSUPPORTED, even if the given command -# doesn't specify it, or doesn't document any failure mode at all. +# prepared to receive the "this feature or command is not currently supported" +# message, even if the given command doesn't specify it, or doesn't document +# any failure mode at all. ## ##
include/qapi/qmp/qerror.h +0 -3
@@ -17,7 +17,4 @@* add new ones! */ -#define QERR_UNSUPPORTED \ - "this feature or command is not currently supported" -#endif /* QERROR_H */
qga/commands-bsd.c +4 -4
@@ -152,25 +152,25 @@ int qmp_guest_fsfreeze_do_thaw(Error **errp)GuestFilesystemInfoList *qmp_guest_get_fsinfo (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestDiskInfoList *qmp_guest_get_disks (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestDiskStatsInfoList *qmp_guest_get_diskstats (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestCpuStatsList *qmp_guest_get_cpustats (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }#endif /* CONFIG_FSFREEZE */
qga/commands-posix.c +23 -23
172 lines not on this page · raw message
qga/commands-win32.c +11 -11
@@ -1213,7 +1213,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)GuestFsfreezeStatus qmp_guest_fsfreeze_status (Error **errp) {if (!vss_initialized ()) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }
@@ -1241,7 +1241,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,Error *local_err =NULL ;if (!vss_initialized ()) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }
@@ -1276,7 +1276,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)int i;if (!vss_initialized ()) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }
@@ -1509,7 +1509,7 @@ out:void qmp_guest_suspend_hybrid (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }static IP_ADAPTER_ADDRESSES *guest_get_adapters_addresses (Error **errp)
@@ -1877,7 +1877,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)int64_t qmp_guest_set_vcpus (GuestLogicalProcessorList *vcpus,Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return -1 ; }
@@ -1938,7 +1938,7 @@ void qmp_guest_set_user_password(const char *username,GError *gerr =NULL ;if (crypted) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return ; }
@@ -1983,20 +1983,20 @@ done:GuestMemoryBlockList *qmp_guest_get_memory_blocks (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestMemoryBlockResponseList *qmp_guest_set_memory_blocks (GuestMemoryBlockList *mem_blks,Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestMemoryBlockInfo *qmp_guest_get_memory_block_info (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
@@ -2522,12 +2522,12 @@ char *qga_get_host_name(Error **errp)GuestDiskStatsInfoList *qmp_guest_get_diskstats (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }GuestCpuStatsList *qmp_guest_get_cpustats (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
Signature · 1 line
2.41.0
PATCH 21/21 qapi: Remove 'qapi/qmp/qerror.h' header
In reply to Philippe Mathieu-DaudéThis file is now empty. Avoid new definitions by killing it, paying off a 8 years old debt (with interests).
Mechanical change using:
$ git grep -l qapi/qmp/qerror.h | while read f; do \
gawk -i inplace '/#include "qapi\/qmp\/qerror.h"/ && !p {p++;next}1' $f; \
done--- include/qapi/qmp/qerror.h | 20 -------------------- backends/cryptodev-vhost-user.c | 1 - backends/dbus-vmstate.c | 1 - backends/rng-egd.c | 1 - backends/rng-random.c | 1 - block/gluster.c | 1 - block/monitor/block-hmp-cmds.c | 1 - block/quorum.c | 1 - block/snapshot.c | 1 - block/vmdk.c | 1 - blockdev.c | 1 - blockjob.c | 1 - chardev/char-fe.c | 1 - chardev/char.c | 1 - dump/dump.c | 1 - dump/win_dump.c | 1 - hw/core/qdev-properties-system.c | 1 - hw/core/qdev-properties.c | 1 - hw/core/qdev.c | 1 - hw/intc/openpic.c | 1 - hw/ppc/spapr_pci.c | 1 - hw/usb/redirect.c | 1 - migration/migration.c | 1 - migration/options.c | 1 - migration/page_cache.c | 1 - migration/ram.c | 1 - migration/savevm.c | 1 - monitor/fds.c | 1 - monitor/hmp-cmds.c | 1 - monitor/qmp-cmds.c | 1 - net/filter-buffer.c | 1 - net/filter.c | 1 - net/net.c | 1 - qapi/opts-visitor.c | 1 - qapi/qapi-forward-visitor.c | 1 - qapi/qapi-util.c | 1 - qapi/qapi-visit-core.c | 1 - qapi/qobject-input-visitor.c | 1 - qapi/string-input-visitor.c | 1 - qga/commands-bsd.c | 1 - qga/commands-posix.c | 1 - qga/commands-win32.c | 1 - qga/commands.c | 1 - qom/object.c | 1 - qom/object_interfaces.c | 1 - qom/qom-qmp-cmds.c | 1 - softmmu/balloon.c | 1 - softmmu/cpus.c | 1 - softmmu/qdev-monitor.c | 1 - softmmu/rtc.c | 1 - softmmu/tpm.c | 1 - softmmu/vl.c | 1 - target/arm/arm-qmp-cmds.c | 1 - target/i386/cpu.c | 1 - target/s390x/cpu_models_sysemu.c | 1 - ui/input-barrier.c | 1 - ui/ui-qmp-cmds.c | 1 - util/block-helpers.c | 1 - util/qemu-option.c | 1 - scripts/qapi/visit.py | 1 - 60 files changed, 79 deletions(-) delete mode 100644 include/qapi/qmp/qerror.h
include/qapi/qmp/qerror.h deleted +0 -20
@@ -1,20 +0,0 @@ -/* -* QError Module -* -* Copyright (C) 2009 Red Hat Inc. -* -* Authors: -* Luiz Capitulino <[email protected]> -* -* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. -* See the COPYING.LIB file in the top-level directory. -*/ -#ifndef QERROR_H -#define QERROR_H - -/* -* These macros will go away, please don't use in new code, and do not -* add new ones! -*/ - -#endif /* QERROR_H */
backends/cryptodev-vhost-user.c +0 -1
@@ -23,7 +23,6 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-user.h" #include "standard-headers/linux/virtio_crypto.h"
backends/dbus-vmstate.c +0 -1
@@ -16,7 +16,6 @@#include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object_interfaces.h" -#include "qapi/qmp/qerror.h" #include "migration/vmstate.h" #include "trace.h" #include "qom/object.h"
backends/rng-egd.c +0 -1
@@ -14,7 +14,6 @@#include "sysemu/rng.h" #include "chardev/char-fe.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/module.h" #include "qom/object.h"
backends/rng-random.c +0 -1
@@ -14,7 +14,6 @@#include "sysemu/rng-random.h" #include "sysemu/rng.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/main-loop.h" #include "qemu/module.h"
block/gluster.c +0 -1
@@ -16,7 +16,6 @@#include "block/qdict.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qemu/uri.h" #include "qemu/error-report.h" #include "qemu/module.h"
block/monitor/block-hmp-cmds.c +0 -1
@@ -43,7 +43,6 @@#include "qapi/qapi-commands-block-export.h" #include "qapi/qmp/qdict.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/sockets.h"
block/quorum.c +0 -1
@@ -24,7 +24,6 @@#include "qapi/error.h" #include "qapi/qapi-events-block.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" #include "crypto/hash.h"
block/snapshot.c +0 -1
@@ -28,7 +28,6 @@#include "block/qdict.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qstring.h" #include "qemu/option.h" #include "sysemu/block-backend.h"
block/vmdk.c +0 -1
@@ -28,7 +28,6 @@#include "block/block_int.h" #include "sysemu/block-backend.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h"
blockdev.c +0 -1
@@ -50,7 +50,6 @@#include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" #include "qapi/qobject-output-visitor.h" #include "sysemu/sysemu.h"
blockjob.c +0 -1
@@ -32,7 +32,6 @@#include "sysemu/block-backend.h" #include "qapi/error.h" #include "qapi/qapi-events-block-core.h" -#include "qapi/qmp/qerror.h" #include "qemu/main-loop.h" #include "qemu/timer.h"
chardev/char-fe.c +0 -1
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "sysemu/replay.h" #include "chardev/char-fe.h"
chardev/char.c +0 -1
@@ -32,7 +32,6 @@#include "chardev/char.h" #include "qapi/error.h" #include "qapi/qapi-commands-char.h" -#include "qapi/qmp/qerror.h" #include "sysemu/replay.h" #include "qemu/help_option.h" #include "qemu/module.h"
dump/dump.c +0 -1
@@ -23,7 +23,6 @@#include "qapi/error.h" #include "qapi/qapi-commands-dump.h" #include "qapi/qapi-events-dump.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "hw/misc/vmcoreinfo.h"
dump/win_dump.c +0 -1
@@ -12,7 +12,6 @@#include "sysemu/dump.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "qapi/qmp/qerror.h" #include "exec/cpu-defs.h" #include "hw/core/cpu.h" #include "qemu/win_dump_defs.h"
hw/core/qdev-properties-system.c +0 -1
@@ -18,7 +18,6 @@#include "qapi/qapi-types-block.h" #include "qapi/qapi-types-machine.h" #include "qapi/qapi-types-migration.h" -#include "qapi/qmp/qerror.h" #include "qemu/ctype.h" #include "qemu/cutils.h" #include "qemu/units.h"
hw/core/qdev-properties.c +0 -1
@@ -2,7 +2,6 @@#include "hw/qdev-properties.h" #include "qapi/error.h" #include "qapi/qapi-types-misc.h" -#include "qapi/qmp/qerror.h" #include "qemu/ctype.h" #include "qemu/error-report.h" #include "qapi/visitor.h"
hw/core/qdev.c +0 -1
@@ -29,7 +29,6 @@#include "qapi/error.h" #include "qapi/qapi-events-qdev.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qemu/error-report.h" #include "qemu/option.h"
hw/intc/openpic.c +0 -1
@@ -41,7 +41,6 @@#include "hw/pci/msi.h" #include "qapi/error.h" #include "qemu/bitops.h" -#include "qapi/qmp/qerror.h" #include "qemu/module.h" #include "qemu/timer.h" #include "qemu/error-report.h"
hw/ppc/spapr_pci.c +0 -1
@@ -39,7 +39,6 @@#include "trace.h" #include "qemu/error-report.h" #include "qemu/module.h" -#include "qapi/qmp/qerror.h" #include "hw/ppc/fdt.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h"
hw/usb/redirect.c +0 -1
@@ -32,7 +32,6 @@#include "qemu/timer.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/iov.h" #include "qemu/module.h"
migration/migration.c +0 -1
@@ -42,7 +42,6 @@#include "qapi/qapi-visit-sockets.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-events-migration.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qnull.h" #include "qemu/rcu.h" #include "block.h"
migration/options.c +0 -1
@@ -17,7 +17,6 @@#include "qapi/error.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-visit-migration.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qnull.h" #include "sysemu/runstate.h" #include "migration/colo.h"
migration/page_cache.c +0 -1
@@ -14,7 +14,6 @@#include "qemu/osdep.h" -#include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "qemu/host-utils.h" #include "page_cache.h"
migration/ram.c +0 -1
@@ -47,7 +47,6 @@#include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" #include "qapi/qapi-commands-migration.h" -#include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" #include "exec/target_page.h"
migration/savevm.c +0 -1
@@ -45,7 +45,6 @@#include "qapi/qapi-commands-migration.h" #include "qapi/clone-visitor.h" #include "qapi/qapi-builtin-visit.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "sysemu/cpus.h" #include "exec/memory.h"
monitor/fds.c +0 -1
@@ -26,7 +26,6 @@#include "monitor-internal.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" -#include "qapi/qmp/qerror.h" #include "qemu/ctype.h" #include "qemu/cutils.h" #include "sysemu/runstate.h"
monitor/hmp-cmds.c +0 -1
@@ -24,7 +24,6 @@#include "qapi/qapi-commands-control.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qemu/cutils.h" #include "hw/intc/intc.h" #include "qemu/log.h"
monitor/qmp-cmds.c +0 -1
@@ -27,7 +27,6 @@#include "qapi/qapi-init-commands.h" #include "qapi/qapi-commands-control.h" #include "qapi/qapi-commands-misc.h" -#include "qapi/qmp/qerror.h" #include "qapi/type-helpers.h" #include "hw/mem/memory-device.h" #include "hw/intc/intc.h"
net/filter-buffer.c +0 -1
@@ -13,7 +13,6 @@#include "qemu/timer.h" #include "qemu/iov.h" #include "qapi/qapi-builtin-visit.h" -#include "qapi/qmp/qerror.h" #include "qom/object.h" #define TYPE_FILTER_BUFFER "filter-buffer"
net/filter.c +0 -1
@@ -8,7 +8,6 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "net/filter.h"
net/net.c +0 -1
@@ -37,7 +37,6 @@#include "qapi/qapi-commands-net.h" #include "qapi/qapi-visit-net.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/cutils.h"
qapi/opts-visitor.c +0 -1
@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/cutils.h" -#include "qapi/qmp/qerror.h" #include "qapi/opts-visitor.h" #include "qemu/queue.h" #include "qemu/option_int.h"
qapi/qapi-forward-visitor.c +0 -1
@@ -17,7 +17,6 @@#include "qapi/qmp/qjson.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qnull.h" #include "qapi/qmp/qnum.h"
qapi/qapi-util.c +0 -1
@@ -14,7 +14,6 @@#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qemu/ctype.h" -#include "qapi/qmp/qerror.h" CompatPolicy compat_policy;
qapi/qapi-visit-core.c +0 -1
@@ -15,7 +15,6 @@#include "qemu/osdep.h" #include "qapi/compat-policy.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qapi/visitor-impl.h" #include "trace.h"
qapi/qobject-input-visitor.c +0 -1
@@ -22,7 +22,6 @@#include "qapi/qmp/qjson.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qnull.h" #include "qapi/qmp/qnum.h"
qapi/string-input-visitor.c +0 -1
@@ -14,7 +14,6 @@#include "qapi/error.h" #include "qapi/string-input-visitor.h" #include "qapi/visitor-impl.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qnull.h" #include "qemu/option.h" #include "qemu/cutils.h"
qga/commands-bsd.c +0 -1
@@ -12,7 +12,6 @@#include "qemu/osdep.h" #include "qga-qapi-commands.h" -#include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "qemu/queue.h" #include "commands-common.h"
qga/commands-posix.c +0 -1
@@ -18,7 +18,6 @@#include <dirent.h> #include "qga-qapi-commands.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/host-utils.h" #include "qemu/sockets.h" #include "qemu/base64.h"
qga/commands-win32.c +0 -1
@@ -32,7 +32,6 @@#include "vss-win32.h" #include "qga-qapi-commands.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/queue.h" #include "qemu/host-utils.h" #include "qemu/base64.h"
qga/commands.c +0 -1
@@ -15,7 +15,6 @@#include "guest-agent-core.h" #include "qga-qapi-commands.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/base64.h" #include "qemu/cutils.h" #include "commands-common.h"
qom/object.c +0 -1
@@ -23,7 +23,6 @@#include "qapi/qobject-input-visitor.h" #include "qapi/forward-visitor.h" #include "qapi/qapi-builtin-visit.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qjson.h" #include "trace.h"
qom/object_interfaces.c +0 -1
@@ -5,7 +5,6 @@#include "qapi/qapi-visit-qom.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qjson.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h"
qom/qom-qmp-cmds.c +0 -1
@@ -21,7 +21,6 @@#include "qapi/qapi-commands-qom.h" #include "qapi/qapi-visit-qom.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qemu/cutils.h"
softmmu/balloon.c +0 -1
@@ -30,7 +30,6 @@#include "sysemu/balloon.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" -#include "qapi/qmp/qerror.h" #include "trace.h" static QEMUBalloonEvent *balloon_event_fn;
softmmu/cpus.c +0 -1
@@ -29,7 +29,6 @@#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-events-run-state.h" -#include "qapi/qmp/qerror.h" #include "exec/gdbstub.h" #include "sysemu/hw_accel.h" #include "exec/cpu-common.h"
softmmu/qdev-monitor.c +0 -1
@@ -27,7 +27,6 @@#include "qapi/qapi-commands-qdev.h" #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" #include "qemu/config-file.h"
softmmu/rtc.c +0 -1
@@ -25,7 +25,6 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/timer.h"
softmmu/tpm.c +0 -1
@@ -16,7 +16,6 @@#include "qapi/error.h" #include "qapi/qapi-commands-tpm.h" -#include "qapi/qmp/qerror.h" #include "sysemu/tpm_backend.h" #include "sysemu/tpm.h" #include "qemu/config-file.h"
softmmu/vl.c +0 -1
@@ -129,7 +129,6 @@#include "qapi/qapi-visit-qom.h" #include "qapi/qapi-commands-ui.h" #include "block/qdict.h" -#include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" #include "qemu/guest-random.h" #include "qemu/keyval.h"
target/arm/arm-qmp-cmds.c +0 -1
@@ -28,7 +28,6 @@#include "qapi/qobject-input-visitor.h" #include "qapi/qapi-commands-machine-target.h" #include "qapi/qapi-commands-misc-target.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qdict.h" #include "qom/qom-qobject.h"
target/i386/cpu.c +0 -1
@@ -31,7 +31,6 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "qapi/qapi-visit-machine.h" -#include "qapi/qmp/qerror.h" #include "standard-headers/asm-x86/kvm_para.h" #include "hw/qdev-properties.h" #include "hw/i386/topology.h"
target/s390x/cpu_models_sysemu.c +0 -1
@@ -17,7 +17,6 @@#include "sysemu/kvm.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qmp/qdict.h" #include "qapi/qapi-commands-machine-target.h"
ui/input-barrier.c +0 -1
@@ -21,7 +21,6 @@#include "qom/object.h" #include "ui/vnc_keysym.h" /* use name2keysym from VNC as we use X11 values */ #include "qemu/cutils.h" -#include "qapi/qmp/qerror.h" #include "input-barrier.h" #define TYPE_INPUT_BARRIER "input-barrier"
ui/ui-qmp-cmds.c +0 -1
@@ -18,7 +18,6 @@#include "io/channel-file.h" #include "monitor/qmp-helpers.h" #include "qapi/qapi-commands-ui.h" -#include "qapi/qmp/qerror.h" #include "qemu/coroutine.h" #include "qemu/cutils.h" #include "trace.h"
util/block-helpers.c +0 -1
@@ -10,7 +10,6 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "block-helpers.h" /**
util/qemu-option.c +0 -1
@@ -31,7 +31,6 @@#include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" -#include "qapi/qmp/qerror.h" #include "qemu/option_int.h" #include "qemu/cutils.h" #include "qemu/id.h"
scripts/qapi/visit.py +0 -1
@@ -356,7 +356,6 @@ def _begin_user_module(self, name: str) -> None: self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" #include "%(visit)s.h" ''', visit=visit))
Signature · 1 line
2.41.0
Re: [PATCH 21/21] qapi: Remove 'qapi/qmp/qerror.h' header
Quoted 10 lines · Philippe Mathieu-Daudé
This file is now empty. Avoid new definitions by killing it, paying off a 8 years old debt (with interests).
Mechanical change using:
$ git grep -l qapi/qmp/qerror.h | while read f; do \ gawk -i inplace '/#include "qapi\/qmp\/qerror.h"/ && !p {p++;next}1' $f; \ doneSigned-off-by Philippe Mathieu-Daudé <[email protected]>