qapi: Kill 'qapi/qmp/qerror.h' for good
Subsystems (2)
v2 cover qapi: Kill 'qapi/qmp/qerror.h' for good
Since v1:
- Fixed checkpatch warnings (Juan)
- Added R-b tags
- New patch for 'vcpu_dirty_limit'
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é (22):
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: Correct error message for 'vcpu_dirty_limit' parameter
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 | 102 +++++++++++++------------------ 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, 308 insertions(+), 437 deletions(-) delete mode 100644 include/qapi/qmp/qerror.h
Signature · 1 line
2.41.0
PATCH v2 1/22 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
Re: [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG 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]>
Thanks,
C.
Quoted 75 lines
--- 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 ; }
Re: [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
In reply to Philippe Mathieu-DaudéQuoted 37 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 sed, manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
hw/ppc/spapr_pci.c static void spapr_pci_pre_plug(HotplugHandler *plug_handler, · line 1554
Quoted 6 lines
hw/ppc/spapr_pci.c +1
-1@@ -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)));
@phb is a SpaprPhbState *, thereforce object_get_typename() returns "spapr-pci-host-bridge", which is not a bus. It provides a bus: PCI bus phb->parent_obj.bus.
Should be fixed on top, so this patch remains mechanical.
Well outside this patch's scope, but here goes anyway: I wonder why we need this check. Why is the generic check in qdev_device_add_from_qdict() not enough?
hw/ppc/spapr_pci.c static void spapr_pci_unplug_request(HotplugHandler *plug_handler, · line 1674
Quoted 8 lines
hw/ppc/spapr_pci.c +1
-1return ; }@@ -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",
Likewise.
Quoted 27 lines
hw/ppc/spapr_pci.c +0
-0object_get_typename(OBJECT(phb)));return ; }softmmu/qdev-monitor.c +3
-2@@ -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 ; }
softmmu/qdev-monitor.c void qdev_unplug(DeviceState *dev, Error **errp) · line 911
Quoted 8 lines
softmmu/qdev-monitor.c +2
-1@@ -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 ; }
Could factor out
if (bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, "Bus '%s' does not support hotplugging", bus->name);
return false;
}
return true;Idea, not a demand.
PATCH v2 2/22 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
Re: [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition
Quoted 37 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 sed, manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
block/snapshot.c int bdrv_snapshot_delete(BlockDriverState *bs, · line 348
Quoted 5 lines
block/snapshot.c +1
-1@@ -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));
Break the line after the last comma, please.
block/snapshot.c int bdrv_snapshot_load_tmp(BlockDriverState *bs, · line 423
Quoted 9 lines
block/snapshot.c +1
-1return -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));
Likewise.
Quoted 8 lines
block/snapshot.c +0
-0return -ENOMEDIUM ; }if (!snapshot_id && !name) {blockdev.c +0
-0
blockdev.c static void external_snapshot_action(TransactionAction *action, · line 1427
Quoted 7 lines
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; }
Outside this patch's scope, but here goes anyway... Elsewhere in this file, we have two instances of
error_setg(errp, "Device has no medium");
The user gets to guess which device.
Looks like commit b6c1bae5df8 (block: Accept node-name for block-stream) and commit 7a9877a0263 (block: Accept device model name for block_set_io_throttle) sacrificed the '%s'. Can we put it back?
PATCH v2 3/22 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 v2 4/22 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
Re: [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition
Quoted 51 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 sed, manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
softmmu/qdev-monitor.c void qdev_unplug(DeviceState *dev, Error **errp) · line 917
Quoted 8 lines
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 ; }
Could factor out
if (!dc->hotpluggable)) {
error_setg(errp, "Device '%s' does not support hotplugging",
object_get_typename(OBJECT(dev)));
}
return true;Idea, not a demand.
PATCH v2 5/22 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
Re: [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter)
Quoted 45 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; @@ 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);Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
dump/dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1813
Quoted 4 lines
dump/dump.c +0
-1@@ -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" );
Incorrect use of QERR_INVALID_PARAMETER: the parameter is perfectly valid, the problem is its invalid value. Better:
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "a non-zero size");
dump/dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1813
Quoted 1 line
dump/dump.c +1
-0+error_setg (errp,"Invalid parameter 'length'" );
Applying PATCH 12's transformation then results in
error_setg(errp, "Parameter '%s' expects a non-zero size",
"length");
which you may want to contract to
error_setg(errp, "Parameter 'length' expects a non-zero size");
But not in this patch. Either before or after. I'd pick before.
dump/dump.c void qmp_dump_guest_memory(bool paging, const char *file,
Quoted 13 lines
dump/dump.c +1
-1goto 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 !defined(WIN32)
if (strstart(file, "fd:", &p)) {
fd = monitor_get_fd(monitor_cur(), p, errp);
if (fd == -1) {
return;
}
}#endif
if (strstart(file, "file:", &p)) {
fd = qemu_open_old(p, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR);
if (fd < 0) {
error_setg_file_open(errp, errno, p);
return;
}dump/dump.c void qmp_dump_guest_memory(bool paging, const char *file, · line 2148
Quoted 4 lines
dump/dump.c +0
-1}if (fd ==-1 ) { -error_setg (errp,QERR_INVALID_PARAMETER ,"protocol" );
This made me go "there is no parameter protocol", but then I double-checked the schema, and realized there is. It's just named @file here. We should rename it to match the schema.
Again, the use of QERR_INVALID_PARAMETER is wrong: @protocol is valid, its value isn't.
More: we should use qemu_create() instead of qemu_open_old(), to not throw away qemu_open_internal()'s error.
qga/commands.c GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp) · line 157
Quoted 13 lines
dump/dump.c +1
-0+error_setg (errp,"Invalid parameter 'protocol'" );return ; }qga/commands.c +0
-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" );
Again, the use of QERR_INVALID_PARAMETER is wrong: @pid is valid, its value isn't.
ui/ui-qmp-cmds.c void qmp_set_password(SetPasswordOptions *opts, Error **errp) · line 47
Quoted 13 lines
qga/commands.c +1
-0+error_setg (errp,"Invalid parameter 'pid'" );return NULL ; }ui/ui-qmp-cmds.c +0
-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" );
Same misuse of QERR_INVALID_PARAMETER.
util/qemu-option.c QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, · line 615
Quoted 13 lines
ui/ui-qmp-cmds.c +1
-0+error_setg (errp,"Invalid parameter 'connected'" );return ; }/* util/qemu-option.c +0
-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" );
This one is correct.
util/qemu-option.c QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, · line 618
Quoted 4 lines
util/qemu-option.c +1
-0+error_setg (errp,"Invalid parameter 'id'" );return NULL ; } opts =qemu_opts_find (list,NULL );
Score: 1 out of 6 points :)
None of this is your patch's fault.
PATCH v2 6/22 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
Re: [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition
monitor/hmp-cmds.c void hmp_sync_profile(Monitor *mon, const QDict *qdict)
Quoted 42 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:
$ 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.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0@@ -138,7 +138,7 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
const char *op = qdict_get_try_str(qdict, "op");
if (op == NULL) {
bool on = qsp_is_enabled();
monitor_printf(mon, "sync-profile is %s\n", on ? "on" : "off");
return;
}
if (!strcmp(op, "on")) {
qsp_enable();
} else if (!strcmp(op, "off")) {
qsp_disable();
} else if (!strcmp(op, "reset")) {
qsp_reset();monitor/hmp-cmds.c void hmp_sync_profile(Monitor *mon, const QDict *qdict) · line 141
Quoted 4 lines
monitor/hmp-cmds.c +0
-1}else {Error *err =NULL ; -error_setg (&err,QERR_INVALID_PARAMETER , op);
The use of QERR_INVALID_PARAMETER is wrong: (1) it takes a parameter name, but we pass a parameter value, and (2) parameter @op is valid, its value isn't.
Quoted 56 lines
monitor/hmp-cmds.c +1
-0+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; }
PATCH v2 7/22 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 v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
Quoted 61 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]>Acked-by Thomas Huth <[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 ; } }
The error messages are awful. Your patch makes their awfulness more visible. Improvement of sorts ;)
PATCH v2 8/22 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 v2 9/22 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 v2 10/22 qapi: Correct error message for 'vcpu_dirty_limit' parameter
In reply to Philippe Mathieu-DaudéQERR_INVALID_PARAMETER_VALUE is defined as:
#define QERR_INVALID_PARAMETER_VALUE \
"Parameter '%s' expects %s"The current error is formatted as:
"Parameter 'vcpu_dirty_limit' expects is invalid, it must greater then 1 MB/s"
Replace by:
"Parameter 'vcpu_dirty_limit' is invalid, it must greater then 1 MB/s"
--- migration/options.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
migration/options.c +2 -3
@@ -1163,9 +1163,8 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)if (params->has_vcpu_dirty_limit && (params->vcpu_dirty_limit <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"vcpu_dirty_limit" , -"is invalid, it must greater then 1 MB/s" ); +error_setg (errp,"Parameter 'vcpu_dirty_limit' is invalid," +" it must greater then 1 MB/s" );return false; }
Signature · 1 line
2.41.0
Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
Quoted 7 lines · Philippe Mathieu-Daudé
QERR_INVALID_PARAMETER_VALUEis defined as:#define QERR_INVALID_PARAMETER_VALUE \ "Parameter '%s' expects %s"The current error is formatted as:
Quoted 7 lines
"Parameter '
vcpu_dirty_limit' expects is invalid, it must greater then 1 MB/s"Replace by:
"Parameter '
vcpu_dirty_limit' is invalid, it must greater then 1 MB/s"Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
In reply to Philippe Mathieu-DaudéQuoted 23 lines · Philippe Mathieu-Daudé
QERR_INVALID_PARAMETER_VALUEis defined as:#define QERR_INVALID_PARAMETER_VALUE \ "Parameter '%s' expects %s"The current error is formatted as:
"Parameter '
vcpu_dirty_limit' expects is invalid, it must greater then 1 MB/s"Replace by:
"Parameter '
vcpu_dirty_limit' is invalid, it must greater then 1 MB/s"Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- migration/options.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)migration/options.c +0
-0
migration/options.c bool migrate_params_check(MigrationParameters *params, Error **errp) · line 1169
Quoted 10 lines
migration/options.c +2
-3@@ -1163,9 +1163,8 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)if (params->has_vcpu_dirty_limit && (params->vcpu_dirty_limit <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"vcpu_dirty_limit" , -"is invalid, it must greater then 1 MB/s" ); +error_setg (errp,"Parameter 'vcpu_dirty_limit' is invalid," +" it must greater then 1 MB/s" );return false; }
Make that "greater than", please.
Arrgh, the unit is MB/s even in QMP:
# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration.
# Defaults to 1. (Since 8.1)
Should be Bytes. Escaped review, and now it's too late to fix.
Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
Quoted 38 lines · Markus Armbruster
Quoted 23 lines · Philippe Mathieu-Daudé
QERR_INVALID_PARAMETER_VALUEis defined as:#define QERR_INVALID_PARAMETER_VALUE \ "Parameter '%s' expects %s"The current error is formatted as:
"Parameter '
vcpu_dirty_limit' expects is invalid, it must greater then 1 MB/s"Replace by:
"Parameter '
vcpu_dirty_limit' is invalid, it must greater then 1 MB/s"Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- migration/options.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)migration/options.c +0
-0migration/options.c bool migrate_params_check(MigrationParameters *params, Error **errp) · line 1169
Quoted 10 lines
migration/options.c +2
-3@@ -1163,9 +1163,8 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)if (params->has_vcpu_dirty_limit && (params->vcpu_dirty_limit <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"vcpu_dirty_limit" , -"is invalid, it must greater then 1 MB/s" ); +error_setg (errp,"Parameter 'vcpu_dirty_limit' is invalid," +" it must greater then 1 MB/s" );return false; }Make that "greater than", please.
Quoted 6 lines
Arrgh, the unit is MB/s even in QMP:
# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration.
# Defaults to 1. (Since 8.1)Should be Bytes. Escaped review, and now it's too late to fix.
I want a Time Machine.
I want a Time Machine.
Wait, if I had a Time Machine I would not be fixing old bugs O:-)
Later, Juan.
PATCH v2 11/22 qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
In reply to Philippe Mathieu-Daudévcpu_dirty_limit
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);Then manually splitting lines over 90 characters.
--- 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 | 92 ++++++++++++++------------------- 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, 89 insertions(+), 116 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 +39 -53
185 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 v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
Quoted 37 lines · Philippe Mathieu-Daudé
vcpu_dirty_limitAddress 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 4 lines
Then manually splitting lines over 90 characters.
Reviewed-by Juan Quintela <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Re: [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
In reply to Philippe Mathieu-DaudéQuoted 104 lines · Philippe Mathieu-Daudé
vcpu_dirty_limitAddress 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);Then manually splitting lines over 90 characters.
Reviewed-by Juan Quintela <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 | 92 ++++++++++++++------------------- 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, 89 insertions(+), 116 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 +0
-0
backends/rng-random.c static void rng_random_opened(RngBackend *b, Error **errp) · line 76
Quoted 5 lines
backends/rng-random.c +0
-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" );
Misuse of QERR_INVALID_PARAMETER_VALUE.
This function is RngBackendClass method opened(), which runs within interface UserCreatableClass method complete(), which runs right after an object with this interface was created. "Parameters" need not exist in this context.
The actual issue is property "filename" has not been set. So let's report that: "property 'filename' is required".
Separate patch, to keep this one mechanical.
Quoted 23 lines
backends/rng-random.c +1
-0+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 +0
-0
blockdev.c void coroutine_fn qmp_block_resize(const char *device, const char *node_name, · line 2343
Quoted 5 lines
blockdev.c +1
-1@@ -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" );
The message is awful. Not your patch's fault. Could improve it on top.
Quoted 9 lines
blockdev.c +0
-2return ; }@@ -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]" );
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 2915
Quoted 10 lines
blockdev.c +3
-2+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 ; }
Contracting the two checks so we can report "expects a power of 2 between 512 and 64MiB" would be better. Maybe on top.
We could quibble about the use of a unit. There is none in QMP. Moving on.
hw/usb/redirect.c static void usbredir_realize(USBDevice *udev, Error **errp)
Quoted 34 lines
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 +0
-0@@ -1435,8 +1435,8 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
i = usbredirfilter_string_to_rules(dev->filter_str, ":", "|",
hw/usb/redirect.c static void usbredir_realize(USBDevice *udev, Error **errp) · line 1439
Quoted 5 lines
hw/usb/redirect.c +0
-2&dev->filter_rules, &dev->filter_rules_count);if (i) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"filter" , -"a usb device filter string" );
Misuse of QERR_INVALID_PARAMETER_VALUE.
This is a realize() method. "Parameters" need not exist in this context.
The actual issue is property "filter" cannot be parsed (i == -EINVAL), or we're out of memory (i == -ENOMEM). This should arguable be checked then the property is set, because the error reporting will be better there. Requires creating a suitable PropertyInfo.
I'm not asking for that now. Instead, I suggest "property 'filter' is not a valid USB redirection filter". Bogus when -ENOMEM, but that's unlikely and no worse than before.
Separate patch, to keep this one mechanical. Not mentioning this again from now on.
Quoted 160 lines
hw/usb/redirect.c +2
-0+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 +29
-38@@ -1002,137 +1002,124 @@ bool migrate_params_check(MigrationParameters *params, Error **errp) {if (params->has_compress_level && (params->compress_level >9 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"compress_level" , -"a value between 0 and 9" ); +error_setg (errp,"Parameter 'compress_level' expects" +" a value between 0 and 9" );return false; }if (params->has_compress_threads && (params->compress_threads <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"compress_threads" , -"a value between 1 and 255" ); +error_setg (errp,"Parameter 'compress_threads' expects" +" a value between 1 and 255" );return false; }if (params->has_decompress_threads && (params->decompress_threads <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"decompress_threads" , -"a value between 1 and 255" ); +error_setg (errp,"Parameter 'decompress_threads' expects" +" a value between 1 and 255" );return false; }if (params->has_throttle_trigger_threshold && (params->throttle_trigger_threshold <1 || params->throttle_trigger_threshold >100 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"throttle_trigger_threshold" , -"an integer in the range of 1 to 100" ); +error_setg (errp,"Parameter 'throttle_trigger_threshold' expects" +" an integer in the range of 1 to 100" );return false; }if (params->has_cpu_throttle_initial && (params->cpu_throttle_initial <1 || params->cpu_throttle_initial >99 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"cpu_throttle_initial" , -"an integer in the range of 1 to 99" ); +error_setg (errp,"Parameter 'cpu_throttle_initial' expects" +" an integer in the range of 1 to 99" );return false; }if (params->has_cpu_throttle_increment && (params->cpu_throttle_increment <1 || params->cpu_throttle_increment >99 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"cpu_throttle_increment" , -"an integer in the range of 1 to 99" ); +error_setg (errp,"Parameter 'cpu_throttle_increment' expects" +" an integer in the range of 1 to 99" );return false; }if (params->has_max_bandwidth && (params->max_bandwidth >SIZE_MAX )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"max_bandwidth" , - "an integer in the range of 0 to "stringify(SIZE_MAX) -" bytes/second" ); + error_setg(errp, "Parameter 'max_bandwidth' expects" + " an integer in the range of 0" + " to " stringify(SIZE_MAX) " bytes/second");return false; }if (params->has_downtime_limit && (params->downtime_limit >MAX_MIGRATE_DOWNTIME )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"downtime_limit" , - "an integer in the range of 0 to " - stringify(MAX_MIGRATE_DOWNTIME)" ms"); +error_setg (errp, + "Parameter 'downtime_limit' expects" + " an integer in the range of 0" + " to " stringify(MAX_MIGRATE_DOWNTIME) " ms");return false; }/* x_checkpoint_delay is now always positive */ if (params->has_multifd_channels && (params->multifd_channels <1 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"multifd_channels" , -"a value between 1 and 255" ); +error_setg (errp,"Parameter 'multifd_channels' expects" +" a value between 1 and 255" );return false; }if (params->has_multifd_zlib_level && (params->multifd_zlib_level >9 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"multifd_zlib_level" , -"a value between 0 and 9" ); +error_setg (errp,"Parameter 'multifd_zlib_level' expects" +" a value between 0 and 9" );return false; }if (params->has_multifd_zstd_level && (params->multifd_zstd_level >20 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"multifd_zstd_level" , -"a value between 0 and 20" ); +error_setg (errp,"Parameter 'multifd_zstd_level' expects" +" a value between 0 and 20" );return false; }if (params->has_xbzrle_cache_size && (params->xbzrle_cache_size <qemu_target_page_size () || !is_power_of_2 (params->xbzrle_cache_size))) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"xbzrle_cache_size" , -"a power of two no less than the target page size" ); +error_setg (errp,"Parameter 'xbzrle_cache_size' expects" +" a power of two no less than the target page size" );return false; }if (params->has_max_cpu_throttle && (params->max_cpu_throttle < params->cpu_throttle_initial || params->max_cpu_throttle >99 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"max_cpu_throttle" , -"an integer in the range of cpu_throttle_initial to 99" ); +error_setg (errp,"Parameter 'max_cpu_throttle' expects" +" an integer in the range of cpu_throttle_initial to 99" );return false; }
migration/options.c bool migrate_params_check(MigrationParameters *params, Error **errp) · line 1105
Quoted 10 lines
migration/options.c +2
-3if (params->has_announce_initial && params->announce_initial >100000 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"announce_initial" , -"a value between 0 and 100000" ); +error_setg (errp,"Parameter 'announce_initial' expects" +" a value between 0 and 100000" );return false; }
Yet another "not your patch's fault": migration.json declares @announce-initial as 'size', even though it's a time. The other @announce-FOO are similarly wrong.
Quoted 46 lines
migration/options.c +8
-12if (params->has_announce_max && params->announce_max >100000 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"announce_max" , -"a value between 0 and 100000" ); +error_setg (errp,"Parameter 'announce_max' expects" +" a value between 0 and 100000" );return false; }if (params->has_announce_rounds && params->announce_rounds >1000 ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"announce_rounds" , -"a value between 0 and 1000" ); +error_setg (errp,"Parameter 'announce_rounds' expects" +" a value between 0 and 1000" );return false; }if (params->has_announce_step && (params->announce_step <1 || params->announce_step >10000 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"announce_step" , -"a value between 0 and 10000" ); +error_setg (errp,"Parameter 'announce_step' expects" +" a value between 0 and 10000" );return false; }@@ -1155,9 +1142,8 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)if (params->has_x_vcpu_dirty_limit_period && (params->x_vcpu_dirty_limit_period <1 || params->x_vcpu_dirty_limit_period >1000 )) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"x-vcpu-dirty-limit-period" , -"a value between 1 and 1000" ); +error_setg (errp,"Parameter 'x-vcpu-dirty-limit-period' expects" +" a value between 1 and 1000" );return false; }migration/page_cache.c +0
-0
migration/page_cache.c PageCache *cache_init(uint64_t new_size, size_t page_size, Error **errp) · line 49
Quoted 5 lines
migration/page_cache.c +0
-2@@ -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" );
The parameter name is obviously wrong: it contains a space.
So let's see where it comes from. Callers:
* qmp_migrate_set_parameters() via migrate_params_apply() and xbzrle_cache_resize()
qmp_migrate_set_parameters() receives its parameters in a MigrationParameters struct, and passes them to migrate_params_apply(). That one passes the value of parameter "xbzrle-cache-size" via xbzrle_cache_resize() to cache_init().
xbzrle_cache_resize() is wrong the same way, visible below.
Correct text for this call chain: "parameter 'xbzrle-cache-size'".
* ram_save_setup() via ram_init_all() via xbzrle_init()
xbzrle_init() passes the value of migrate_xbzrle_cache_size(), which returns value of migration parameter "xbzrle-cache-size".
This seems to run early in migration. Wrong place for basic configuration sanity checking. Redundant with he check above?
Correct text for this call chain: "migration parameter 'xbzrle-cache-size'.
* qemu_plugin_install() via caches_init(), both in contrib/plugins/cache.c
qemu_plugin_install() appears to parse a command line argument. Yet another ad hoc parser. The cache sizes come from dblksize=..., iblksize=..., and l2blksize=...
Correct text for this call chain would use these names.
Yuck!
migration/page_cache.c PageCache *cache_init(uint64_t new_size, size_t page_size, Error **errp) · line 56
Quoted 9 lines
migration/page_cache.c +2
-2+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" );
Likewise.
Quoted 10 lines
migration/page_cache.c +2
-0+error_setg (errp, +"Parameter 'cache size' expects is not a power of two number of pages" );return NULL ; }migration/ram.c +0
-0
migration/ram.c int xbzrle_cache_resize(uint64_t new_size, Error **errp) · line 169
Quoted 5 lines
migration/ram.c +0
-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" );
Same crap, as mentioned above.
Correct text: "parameter 'xbzrle-cache-size'".
Quoted 51 lines
migration/ram.c +2
-0+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 +0
-0
net/filter-buffer.c static void filter_buffer_setup(NetFilterState *nf, Error **errp) · line 125
Quoted 5 lines
net/filter-buffer.c +0
-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" );
Misuse of QERR_INVALID_PARAMETER_VALUE.
This function is interface UserCreatableClass method complete(), which runs right after an object with this interface was created. "Parameters" need not exist in this context.
The error is about the value of property "interval". So let's report
that: "property 'interval' requires a non-zero value".
Quoted 9 lines
net/filter-buffer.c +1
-0+error_setg (errp,"Parameter 'interval' expects a non-zero interval" );return ; }net/filter.c +0
-0
net/filter.c static void netfilter_complete(UserCreatable *uc, Error **errp) · line 236
Quoted 5 lines
net/filter.c +0
-2@@ -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" );
Likewise, property "netdev".
net/filter.c static void netfilter_complete(UserCreatable *uc, Error **errp) · line 255
Quoted 10 lines
net/filter.c +1
-2+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>'" );
Likewise, property "position".
The parsing should be done in the property setternetfilter_set_position() instead.
net/net.c static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
Quoted 21 lines
net/filter.c +2
-0+error_setg (errp, +"Parameter 'position' expects 'head', 'tail' or 'id=<id>'" );return ; }net/net.c +2
-2@@ -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)
prefix_addr = substrings[0];
/* Handle user-specified prefix length. */net/net.c static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) · line 1251
Quoted 5 lines
net/net.c +0
-2if (substrings[1 ] &&qemu_strtoul (substrings[1 ],NULL ,10 , &prefix_len)) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"ipv6-prefixlen" ,"a number" );
Wrong. We're still checking parameter "ipv6-net". The part after '/'.
Quoted 18 lines
net/net.c +2
-1+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 +0
-0
qga/commands-win32.c void qmp_guest_shutdown(const char *mode, Error **errp) · line 332
Quoted 5 lines
qga/commands-win32.c +0
-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'" );
Correct, but the parameter should be an enum, and then we wouldn't neet this.
Quoted 48 lines
qga/commands-win32.c +2
-0+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 +0
-0
softmmu/balloon.c void qmp_balloon(int64_t target, Error **errp) · line 100
Quoted 4 lines
softmmu/balloon.c +0
-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" );
Wrong. The parameter is named "value" in the schema.
Quoted 80 lines
softmmu/balloon.c +1
-0+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 ;
PATCH v2 12/22 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 v2 13/22 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
PATCH v2 14/22 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 v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition
Quoted 45 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:
$ 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]>Reviewed-by Juan Quintela <[email protected]>--- 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 +0
-0
block/vmdk.c vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, · line 2249
Quoted 4 lines
block/vmdk.c +0
-1@@ -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 );
As far as I can tell, blk_co_pwrite() returns a negative errno code. Which we throw away, and claim "IO error". I expect that to be misleading at least sometimes.
I suspect the other uses of QERR_IO_ERROR are similarly problematic more often than not.
Not your patch's problem, of course.
block/vmdk.c vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, · line 2249
Quoted 1 line
block/vmdk.c +1
-0+error_setg (errp,"An IO error has occurred" );
We should spell it "I/O", unless we're reporting trouble with Jupiter's moon.
Quoted 9 lines
block/vmdk.c +1
-1goto 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; }
[...]
PATCH v2 15/22 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
PATCH v2 16/22 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 v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
Quoted 76 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);Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Stefan Berger <[email protected]>--- 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 +0
-0
backends/dbus-vmstate.c dbus_vmstate_complete(UserCreatable *uc, Error **errp) · line 416
Quoted 4 lines
backends/dbus-vmstate.c +0
-1@@ -413,7 +413,7 @@ dbus_vmstate_complete(UserCreatable *uc, Error **errp) }if (!self->dbus_addr) { -error_setg (errp,QERR_MISSING_PARAMETER ,"addr" );
Misuse of QERR_MISSING_PARAMETER.
This function is interface UserCreatableClass method complete(), which runs right after an object with this interface was created. "Parameters" need not exist in this context.
The actual issue is property "addr" has not been set. So let's report
that: "property 'addr' is required".
Separate patch, to keep this one mechanical.
Quoted 64 lines
backends/dbus-vmstate.c +1
-0+error_setg (errp,"Parameter 'addr' is missing" );return ; }block/gluster.c +9
-8@@ -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; }
block/gluster.c static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, · line 656
Quoted 10 lines
block/gluster.c +2
-2@@ -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; }
I suspect pretty much everything you patch in this file is bad, but I'm running out of steam.
Quoted 54 lines
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 +0
-0
hw/usb/redirect.c static void usbredir_realize(USBDevice *udev, Error **errp) · line 1429
Quoted 4 lines
hw/usb/redirect.c +0
-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" );
Misuse of QERR_MISSING_PARAMETER.
This is a realize() method. "Parameters" need not exist in this context.
The actual issue is property "chardev" has not been set. So let's report that: "property 'filename' is required".
Separate patch, to keep this one mechanical. Not mentioning this again from now on.
Quoted 64 lines
hw/usb/redirect.c +1
-0+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 +0
-0
ui/input-barrier.c static void input_barrier_complete(UserCreatable *uc, Error **errp) · line 496
Quoted 4 lines
ui/input-barrier.c +0
-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" );
Misuse of QERR_MISSING_PARAMETER.
This function is interface UserCreatableClass method complete(), which runs right after an object with this interface was created. "Parameters" need not exist in this context.
The actual issue is property "name" has not been set. So let's report
that: "property 'name' is required".
ui/ui-qmp-cmds.c void qmp_client_migrate_info(const char *protocol, const char *hostname, · line 198
Quoted 13 lines
ui/input-barrier.c +1
-0+error_setg (errp,"Parameter 'name' is missing" );return ; }ui/ui-qmp-cmds.c +0
-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" );
Bad error message. The actual issue is both "port" and "tls-port" are missing, but we need at least one. So let's report that: "parameter 'port' or 'tls-port' is required".
Quoted 3 lines
ui/ui-qmp-cmds.c +1
-0+error_setg (errp,"Parameter 'port/tls-port' is missing" );return ; }
PATCH v2 17/22 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 v2 18/22 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
Re: [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition
Quoted 50 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!
*/Manual change. Remove the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
target/i386/cpu.c static void x86_cpuid_set_vendor(Object *obj, const char *value, · line 5193
Quoted 4 lines
target/i386/cpu.c +0
-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);
Reporting the actual problem would be better: we need the value to be exactly CPUID_VENDOR_SZ characters long.
Quoted 3 lines
target/i386/cpu.c +1
-0+error_setg (errp,"Property 'vendor' doesn't take value '%s'" , value);return ; }
PATCH v2 19/22 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
Re: [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition
Quoted 96 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 sed, manually removing the definition in
include/qapi/qmp/qerror.h.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
util/block-helpers.c void check_block_size(const char *id, const char *name, int64_t value, · line 33
Quoted 4 lines
util/block-helpers.c +0
-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,
Three callers:
* set_blocksize()
Property setter. Good.
* vu_blk_exp_create() and vduse_blk_exp_create()
These check QMP arguments, i.e. *not* porperties. Misuse of QERR_PROPERTY_VALUE_OUT_OF_RANGE.
Quoted 5 lines
util/block-helpers.c +2
-0+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 ; }
PATCH v2 20/22 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
Re: [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition
Quoted 61 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 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.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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 +0
-0
qga/commands-win32.c int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp) · line 249
Quoted 6 lines
qga/commands-win32.c +2
-1@@ -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'" );
Oopsie :)
Two more below.
Quoted 4 lines
qga/commands-win32.c +0
-0g_error_free (gerr); }g_free (w_path);
qga/commands-win32.c static void acquire_privilege(const char *name, Error **errp) · line 287
Quoted 10 lines
qga/commands-win32.c +2
-2@@ -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; }
I don't like this error message. I'm going to pretend I didn't see it.
[...]
RFC PATCH v2 21/22 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
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
qga/qapi-schema.json
Quoted 32 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:
$ 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.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC: Not sure what is the best way to change the comment
inqga/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 +0
-0@@ -6,8 +6,9 @@
##
# = General note concerning the use of guest agent interfaces
qga/qapi-schema.json line 14
Quoted 11 lines
qga/qapi-schema.json +3
-2# # "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. ## ##
The comment is problematic before the patch. It's a doc comment, i.e. it goes into the "QEMU Guest Agent Protocol Reference" manual, where QERR_UNSUPPORTED is meaningless. Back when the comment was added (commit 9481ecd737b "qga schema: document generic QERR_UNSUPPORTED"), it was still internal documentation, where QERR_UNSUPPORTED made sense. It became external documentation four years later (commit 56e8bdd46a8 "build-sys: add qapi doc generation targets")
I'm not sure how useful the comment is.
I guess we could instead simply point out that clients should always be prepared for errors, even when the command doesn't document any, simply because commands need not exist in all versions or builds of qemu-ga.
Quoted 35 lines
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 +2
-3@@ -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 );
qga/commands-bsd.c int qmp_guest_fsfreeze_do_thaw(Error **errp) · line 175
Quoted 10 lines
qga/commands-bsd.c +2
-1+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 ; }
These are all commands that are not supported by this build of qemu-ga. We could use the opportunity to improve the error message: scratch "feature or ". Or maybe change the message to "this command is not supported in this version of qemu-ga".
More of the same below, marked [*].
Taking a step back... Do we really need to make this a failure of its own? Why not fail exactly as if the command didn't exist? Why would a client ever care for the difference between "command doesn't exist in this build of qemu-ga (but it does in other builds of this version of qemu-ga)" and "command doesn't exist in this build of qemu-ga (and it won't in any build of this version of qemu-ga)"?
If clients don't care, we could instead unregister these commands, i.e. undo qmp_register_command(). The command will then fail exactly like any other unknown command. We still need to provide the functions to make the linker happy (unless we play with weak symbols), but they can simply abort().
Michael and/or Konstantin, do you have comments as maintainers? A preference even?
Hmm, there's yet another mechanism to disable commands:qmp_disable_command() & friends. Looks like its purpose is letting guest system administrators disable commands, and also to disable a bunch of commands in "frozen state", whatever that is. Alright, I didn't see that, lalala.
Quoted 6 lines
qga/commands-bsd.c +0
-0#endif /* CONFIG_FSFREEZE */ qga/commands-posix.c +0
-0
qga/commands-posix.c void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) · line 171
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -165,7 +165,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) }if (!hwclock_available) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return ; }
!hwclock_available means /sbin/hwclock grants execute permission for the process's real UID and GID. I'm not sure why we bother to check that. Why not let execl() fail, and report that error? Oh, we don't:
/* Use '/sbin/hwclock -w' to set RTC from the system time,
* or '/sbin/hwclock -s' to set the system time from RTC. */
execl(hwclock_path, "hwclock", has_time ? "-w" : "-s", NULL);
_exit(EXIT_FAILURE);This is wrong. We should error_setg_errno(errp, errno, ...); return instead. Not your patch's problem.
Until we do that: [*]
qga/commands-posix.c GuestDiskInfoList *qmp_guest_get_disks(Error **errp) · line 1545
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -1540,7 +1540,7 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)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 ; }
Command not supported by this build of qemu-qa: [*].
Quoted 157 lines
qga/commands-posix.c +20
-20@@ -2235,7 +2235,7 @@ void qmp_guest_set_user_password(const char *username, bool crypted, Error **errp) { -error_setg (errp ,QERR_UNSUPPORTED ); + error_setg(errp, "this feature or command is not currently supported"); }#endif /* __linux__ || __FreeBSD__ */ @@ -2751,47 +2751,47 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)void qmp_guest_suspend_disk (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_ram (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_hybrid (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }GuestLogicalProcessorList *qmp_guest_get_vcpus (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }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 ; }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 ; }@@ -3056,7 +3056,7 @@ error:GuestNetworkInterfaceList *qmp_guest_network_get_interfaces (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }@@ -3066,20 +3066,20 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(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 ; }GuestFsfreezeStatus qmp_guest_fsfreeze_status (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_freeze (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }@@ -3088,33 +3088,33 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints, strList *mountpoints, Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_thaw (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }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 ; }@@ -3124,7 +3124,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)GuestFilesystemTrimResponse *qmp_guest_fstrim (bool has_minimum,int64_t minimum,Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }#endif @@ -3243,7 +3243,7 @@ GuestUserList *qmp_guest_get_users(Error **errp)GuestUserList *qmp_guest_get_users (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
qga/commands-posix.c GuestOSInfo *qmp_guest_get_osinfo(Error **errp) · line 3392
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -3386,7 +3386,7 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)GuestDeviceInfoList *qmp_guest_get_devices (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
Commands not supported by this build of qemu-qa: [*].
Quoted 23 lines
qga/commands-win32.c +2
-2@@ -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 ; }
qga/commands-win32.c int64_t qmp_guest_fsfreeze_thaw(Error **errp) · line 1282
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }
!vss_initialized() means qga-vss.dll failed to load and initialize.
Another [*].
Quoted 10 lines
qga/commands-win32.c +1
-1@@ -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)
qga/commands-win32.c GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) · line 1883
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }
Commands not supported by this build of qemu-qa: [*].
qga/commands-win32.c void qmp_guest_set_user_password(const char *username, · line 1943
Quoted 8 lines
qga/commands-win32.c +1
-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 ; }
Command does not support "crypted": true in this build of qemu-ga. The error message is crap. Better would be some variation of "this machine supports only clear-text passwords".
Quoted 30 lines
qga/commands-win32.c +3
-4@@ -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 );
qga/commands-win32.c char *qga_get_host_name(Error **errp) · line 2533
Quoted 10 lines
qga/commands-win32.c +2
-1+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 ; }
Commands not supported by this build of qemu-qa: [*].
Summary of my review:
* You're unsure about your change to the "General note concerning the use of guest agent interfaces". I suggested a way to rewrite it.
* Error messages could use improvement. Since your patch doesn't change any, feel free to leave that for another day.
* How we do compiled-out commands could use improvement. Feel even more free to leave for another day. I'd like to hear the maintainers' opinion, though.
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
Please ignore this copy, it has the recipients messed up.
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
In reply to Markus ArmbrusterMichael, Konstantin, QERR_UNSUPPORTED is only used by QGA.
Do you mind giving our maintainer's position on Markus analysis so we can know how to proceed with this definition?
Regards,
Phil.
Quoted 471 lines · Markus Armbruster
qga/qapi-schema.json
Quoted 32 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:
$ 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.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC: Not sure what is the best way to change the comment
inqga/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 +0
-0@@ -6,8 +6,9 @@##
# = General note concerning the use of guest agent interfacesqga/qapi-schema.json line 14
Quoted 11 lines
qga/qapi-schema.json +3
-2# # "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. ## ##The comment is problematic before the patch. It's a doc comment, i.e. it goes into the "QEMU Guest Agent Protocol Reference" manual, where
QERR_UNSUPPORTEDis meaningless. Back when the comment was added (commit9481ecd737b"qga schema: document genericQERR_UNSUPPORTED"), it was still internal documentation, whereQERR_UNSUPPORTEDmade sense. It became external documentation four years later (commit56e8bdd46a8"build-sys: add qapi doc generation targets")I'm not sure how useful the comment is.
I guess we could instead simply point out that clients should always be prepared for errors, even when the command doesn't document any, simply because commands need not exist in all versions or builds of qemu-ga.
Quoted 35 lines
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 +2
-3@@ -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 );qga/commands-bsd.c int qmp_guest_fsfreeze_do_thaw(Error **errp) · line 175
Quoted 10 lines
qga/commands-bsd.c +2
-1+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 ; }These are all commands that are not supported by this build of qemu-ga. We could use the opportunity to improve the error message: scratch "feature or ". Or maybe change the message to "this command is not supported in this version of qemu-ga".
More of the same below, marked [*].
Taking a step back... Do we really need to make this a failure of its own? Why not fail exactly as if the command didn't exist? Why would a client ever care for the difference between "command doesn't exist in this build of qemu-ga (but it does in other builds of this version of qemu-ga)" and "command doesn't exist in this build of qemu-ga (and it won't in any build of this version of qemu-ga)"?
If clients don't care, we could instead unregister these commands, i.e. undo
qmp_register_command(). The command will then fail exactly like any other unknown command. We still need to provide the functions to make the linker happy (unless we play with weak symbols), but they can simplyabort().Michael and/or Konstantin, do you have comments as maintainers? A preference even?
Hmm, there's yet another mechanism to disable commands:
qmp_disable_command()& friends. Looks like its purpose is letting guest system administrators disable commands, and also to disable a bunch of commands in "frozen state", whatever that is. Alright, I didn't see that, lalala.Quoted 6 lines
qga/commands-bsd.c +0
-0#endif /* CONFIG_FSFREEZE */ qga/commands-posix.c +0
-0qga/commands-posix.c void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) · line 171
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -165,7 +165,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) }if (!hwclock_available) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return ; }!hwclock_available means
/sbin/hwclockgrants execute permission for the process's real UID and GID. I'm not sure why we bother to check that. Why not letexecl()fail, and report that error? Oh, we don't:/* Use '/sbin/hwclock -w' to set RTC from the system time, * or '/sbin/hwclock -s' to set the system time from RTC. */ execl(hwclock_path, "hwclock", has_time ? "-w" : "-s", NULL); _exit(EXIT_FAILURE);This is wrong. We should
error_setg_errno(errp, errno, ...); return instead. Not your patch's problem.Until we do that: [*]
qga/commands-posix.c GuestDiskInfoList *qmp_guest_get_disks(Error **errp) · line 1545
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -1540,7 +1540,7 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)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 ; }Command not supported by this build of qemu-qa: [*].
Quoted 157 lines
qga/commands-posix.c +20
-20@@ -2235,7 +2235,7 @@ void qmp_guest_set_user_password(const char *username, bool crypted, Error **errp) { -error_setg (errp ,QERR_UNSUPPORTED ); + error_setg(errp, "this feature or command is not currently supported"); }#endif /* __linux__ || __FreeBSD__ */ @@ -2751,47 +2751,47 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)void qmp_guest_suspend_disk (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_ram (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_hybrid (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }GuestLogicalProcessorList *qmp_guest_get_vcpus (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }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 ; }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 ; }@@ -3056,7 +3056,7 @@ error:GuestNetworkInterfaceList *qmp_guest_network_get_interfaces (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }@@ -3066,20 +3066,20 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(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 ; }GuestFsfreezeStatus qmp_guest_fsfreeze_status (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_freeze (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }@@ -3088,33 +3088,33 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints, strList *mountpoints, Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_thaw (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }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 ; }@@ -3124,7 +3124,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)GuestFilesystemTrimResponse *qmp_guest_fstrim (bool has_minimum,int64_t minimum,Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }#endif @@ -3243,7 +3243,7 @@ GuestUserList *qmp_guest_get_users(Error **errp)GuestUserList *qmp_guest_get_users (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }qga/commands-posix.c GuestOSInfo *qmp_guest_get_osinfo(Error **errp) · line 3392
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -3386,7 +3386,7 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)GuestDeviceInfoList *qmp_guest_get_devices (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }Commands not supported by this build of qemu-qa: [*].
Quoted 23 lines
qga/commands-win32.c +2
-2@@ -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 ; }qga/commands-win32.c int64_t qmp_guest_fsfreeze_thaw(Error **errp) · line 1282
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }!vss_initialized() means qga-vss.dll failed to load and initialize.
Another [*].
Quoted 10 lines
qga/commands-win32.c +1
-1@@ -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)qga/commands-win32.c GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) · line 1883
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }Commands not supported by this build of qemu-qa: [*].
qga/commands-win32.c void qmp_guest_set_user_password(const char *username, · line 1943
Quoted 8 lines
qga/commands-win32.c +1
-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 ; }Command does not support "crypted": true in this build of qemu-ga. The error message is crap. Better would be some variation of "this machine supports only clear-text passwords".
Quoted 30 lines
qga/commands-win32.c +3
-4@@ -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 );qga/commands-win32.c char *qga_get_host_name(Error **errp) · line 2533
Quoted 10 lines
qga/commands-win32.c +2
-1+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 ; }Commands not supported by this build of qemu-qa: [*].
Summary of my review:
* You're unsure about your change to the "General note concerning the use of guest agent interfaces". I suggested a way to rewrite it.
* Error messages could use improvement. Since your patch doesn't change any, feel free to leave that for another day.
* How we do compiled-out commands could use improvement. Feel even more free to leave for another day. I'd like to hear the maintainers' opinion, though.
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
Quoted 4 lines · Philippe Mathieu-Daudé
Michael, Konstantin,
QERR_UNSUPPORTEDis only used by QGA.Do you mind giving our maintainer's position on Markus analysis so we can know how to proceed with this definition?
Daniel Berrangé recently posted patches that get rid of most instances of QERR_UNSUPPORTED:
[PATCH 00/20] qga: clean up command source locations and conditionals
https://lore.kernel.org/qemu-devel/[email protected]/
I pointed out a possible opportunity to remove even more.
I think we should let the dust settle there, then figure out how to eliminate remaining QERR_UNSUPPORTED, if any.
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
Hi Markus and Philippe,
I agree to remove QERR_UNSUPPORTED and have more specific errors or even remove the functions from the schema in some cases instead of copy-paste QERR_UNSUPPORTED from platform to platform.
Best Regards,
Konstantin Kostiuk.
Quoted 20 lines · Markus Armbruster
Quoted 4 lines · Philippe Mathieu-Daudé
Michael, Konstantin,
QERR_UNSUPPORTEDis only used by QGA.Do you mind giving our maintainer's position on Markus analysis so we can know how to proceed with this definition?
Daniel Berrangé recently posted patches that get rid of most instances of
QERR_UNSUPPORTED:[PATCH 00/20] qga: clean up command source locations and conditionals
https://lore.kernel.org/qemu-devel/[email protected]/
I pointed out a possible opportunity to remove even more.
I think we should let the dust settle there, then figure out how to eliminate remaining
QERR_UNSUPPORTED, if any.
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
In reply to Markus ArmbrusterQuoted 10 lines · Markus Armbruster
Quoted 4 lines · Philippe Mathieu-Daudé
Michael, Konstantin,
QERR_UNSUPPORTEDis only used by QGA.Do you mind giving our maintainer's position on Markus analysis so we can know how to proceed with this definition?
Daniel Berrangé recently posted patches that get rid of most instances of
QERR_UNSUPPORTED:
Quoted 7 lines
[PATCH 00/20] qga: clean up command source locations and conditionals
https://lore.kernel.org/qemu-devel/[email protected]/I pointed out a possible opportunity to remove even more.
I think we should let the dust settle there, then figure out how to eliminate remaining
QERR_UNSUPPORTED, if any.
Ah great, thanks for the update :)
Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
In reply to Philippe Mathieu-Daudéqga/qapi-schema.json
Quoted 32 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:
$ 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.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC: Not sure what is the best way to change the comment
inqga/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 +0
-0@@ -6,8 +6,9 @@
##
# = General note concerning the use of guest agent interfaces
qga/qapi-schema.json line 14
Quoted 11 lines
qga/qapi-schema.json +3
-2# # "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. ## ##
The comment is problematic before the patch. It's a doc comment, i.e. it goes into the "QEMU Guest Agent Protocol Reference" manual, where QERR_UNSUPPORTED is meaningless. Back when the comment was added (commit 9481ecd737b "qga schema: document generic QERR_UNSUPPORTED"), it was still internal documentation, where QERR_UNSUPPORTED made sense. It became external documentation four years later (commit 56e8bdd46a8 "build-sys: add qapi doc generation targets")
I'm not sure how useful the comment is.
I guess we could instead simply point out that clients should always be prepared for errors, even when the command doesn't document any, simply because commands need not exist in all versions or builds of qemu-ga.
Quoted 35 lines
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 +2
-3@@ -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 );
qga/commands-bsd.c int qmp_guest_fsfreeze_do_thaw(Error **errp) · line 175
Quoted 10 lines
qga/commands-bsd.c +2
-1+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 ; }
These are all commands that are not supported by this build of qemu-ga. We could use the opportunity to improve the error message: scratch "feature or ". Or maybe change the message to "this command is not supported in this version of qemu-ga".
More of the same below, marked [*].
Taking a step back... Do we really need to make this a failure of its own? Why not fail exactly as if the command didn't exist? Why would a client ever care for the difference between "command doesn't exist in this build of qemu-ga (but it does in other builds of this version of qemu-ga)" and "command doesn't exist in this build of qemu-ga (and it won't in any build of this version of qemu-ga)"?
If clients don't care, we could instead unregister these commands, i.e. undo qmp_register_command(). The command will then fail exactly like any other unknown command. We still need to provide the functions to make the linker happy (unless we play with weak symbols), but they can simply abort().
Michael and/or Konstantin, do you have comments as maintainers? A preference even?
Hmm, there's yet another mechanism to disable commands:qmp_disable_command() & friends. Looks like its purpose is letting guest system administrators disable commands, and also to disable a bunch of commands in "frozen state", whatever that is. Alright, I didn't see that, lalala.
Quoted 6 lines
qga/commands-bsd.c +0
-0#endif /* CONFIG_FSFREEZE */ qga/commands-posix.c +0
-0
qga/commands-posix.c void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) · line 171
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -165,7 +165,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) }if (!hwclock_available) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return ; }
!hwclock_available means /sbin/hwclock grants execute permission for the process's real UID and GID. I'm not sure why we bother to check that. Why not let execl() fail, and report that error? Oh, we don't:
/* Use '/sbin/hwclock -w' to set RTC from the system time,
* or '/sbin/hwclock -s' to set the system time from RTC. */
execl(hwclock_path, "hwclock", has_time ? "-w" : "-s", NULL);
_exit(EXIT_FAILURE);This is wrong. We should error_setg_errno(errp, errno, ...); return instead. Not your patch's problem.
Until we do that: [*]
qga/commands-posix.c GuestDiskInfoList *qmp_guest_get_disks(Error **errp) · line 1545
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -1540,7 +1540,7 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)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 ; }
Command not supported by this build of qemu-qa: [*].
Quoted 157 lines
qga/commands-posix.c +20
-20@@ -2235,7 +2235,7 @@ void qmp_guest_set_user_password(const char *username, bool crypted, Error **errp) { -error_setg (errp ,QERR_UNSUPPORTED ); + error_setg(errp, "this feature or command is not currently supported"); }#endif /* __linux__ || __FreeBSD__ */ @@ -2751,47 +2751,47 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)void qmp_guest_suspend_disk (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_ram (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }void qmp_guest_suspend_hybrid (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" ); }GuestLogicalProcessorList *qmp_guest_get_vcpus (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }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 ; }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 ; }@@ -3056,7 +3056,7 @@ error:GuestNetworkInterfaceList *qmp_guest_network_get_interfaces (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }@@ -3066,20 +3066,20 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(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 ; }GuestFsfreezeStatus qmp_guest_fsfreeze_status (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_freeze (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }@@ -3088,33 +3088,33 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints, strList *mountpoints, Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }int64_t qmp_guest_fsfreeze_thaw (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return 0 ; }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 ; }@@ -3124,7 +3124,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)GuestFilesystemTrimResponse *qmp_guest_fstrim (bool has_minimum,int64_t minimum,Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }#endif @@ -3243,7 +3243,7 @@ GuestUserList *qmp_guest_get_users(Error **errp)GuestUserList *qmp_guest_get_users (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
qga/commands-posix.c GuestOSInfo *qmp_guest_get_osinfo(Error **errp) · line 3392
Quoted 8 lines
qga/commands-posix.c +1
-1@@ -3386,7 +3386,7 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)GuestDeviceInfoList *qmp_guest_get_devices (Error **errp) { -error_setg (errp,QERR_UNSUPPORTED ); +error_setg (errp,"this feature or command is not currently supported" );return NULL ; }
Commands not supported by this build of qemu-qa: [*].
Quoted 23 lines
qga/commands-win32.c +2
-2@@ -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 ; }
qga/commands-win32.c int64_t qmp_guest_fsfreeze_thaw(Error **errp) · line 1282
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }
!vss_initialized() means qga-vss.dll failed to load and initialize.
Another [*].
Quoted 10 lines
qga/commands-win32.c +1
-1@@ -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)
qga/commands-win32.c GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) · line 1883
Quoted 8 lines
qga/commands-win32.c +1
-1@@ -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 ; }
Commands not supported by this build of qemu-qa: [*].
qga/commands-win32.c void qmp_guest_set_user_password(const char *username, · line 1943
Quoted 8 lines
qga/commands-win32.c +1
-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 ; }
Command does not support "crypted": true in this build of qemu-ga. The error message is crap. Better would be some variation of "this machine supports only clear-text passwords".
Quoted 30 lines
qga/commands-win32.c +3
-4@@ -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 );
qga/commands-win32.c char *qga_get_host_name(Error **errp) · line 2533
Quoted 10 lines
qga/commands-win32.c +2
-1+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 ; }
Commands not supported by this build of qemu-qa: [*].
Summary of my review:
* You're unsure about your change to the "General note concerning the use of guest agent interfaces". I suggested a way to rewrite it.
* Error messages could use improvement. Since your patch doesn't change any, feel free to leave that for another day.
* How we do compiled-out commands could use improvement. Feel even more free to leave for another day. I'd like to hear the maintainers' opinion, though.
PATCH v2 22/22 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
$ git rm include/qapi/qmp/qerror.h--- 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
Quoted 14 lines · Philippe Mathieu-Daudé
Since v1:
- Fixed checkpatch warnings (Juan)
- Added R-b tags
- New patch for 'vcpu_dirty_limit'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!
*/
Quoted 3 lines
Besides, these definitions are still added in recent code (see for example commit
09f9ec9913from June 2023). So let's finish with this 8 years old technical debt.
Gee, a late birthday present for me! Thank you!
Quoted 5 lines
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.
By the time you're done, it'll likely be 6h or more...
Your patches are sane, the problem is they made me look at the code they patch, much of which is not fine. Let's chat off list to figure out how to best get your patches merged.