* [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 5:55 ` Cédric Le Goater
2023-10-20 5:49 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition Philippe Mathieu-Daudé
` (22 subsequent siblings)
23 siblings, 2 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Nicholas Piggin,
Daniel Henrique Barboza, Cédric Le Goater, David Gibson,
Harsh Prateek Bora, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
hw/ppc/spapr_pci.c | 4 ++--
softmmu/qdev-monitor.c | 8 +++++---
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 8dd9fcb071..1a9c2d3502 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 370c5a90f2..7f063f5852 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -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;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 74f4e41338..3a9740dcbd 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
2023-10-05 4:50 ` [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition Philippe Mathieu-Daudé
@ 2023-10-05 5:55 ` Cédric Le Goater
2023-10-20 5:49 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Cédric Le Goater @ 2023-10-05 5:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x, Nicholas Piggin,
Daniel Henrique Barboza, David Gibson, Harsh Prateek Bora,
Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost
On 10/5/23 06:50, Philippe Mathieu-Daudé wrote:
> 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é <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> include/qapi/qmp/qerror.h | 3 ---
> hw/ppc/spapr_pci.c | 4 ++--
> softmmu/qdev-monitor.c | 8 +++++---
> 3 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 8dd9fcb071..1a9c2d3502 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 370c5a90f2..7f063f5852 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -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;
> }
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 74f4e41338..3a9740dcbd 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -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;
> }
>
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition
2023-10-05 4:50 ` [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition Philippe Mathieu-Daudé
2023-10-05 5:55 ` Cédric Le Goater
@ 2023-10-20 5:49 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 5:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Nicholas Piggin, Daniel Henrique Barboza, Cédric Le Goater,
David Gibson, Harsh Prateek Bora, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> include/qapi/qmp/qerror.h | 3 ---
> hw/ppc/spapr_pci.c | 4 ++--
> softmmu/qdev-monitor.c | 8 +++++---
> 3 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 8dd9fcb071..1a9c2d3502 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 370c5a90f2..7f063f5852 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -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?
> 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",
Likewise.
> object_get_typename(OBJECT(phb)));
> return;
> }
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 74f4e41338..3a9740dcbd 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -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;
> }
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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 6:00 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 03/22] qapi: Inline and remove QERR_DEVICE_IN_USE definition Philippe Mathieu-Daudé
` (21 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Kevin Wolf, Hanna Reitz
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
block/snapshot.c | 4 ++--
blockdev.c | 2 +-
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 1a9c2d3502..168177bcd7 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/block/snapshot.c b/block/snapshot.c
index b86b5b24ad..eb43e957e1 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -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) {
diff --git a/blockdev.c b/blockdev.c
index 325b7a3bef..e5617faf0f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition
2023-10-05 4:50 ` [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition Philippe Mathieu-Daudé
@ 2023-10-20 6:00 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 6:00 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Kevin Wolf, Hanna Reitz
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> include/qapi/qmp/qerror.h | 3 ---
> block/snapshot.c | 4 ++--
> blockdev.c | 2 +-
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 1a9c2d3502..168177bcd7 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/block/snapshot.c b/block/snapshot.c
> index b86b5b24ad..eb43e957e1 100644
> --- a/block/snapshot.c
> +++ b/block/snapshot.c
> @@ -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.
> 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));
Likewise.
> return -ENOMEDIUM;
> }
> if (!snapshot_id && !name) {
> diff --git a/blockdev.c b/blockdev.c
> index 325b7a3bef..e5617faf0f 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -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?
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 03/22] qapi: Inline and remove QERR_DEVICE_IN_USE definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 01/22] qapi: Inline and remove QERR_BUS_NO_HOTPLUG definition Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 02/22] qapi: Inline and remove QERR_DEVICE_HAS_NO_MEDIUM definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition Philippe Mathieu-Daudé
` (20 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Kevin Wolf, Hanna Reitz,
Marc-André Lureau, Paolo Bonzini
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
blockdev.c | 2 +-
chardev/char-fe.c | 2 +-
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 168177bcd7..daa889809b 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/blockdev.c b/blockdev.c
index e5617faf0f..da39da457e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
}
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7789f7be9c..7d33b3ccd1 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 03/22] qapi: Inline and remove QERR_DEVICE_IN_USE definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 6:03 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
` (19 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
hw/core/qdev.c | 3 ++-
softmmu/qdev-monitor.c | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index daa889809b..e93211085a 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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'"
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 43d863b0c5..9b62e0573d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -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;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 3a9740dcbd..a964bd80df 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition
2023-10-05 4:50 ` [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition Philippe Mathieu-Daudé
@ 2023-10-20 6:03 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 6:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> include/qapi/qmp/qerror.h | 3 ---
> hw/core/qdev.c | 3 ++-
> softmmu/qdev-monitor.c | 2 +-
> 3 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index daa889809b..e93211085a 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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'"
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 43d863b0c5..9b62e0573d 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -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;
> }
>
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 3a9740dcbd..a964bd80df 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 04/22] qapi: Inline and remove QERR_DEVICE_NO_HOTPLUG definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 7:07 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition Philippe Mathieu-Daudé
` (18 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Marc-André Lureau, Michael Roth,
Konstantin Kostiuk, Gerd Hoffmann
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é <philmd@linaro.org>
---
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(-)
diff --git a/dump/dump.c b/dump/dump.c
index d4ef713cd0..e173f1f14c 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -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;
}
diff --git a/qga/commands.c b/qga/commands.c
index 09c683e263..871210ab0b 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -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;
}
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index debc07d678..41ca0100e7 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -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;
}
/*
diff --git a/util/qemu-option.c b/util/qemu-option.c
index eedd08929b..fb391a7904 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter)
2023-10-05 4:50 ` [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
@ 2023-10-20 7:07 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 7:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Marc-André Lureau, Michael Roth, Konstantin Kostiuk,
Gerd Hoffmann
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index d4ef713cd0..e173f1f14c 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -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");
> + 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.
> 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 !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;
}
> }
>
> 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.
> + error_setg(errp, "Invalid parameter 'protocol'");
> return;
> }
>
> diff --git a/qga/commands.c b/qga/commands.c
> index 09c683e263..871210ab0b 100644
> --- a/qga/commands.c
> +++ b/qga/commands.c
> @@ -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.
> + error_setg(errp, "Invalid parameter 'pid'");
> return NULL;
> }
>
> diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
> index debc07d678..41ca0100e7 100644
> --- a/ui/ui-qmp-cmds.c
> +++ b/ui/ui-qmp-cmds.c
> @@ -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.
> + error_setg(errp, "Invalid parameter 'connected'");
> return;
> }
> /*
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index eedd08929b..fb391a7904 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -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.
> + 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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 05/22] qapi: Inline QERR_INVALID_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 7:16 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param) Philippe Mathieu-Daudé
` (17 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Michael Roth
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é <philmd@linaro.org>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index e93211085a..63ab775dc5 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 6c559b48c8..9d6533643d 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -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);
}
}
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 8f1efab8b9..3d1a28b419 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -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;
diff --git a/util/qemu-option.c b/util/qemu-option.c
index fb391a7904..201f7a87f3 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition
2023-10-05 4:50 ` [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition Philippe Mathieu-Daudé
@ 2023-10-20 7:16 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 7:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Dr. David Alan Gilbert, Michael Roth
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index e93211085a..63ab775dc5 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 6c559b48c8..9d6533643d 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -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();
> } 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.
> + error_setg(&err, "Invalid parameter '%s'", op);
> hmp_handle_error(mon, err);
> }
> }
> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
> index 8f1efab8b9..3d1a28b419 100644
> --- a/qapi/opts-visitor.c
> +++ b/qapi/opts-visitor.c
> @@ -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;
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index fb391a7904..201f7a87f3 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -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;
> }
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 06/22] qapi: Inline and remove QERR_INVALID_PARAMETER definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 7:18 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 08/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) Philippe Mathieu-Daudé
` (16 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Thomas Huth, Peter Maydell,
Richard Henderson, David Hildenbrand, Ilya Leoshkevich
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é <philmd@linaro.org>
Acked-by: Thomas Huth <thuth@redhat.com>
---
target/arm/arm-qmp-cmds.c | 3 ++-
target/s390x/cpu_models_sysemu.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index b53d5efe13..3c99fd8222 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -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;
}
}
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 63981bf36b..4507714493 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -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;
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param)
2023-10-05 4:50 ` [PATCH v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param) Philippe Mathieu-Daudé
@ 2023-10-20 7:18 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 7:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Thomas Huth, Peter Maydell, Richard Henderson, David Hildenbrand,
Ilya Leoshkevich
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> Acked-by: Thomas Huth <thuth@redhat.com>
> ---
> target/arm/arm-qmp-cmds.c | 3 ++-
> target/s390x/cpu_models_sysemu.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
> index b53d5efe13..3c99fd8222 100644
> --- a/target/arm/arm-qmp-cmds.c
> +++ b/target/arm/arm-qmp-cmds.c
> @@ -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;
> }
> }
> diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
> index 63981bf36b..4507714493 100644
> --- a/target/s390x/cpu_models_sysemu.c
> +++ b/target/s390x/cpu_models_sysemu.c
> @@ -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 ;)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 08/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 07/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant param) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 09/22] qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition Philippe Mathieu-Daudé
` (15 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Michael Roth, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
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);
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qapi/qobject-input-visitor.c | 32 ++++++++++++++++----------------
qapi/string-input-visitor.c | 8 ++++----
qom/object.c | 12 ++++++++----
3 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 3e8aca6b15..f110a804b2 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -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();
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 197139c1c0..3f1b9e9b41 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -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;
}
diff --git a/qom/object.c b/qom/object.c
index e25f1e96db..890fa0a106 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 09/22] qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 08/22] qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter Philippe Mathieu-Daudé
` (14 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost, Michael Roth
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
qom/object.c | 3 ++-
scripts/qapi/visit.py | 4 ++--
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 63ab775dc5..b723830eff 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/qom/object.c b/qom/object.c
index 890fa0a106..eea61a5068 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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);
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index c56ea4d724..4b4a442383 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 09/22] qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 6:33 ` Juan Quintela
2023-10-20 8:33 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value) Philippe Mathieu-Daudé
` (13 subsequent siblings)
23 siblings, 2 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Juan Quintela, Peter Xu,
Leonardo Bras
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"
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
migration/options.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/migration/options.c b/migration/options.c
index 1d1e1321b0..79fce0c3a9 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
2023-10-05 4:50 ` [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter Philippe Mathieu-Daudé
@ 2023-10-05 6:33 ` Juan Quintela
2023-10-20 8:33 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Juan Quintela @ 2023-10-05 6:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Peter Xu, Leonardo Bras
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 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"
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
2023-10-05 4:50 ` [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter Philippe Mathieu-Daudé
2023-10-05 6:33 ` Juan Quintela
@ 2023-10-20 8:33 ` Markus Armbruster
2023-10-20 9:55 ` Juan Quintela
1 sibling, 1 reply; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 8:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Juan Quintela, Peter Xu, Leonardo Bras
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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"
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> migration/options.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/migration/options.c b/migration/options.c
> index 1d1e1321b0..79fce0c3a9 100644
> --- a/migration/options.c
> +++ b/migration/options.c
> @@ -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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter
2023-10-20 8:33 ` Markus Armbruster
@ 2023-10-20 9:55 ` Juan Quintela
0 siblings, 0 replies; 49+ messages in thread
From: Juan Quintela @ 2023-10-20 9:55 UTC (permalink / raw)
To: Markus Armbruster
Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-arm, qemu-ppc,
qemu-block, qemu-s390x, Peter Xu, Leonardo Bras
Markus Armbruster <armbru@redhat.com> wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> 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"
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> migration/options.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/migration/options.c b/migration/options.c
>> index 1d1e1321b0..79fce0c3a9 100644
>> --- a/migration/options.c
>> +++ b/migration/options.c
>> @@ -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.
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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 10/22] qapi: Correct error message for 'vcpu_dirty_limit' parameter Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 6:34 ` Juan Quintela
2023-10-20 11:32 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 12/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant param) Philippe Mathieu-Daudé
` (12 subsequent siblings)
23 siblings, 2 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Juan Quintela, Gonglei (Arei),
Zhenwei Pi, Laurent Vivier, Amit Shah, Alberto Garcia, Kevin Wolf,
Hanna Reitz, John Snow, Vladimir Sementsov-Ogievskiy,
Marc-André Lureau, Paolo Bonzini, Gerd Hoffmann, Peter Xu,
Leonardo Bras, Jason Wang, Konstantin Kostiuk, Michael Roth,
Daniel P. Berrangé, Eduardo Habkost, Michael S. Tsirkin,
David Hildenbrand, Richard Henderson
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.
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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(-)
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index c3283ba84a..d93ccd5528 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -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;
}
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 684c3cf3d6..8f101afadc 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -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;
}
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 80eb5be138..9cb7d26cb5 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -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) {
diff --git a/block/quorum.c b/block/quorum.c
index 05220cab7f..8e9f279568 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -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;
}
diff --git a/blockdev.c b/blockdev.c
index da39da457e..ed90365329 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
}
diff --git a/blockjob.c b/blockjob.c
index 58c5d64539..f95f73244e 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -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;
}
diff --git a/chardev/char.c b/chardev/char.c
index 996a024c7a..447b4d9d06 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -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;
}
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index c9893df867..ac6fa34ad1 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -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;
}
}
diff --git a/migration/migration.c b/migration/migration.c
index 6d3cf5d5cd..b7f6818a15 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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();
diff --git a/migration/options.c b/migration/options.c
index 79fce0c3a9..4f6c8e810c 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -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;
}
if (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;
}
if (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;
}
diff --git a/migration/page_cache.c b/migration/page_cache.c
index 6d4f7a9bbc..d430ce742b 100644
--- a/migration/page_cache.c
+++ b/migration/page_cache.c
@@ -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;
}
diff --git a/migration/ram.c b/migration/ram.c
index e4bfd39f08..0a4a0d7a0e 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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;
}
diff --git a/monitor/fds.c b/monitor/fds.c
index d86c2c674c..17e9c126e3 100644
--- a/monitor/fds.c
+++ b/monitor/fds.c
@@ -67,8 +67,8 @@ static bool monitor_add_fd(Monitor *mon, int fd, const char *fdname, Error **err
if (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 */
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index b0f948d337..2d2e71b867 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -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;
}
}
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index 283dc9cbe6..071029a6c7 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -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;
}
diff --git a/net/filter.c b/net/filter.c
index 3335908771..1621513bab 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -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;
}
diff --git a/net/net.c b/net/net.c
index 1c0bfdaa6c..5cdbd9c218 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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;
}
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 6beae659b7..946dbafbb6 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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;
}
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d31589b04..be04b2c5ab 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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;
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 7c087299de..3d014f1bea 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -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;
}
diff --git a/softmmu/balloon.c b/softmmu/balloon.c
index e0e8969a4b..d941c6b9c1 100644
--- a/softmmu/balloon.c
+++ b/softmmu/balloon.c
@@ -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;
}
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 0848e0dbdb..7fc70f9166 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index a964bd80df..b17aec4357 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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;
}
}
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index 41ca0100e7..a95fd35948 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -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
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 201f7a87f3..62dd80a5ae 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
2023-10-05 4:50 ` [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value) Philippe Mathieu-Daudé
@ 2023-10-05 6:34 ` Juan Quintela
2023-10-20 11:32 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Juan Quintela @ 2023-10-05 6:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Gonglei (Arei), Zhenwei Pi, Laurent Vivier, Amit Shah,
Alberto Garcia, Kevin Wolf, Hanna Reitz, John Snow,
Vladimir Sementsov-Ogievskiy, Marc-André Lureau,
Paolo Bonzini, Gerd Hoffmann, Peter Xu, Leonardo Bras, Jason Wang,
Konstantin Kostiuk, Michael Roth, Daniel P. Berrangé,
Eduardo Habkost, Michael S. Tsirkin, David Hildenbrand,
Richard Henderson
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 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.
>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value)
2023-10-05 4:50 ` [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value) Philippe Mathieu-Daudé
2023-10-05 6:34 ` Juan Quintela
@ 2023-10-20 11:32 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 11:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Juan Quintela, Gonglei (Arei), Zhenwei Pi, Laurent Vivier,
Amit Shah, Alberto Garcia, Kevin Wolf, Hanna Reitz, John Snow,
Vladimir Sementsov-Ogievskiy, Marc-André Lureau,
Paolo Bonzini, Gerd Hoffmann, Peter Xu, Leonardo Bras, Jason Wang,
Konstantin Kostiuk, Michael Roth, Daniel P. Berrangé,
Eduardo Habkost, Michael S. Tsirkin, David Hildenbrand,
Richard Henderson
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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.
>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
> index c3283ba84a..d93ccd5528 100644
> --- a/backends/cryptodev-vhost-user.c
> +++ b/backends/cryptodev-vhost-user.c
> @@ -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;
> }
>
> diff --git a/backends/rng-egd.c b/backends/rng-egd.c
> index 684c3cf3d6..8f101afadc 100644
> --- a/backends/rng-egd.c
> +++ b/backends/rng-egd.c
> @@ -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;
> }
>
> diff --git a/backends/rng-random.c b/backends/rng-random.c
> index 80eb5be138..9cb7d26cb5 100644
> --- a/backends/rng-random.c
> +++ b/backends/rng-random.c
> @@ -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.
> + 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) {
> diff --git a/block/quorum.c b/block/quorum.c
> index 05220cab7f..8e9f279568 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -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;
> }
>
> diff --git a/blockdev.c b/blockdev.c
> index da39da457e..ed90365329 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -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.
> 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;
> }
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.
>
> diff --git a/blockjob.c b/blockjob.c
> index 58c5d64539..f95f73244e 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -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;
> }
>
> diff --git a/chardev/char.c b/chardev/char.c
> index 996a024c7a..447b4d9d06 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -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;
> }
>
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index c9893df867..ac6fa34ad1 100644
> --- a/hw/usb/redirect.c
> +++ b/hw/usb/redirect.c
> @@ -1435,8 +1435,8 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
i = usbredirfilter_string_to_rules(dev->filter_str, ":", "|",
> &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.
> + error_setg(errp,
> + "Parameter 'filter' expects a usb device filter string");
> return;
> }
> }
> diff --git a/migration/migration.c b/migration/migration.c
> index 6d3cf5d5cd..b7f6818a15 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -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();
> diff --git a/migration/options.c b/migration/options.c
> index 79fce0c3a9..4f6c8e810c 100644
> --- a/migration/options.c
> +++ b/migration/options.c
> @@ -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;
> }
>
> if (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.
> if (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;
> }
>
> diff --git a/migration/page_cache.c b/migration/page_cache.c
> index 6d4f7a9bbc..d430ce742b 100644
> --- a/migration/page_cache.c
> +++ b/migration/page_cache.c
> @@ -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!
> + 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.
> + error_setg(errp,
> + "Parameter 'cache size' expects is not a power of two number of pages");
> return NULL;
> }
>
> diff --git a/migration/ram.c b/migration/ram.c
> index e4bfd39f08..0a4a0d7a0e 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -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'".
> + error_setg(errp,
> + "Parameter 'cache size' expects exceeding address space");
> return -1;
> }
>
> diff --git a/monitor/fds.c b/monitor/fds.c
> index d86c2c674c..17e9c126e3 100644
> --- a/monitor/fds.c
> +++ b/monitor/fds.c
> @@ -67,8 +67,8 @@ static bool monitor_add_fd(Monitor *mon, int fd, const char *fdname, Error **err
>
> if (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 */
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index b0f948d337..2d2e71b867 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -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;
> }
> }
> diff --git a/net/filter-buffer.c b/net/filter-buffer.c
> index 283dc9cbe6..071029a6c7 100644
> --- a/net/filter-buffer.c
> +++ b/net/filter-buffer.c
> @@ -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".
> + error_setg(errp, "Parameter 'interval' expects a non-zero interval");
> return;
> }
>
> diff --git a/net/filter.c b/net/filter.c
> index 3335908771..1621513bab 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -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".
> + 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 setter
netfilter_set_position() instead.
> + error_setg(errp,
> + "Parameter 'position' expects 'head', 'tail' or 'id=<id>'");
> return;
> }
>
> diff --git a/net/net.c b/net/net.c
> index 1c0bfdaa6c..5cdbd9c218 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -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. */
> if (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 '/'.
> + 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;
> }
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 6beae659b7..946dbafbb6 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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.
> + error_setg(errp,
> + "Parameter 'mode' expects 'halt', 'powerdown', or 'reboot'");
> return;
> }
>
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 7d31589b04..be04b2c5ab 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -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;
> diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
> index 7c087299de..3d014f1bea 100644
> --- a/qom/qom-qmp-cmds.c
> +++ b/qom/qom-qmp-cmds.c
> @@ -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;
> }
>
> diff --git a/softmmu/balloon.c b/softmmu/balloon.c
> index e0e8969a4b..d941c6b9c1 100644
> --- a/softmmu/balloon.c
> +++ b/softmmu/balloon.c
> @@ -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.
> + error_setg(errp, "Parameter 'target' expects a size");
> return;
> }
>
> diff --git a/softmmu/cpus.c b/softmmu/cpus.c
> index 0848e0dbdb..7fc70f9166 100644
> --- a/softmmu/cpus.c
> +++ b/softmmu/cpus.c
> @@ -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;
> }
>
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index a964bd80df..b17aec4357 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -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;
> }
> }
> diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
> index 41ca0100e7..a95fd35948 100644
> --- a/ui/ui-qmp-cmds.c
> +++ b/ui/ui-qmp-cmds.c
> @@ -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
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index 201f7a87f3..62dd80a5ae 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -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;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 12/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant param)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 11/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant value) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 13/22] qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition Philippe Mathieu-Daudé
` (11 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost, Michael Roth
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);
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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(-)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 688340610e..7752c5fda5 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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;
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 3d1a28b419..0393704a73 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -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;
}
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
index 63596e11c5..82c3425566 100644
--- a/qapi/qapi-util.c
+++ b/qapi/qapi-util.c
@@ -101,8 +101,7 @@ bool qapi_bool_parse(const char *name, const char *value, bool *obj, Error **err
return true;
}
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
- "'on' or 'off'");
+ error_setg(errp, "Parameter '%s' expects 'on' or 'off'", name);
return false;
}
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index f110a804b2..f5fa6c1878 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -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;
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 3f1b9e9b41..6ea6a0c676 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -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);
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 62dd80a5ae..9440224e5b 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -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");
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 13/22] qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 12/22] qapi: Inline QERR_INVALID_PARAMETER_VALUE definition (constant param) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition Philippe Mathieu-Daudé
` (10 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Stefan Berger, Michael Roth,
Stefan Berger
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index b723830eff..ac727d1c2d 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 0393704a73..844db583f4 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -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;
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 6c13510a2b..01793d6e74 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -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;
}
diff --git a/softmmu/tpm.c b/softmmu/tpm.c
index 578563f05a..8437c4efc3 100644
--- a/softmmu/tpm.c
+++ b/softmmu/tpm.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 13/22] qapi: Inline and remove QERR_INVALID_PARAMETER_VALUE definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 11:50 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 15/22] qapi: Inline and remove QERR_MIGRATION_ACTIVE definition Philippe Mathieu-Daudé
` (9 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Juan Quintela, Fam Zheng, Kevin Wolf,
Hanna Reitz, Marc-André Lureau, Peter Xu, Leonardo Bras,
Paolo Bonzini, Richard Henderson
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é <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index ac727d1c2d..d95c4b84b9 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/block/vmdk.c b/block/vmdk.c
index e90649c8bf..6779a181f0 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -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;
diff --git a/blockdev.c b/blockdev.c
index ed90365329..228cebf9a2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
}
}
diff --git a/dump/win_dump.c b/dump/win_dump.c
index b7bfaff379..0115a609e0 100644
--- a/dump/win_dump.c
+++ b/dump/win_dump.c
@@ -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;
}
diff --git a/migration/savevm.c b/migration/savevm.c
index bb3e99194c..41c7f39ef5 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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();
}
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 7fc70f9166..f7c743b0ce 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition
2023-10-05 4:50 ` [PATCH v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition Philippe Mathieu-Daudé
@ 2023-10-20 11:50 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 11:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Juan Quintela, Fam Zheng, Kevin Wolf, Hanna Reitz,
Marc-André Lureau, Peter Xu, Leonardo Bras, Paolo Bonzini,
Richard Henderson
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
> ---
> 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(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index ac727d1c2d..d95c4b84b9 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index e90649c8bf..6779a181f0 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -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.
> + error_setg(errp, "An IO error has occurred");
We should spell it "I/O", unless we're reporting trouble with Jupiter's
moon.
> 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;
> }
>
[...]
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 15/22] qapi: Inline and remove QERR_MIGRATION_ACTIVE definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 14/22] qapi: Inline and remove QERR_IO_ERROR definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
` (8 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Juan Quintela, Peter Xu,
Leonardo Bras
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é <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index d95c4b84b9..cc4dae1076 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/migration/migration.c b/migration/migration.c
index b7f6818a15..5703cc34ae 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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;
}
diff --git a/migration/options.c b/migration/options.c
index 4f6c8e810c..7360a22252 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -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;
}
diff --git a/migration/savevm.c b/migration/savevm.c
index 41c7f39ef5..c0e0585bc1 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 15/22] qapi: Inline and remove QERR_MIGRATION_ACTIVE definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 12:58 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 17/22] qapi: Inline and remove QERR_MISSING_PARAMETER definition Philippe Mathieu-Daudé
` (7 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Stefan Berger,
Marc-André Lureau, Kevin Wolf, Hanna Reitz, Gerd Hoffmann,
Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost,
Stefan Berger, integration
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é <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
---
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(-)
diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
index 57369ec0f2..e781ded17c 100644
--- a/backends/dbus-vmstate.c
+++ b/backends/dbus-vmstate.c
@@ -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;
}
diff --git a/block/gluster.c b/block/gluster.c
index ad5fadbe79..8d97d698c3 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -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;
}
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index ca2599de44..90e593ed38 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -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;
}
diff --git a/dump/dump.c b/dump/dump.c
index e173f1f14c..642b952985 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -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) {
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index ac6fa34ad1..83bfc9dc19 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -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;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index b17aec4357..b7b2bf18d4 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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;
}
diff --git a/softmmu/tpm.c b/softmmu/tpm.c
index 8437c4efc3..3a7d4b5c67 100644
--- a/softmmu/tpm.c
+++ b/softmmu/tpm.c
@@ -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;
}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 98e071e63b..840ac84069 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -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;
}
diff --git a/ui/input-barrier.c b/ui/input-barrier.c
index 2d57ca7079..ecbba4adc2 100644
--- a/ui/input-barrier.c
+++ b/ui/input-barrier.c
@@ -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;
}
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index a95fd35948..0e350fc333 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter)
2023-10-05 4:50 ` [PATCH v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
@ 2023-10-20 12:58 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 12:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Stefan Berger, Marc-André Lureau, Kevin Wolf, Hanna Reitz,
Gerd Hoffmann, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost, Stefan Berger, integration
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> 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(-)
>
> diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
> index 57369ec0f2..e781ded17c 100644
> --- a/backends/dbus-vmstate.c
> +++ b/backends/dbus-vmstate.c
> @@ -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.
> + error_setg(errp, "Parameter 'addr' is missing");
> return;
> }
>
> diff --git a/block/gluster.c b/block/gluster.c
> index ad5fadbe79..8d97d698c3 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -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;
> }
I suspect pretty much everything you patch in this file is bad, but I'm
running out of steam.
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index ca2599de44..90e593ed38 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -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;
> }
>
> diff --git a/dump/dump.c b/dump/dump.c
> index e173f1f14c..642b952985 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -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) {
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index ac6fa34ad1..83bfc9dc19 100644
> --- a/hw/usb/redirect.c
> +++ b/hw/usb/redirect.c
> @@ -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.
> + error_setg(errp, "Parameter 'chardev' is missing");
> return;
> }
>
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index b17aec4357..b7b2bf18d4 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -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;
> }
>
> diff --git a/softmmu/tpm.c b/softmmu/tpm.c
> index 8437c4efc3..3a7d4b5c67 100644
> --- a/softmmu/tpm.c
> +++ b/softmmu/tpm.c
> @@ -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;
> }
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 98e071e63b..840ac84069 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -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;
> }
>
> diff --git a/ui/input-barrier.c b/ui/input-barrier.c
> index 2d57ca7079..ecbba4adc2 100644
> --- a/ui/input-barrier.c
> +++ b/ui/input-barrier.c
> @@ -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".
> + error_setg(errp, "Parameter 'name' is missing");
> return;
> }
>
> diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
> index a95fd35948..0e350fc333 100644
> --- a/ui/ui-qmp-cmds.c
> +++ b/ui/ui-qmp-cmds.c
> @@ -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".
> + error_setg(errp, "Parameter 'port/tls-port' is missing");
> return;
> }
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 17/22] qapi: Inline and remove QERR_MISSING_PARAMETER definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 16/22] qapi: Inline QERR_MISSING_PARAMETER definition (constant parameter) Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 4:50 ` [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition Philippe Mathieu-Daudé
` (6 subsequent siblings)
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Michael Roth
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é <philmd@linaro.org>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index cc4dae1076..b0f48f22fe 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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'"
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 844db583f4..bf0d8acbd6 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -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;
}
diff --git a/qapi/qapi-forward-visitor.c b/qapi/qapi-forward-visitor.c
index e36d9bc9ba..3fb2c954aa 100644
--- a/qapi/qapi-forward-visitor.c
+++ b/qapi/qapi-forward-visitor.c
@@ -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;
}
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index f5fa6c1878..17e9f3b638 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 17/22] qapi: Inline and remove QERR_MISSING_PARAMETER definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 13:00 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition Philippe Mathieu-Daudé
` (5 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
hw/core/qdev-properties.c | 2 +-
target/i386/cpu.c | 2 +-
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index b0f48f22fe..7862ac55a1 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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 ")"
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 357b8761b5..44fc1686e0 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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:
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index ed72883bf3..e5a14885ed 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition
2023-10-05 4:50 ` [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition Philippe Mathieu-Daudé
@ 2023-10-20 13:00 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 13:00 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> include/qapi/qmp/qerror.h | 3 ---
> hw/core/qdev-properties.c | 2 +-
> target/i386/cpu.c | 2 +-
> 3 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index b0f48f22fe..7862ac55a1 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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 ")"
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 357b8761b5..44fc1686e0 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -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:
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index ed72883bf3..e5a14885ed 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -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.
> + error_setg(errp, "Property 'vendor' doesn't take value '%s'", value);
> return;
> }
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 18/22] qapi: Inline and remove QERR_PROPERTY_VALUE_BAD definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 13:08 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition Philippe Mathieu-Daudé
` (4 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Mark Cave-Ayland
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é <philmd@linaro.org>
---
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(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 7862ac55a1..e094f13114 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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'"
diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index a6f91d4bcd..4f6ee930e2 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -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;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index e5a14885ed..273f865228 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -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;
}
diff --git a/util/block-helpers.c b/util/block-helpers.c
index c4851432f5..de94909bc4 100644
--- a/util/block-helpers.c
+++ b/util/block-helpers.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition
2023-10-05 4:50 ` [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition Philippe Mathieu-Daudé
@ 2023-10-20 13:08 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 13:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Mark Cave-Ayland
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 7862ac55a1..e094f13114 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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'"
>
> diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
> index a6f91d4bcd..4f6ee930e2 100644
> --- a/hw/intc/openpic.c
> +++ b/hw/intc/openpic.c
> @@ -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;
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index e5a14885ed..273f865228 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -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;
> }
> diff --git a/util/block-helpers.c b/util/block-helpers.c
> index c4851432f5..de94909bc4 100644
> --- a/util/block-helpers.c
> +++ b/util/block-helpers.c
> @@ -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.
> + 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;
> }
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 19/22] qapi: Inline and remove QERR_PROPERTY_VALUE_OUT_OF_RANGE definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-20 13:03 ` Markus Armbruster
2023-10-05 4:50 ` [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition Philippe Mathieu-Daudé
` (3 subsequent siblings)
23 siblings, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Konstantin Kostiuk, Michael Roth
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é <philmd@linaro.org>
---
include/qapi/qmp/qerror.h | 3 ---
qga/commands-win32.c | 38 ++++++++++++++++++++------------------
qga/commands.c | 7 ++++---
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index e094f13114..840831cc6a 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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"
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 946dbafbb6..aa8c9770d4 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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;
}
diff --git a/qga/commands.c b/qga/commands.c
index 871210ab0b..936634c50a 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition
2023-10-05 4:50 ` [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition Philippe Mathieu-Daudé
@ 2023-10-20 13:03 ` Markus Armbruster
0 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 13:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Konstantin Kostiuk, Michael Roth
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> include/qapi/qmp/qerror.h | 3 ---
> qga/commands-win32.c | 38 ++++++++++++++++++++------------------
> qga/commands.c | 7 ++++---
> 3 files changed, 24 insertions(+), 24 deletions(-)
>
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index e094f13114..840831cc6a 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -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"
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 946dbafbb6..aa8c9770d4 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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.
> 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;
> }
>
I don't like this error message. I'm going to pretend I didn't see it.
[...]
^ permalink raw reply [flat|nested] 49+ messages in thread
* [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 20/22] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 11:22 ` Markus Armbruster
2023-10-05 11:57 ` Markus Armbruster
2023-10-05 4:50 ` [PATCH v2 22/22] qapi: Remove 'qapi/qmp/qerror.h' header Philippe Mathieu-Daudé
` (2 subsequent siblings)
23 siblings, 2 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Michael Roth, Konstantin Kostiuk
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é <philmd@linaro.org>
---
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(-)
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index b720dd4379..51683f4dc2 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -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.
##
##
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 840831cc6a..7606f4525d 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -17,7 +17,4 @@
* add new ones!
*/
-#define QERR_UNSUPPORTED \
- "this feature or command is not currently supported"
-
#endif /* QERROR_H */
diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c
index 17bddda1cf..11536f148f 100644
--- a/qga/commands-bsd.c
+++ b/qga/commands-bsd.c
@@ -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 */
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 6169bbf7a0..f510add366 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index aa8c9770d4..5c9f8e0923 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2023-10-05 4:50 ` [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition Philippe Mathieu-Daudé
@ 2023-10-05 11:22 ` Markus Armbruster
2023-10-05 11:57 ` Markus Armbruster
2024-06-12 12:23 ` Philippe Mathieu-Daudé
2023-10-05 11:57 ` Markus Armbruster
1 sibling, 2 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-05 11:22 UTC (permalink / raw)
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Michael Roth, Konstantin Kostiuk
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> index b720dd4379..51683f4dc2 100644
> --- a/qga/qapi-schema.json
> +++ b/qga/qapi-schema.json
> @@ -6,8 +6,9 @@
##
# = General note concerning the use of guest agent interfaces
> #
> # "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.
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 840831cc6a..7606f4525d 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -17,7 +17,4 @@
> * add new ones!
> */
>
> -#define QERR_UNSUPPORTED \
> - "this feature or command is not currently supported"
> -
> #endif /* QERROR_H */
> diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c
> index 17bddda1cf..11536f148f 100644
> --- a/qga/commands-bsd.c
> +++ b/qga/commands-bsd.c
> @@ -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;
> }
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.
> #endif /* CONFIG_FSFREEZE */
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 6169bbf7a0..f510add366 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -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: [*]
> @@ -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: [*].
>
> @@ -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;
> }
>
> @@ -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: [*].
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index aa8c9770d4..5c9f8e0923 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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;
> }
>
!vss_initialized() means qga-vss.dll failed to load and initialize.
Another [*].
> @@ -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;
> }
>
Commands not supported by this build of qemu-qa: [*].
> @@ -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".
>
> @@ -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;
> }
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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2023-10-05 11:22 ` Markus Armbruster
@ 2023-10-05 11:57 ` Markus Armbruster
2024-06-12 12:23 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-05 11:57 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x, Michael Roth,
Konstantin Kostiuk
Please ignore this copy, it has the recipients messed up.
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2023-10-05 11:22 ` Markus Armbruster
2023-10-05 11:57 ` Markus Armbruster
@ 2024-06-12 12:23 ` Philippe Mathieu-Daudé
2024-06-12 13:07 ` Markus Armbruster
1 sibling, 1 reply; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-12 12:23 UTC (permalink / raw)
To: Konstantin Kostiuk, Michael Roth
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x
Michael, 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.
On 5/10/23 13:22, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> 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é <philmd@linaro.org>
>> ---
>> 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(-)
>>
>> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
>> index b720dd4379..51683f4dc2 100644
>> --- a/qga/qapi-schema.json
>> +++ b/qga/qapi-schema.json
>> @@ -6,8 +6,9 @@
> ##
> # = General note concerning the use of guest agent interfaces
>> #
>> # "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.
>
>> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
>> index 840831cc6a..7606f4525d 100644
>> --- a/include/qapi/qmp/qerror.h
>> +++ b/include/qapi/qmp/qerror.h
>> @@ -17,7 +17,4 @@
>> * add new ones!
>> */
>>
>> -#define QERR_UNSUPPORTED \
>> - "this feature or command is not currently supported"
>> -
>> #endif /* QERROR_H */
>> diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c
>> index 17bddda1cf..11536f148f 100644
>> --- a/qga/commands-bsd.c
>> +++ b/qga/commands-bsd.c
>> @@ -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;
>> }
>
> 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.
>
>> #endif /* CONFIG_FSFREEZE */
>> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>> index 6169bbf7a0..f510add366 100644
>> --- a/qga/commands-posix.c
>> +++ b/qga/commands-posix.c
>> @@ -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: [*]
>
>> @@ -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: [*].
>
>>
>> @@ -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;
>> }
>>
>> @@ -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: [*].
>
>> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
>> index aa8c9770d4..5c9f8e0923 100644
>> --- a/qga/commands-win32.c
>> +++ b/qga/commands-win32.c
>> @@ -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;
>> }
>>
>
> !vss_initialized() means qga-vss.dll failed to load and initialize.
>
> Another [*].
>
>> @@ -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;
>> }
>>
>
> Commands not supported by this build of qemu-qa: [*].
>
>> @@ -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".
>
>>
>> @@ -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;
>> }
>
> 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.
>
>
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2024-06-12 12:23 ` Philippe Mathieu-Daudé
@ 2024-06-12 13:07 ` Markus Armbruster
2024-06-12 13:27 ` Konstantin Kostiuk
2024-06-12 13:45 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 49+ messages in thread
From: Markus Armbruster @ 2024-06-12 13:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Konstantin Kostiuk, Michael Roth, qemu-devel, qemu-arm, qemu-ppc,
qemu-block, qemu-s390x
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Michael, 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?
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/20240604134933.220112-1-berrange@redhat.com/
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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2024-06-12 13:07 ` Markus Armbruster
@ 2024-06-12 13:27 ` Konstantin Kostiuk
2024-06-12 13:45 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 49+ messages in thread
From: Konstantin Kostiuk @ 2024-06-12 13:27 UTC (permalink / raw)
To: Markus Armbruster, Philippe Mathieu-Daudé
Cc: Michael Roth, qemu-devel, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
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.
On Wed, Jun 12, 2024 at 4:07 PM Markus Armbruster <armbru@redhat.com> wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
> > Michael, 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?
>
> 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/20240604134933.220112-1-berrange@redhat.com/
>
> 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.
>
>
[-- Attachment #2: Type: text/html, Size: 1788 bytes --]
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2024-06-12 13:07 ` Markus Armbruster
2024-06-12 13:27 ` Konstantin Kostiuk
@ 2024-06-12 13:45 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-12 13:45 UTC (permalink / raw)
To: Markus Armbruster
Cc: Konstantin Kostiuk, Michael Roth, qemu-devel, qemu-arm, qemu-ppc,
qemu-block, qemu-s390x
On 12/6/24 15:07, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> Michael, 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?
>
> 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/20240604134933.220112-1-berrange@redhat.com/
>
> 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 :)
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition
2023-10-05 4:50 ` [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition Philippe Mathieu-Daudé
2023-10-05 11:22 ` Markus Armbruster
@ 2023-10-05 11:57 ` Markus Armbruster
1 sibling, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-05 11:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, qemu-arm, qemu-ppc, qemu-block,
qemu-s390x, Michael Roth, Konstantin Kostiuk
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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é <philmd@linaro.org>
> ---
> 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(-)
>
> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> index b720dd4379..51683f4dc2 100644
> --- a/qga/qapi-schema.json
> +++ b/qga/qapi-schema.json
> @@ -6,8 +6,9 @@
##
# = General note concerning the use of guest agent interfaces
> #
> # "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.
> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
> index 840831cc6a..7606f4525d 100644
> --- a/include/qapi/qmp/qerror.h
> +++ b/include/qapi/qmp/qerror.h
> @@ -17,7 +17,4 @@
> * add new ones!
> */
>
> -#define QERR_UNSUPPORTED \
> - "this feature or command is not currently supported"
> -
> #endif /* QERROR_H */
> diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c
> index 17bddda1cf..11536f148f 100644
> --- a/qga/commands-bsd.c
> +++ b/qga/commands-bsd.c
> @@ -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;
> }
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.
> #endif /* CONFIG_FSFREEZE */
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 6169bbf7a0..f510add366 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -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: [*]
> @@ -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: [*].
>
> @@ -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;
> }
>
> @@ -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: [*].
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index aa8c9770d4..5c9f8e0923 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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;
> }
>
!vss_initialized() means qga-vss.dll failed to load and initialize.
Another [*].
> @@ -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;
> }
>
Commands not supported by this build of qemu-qa: [*].
> @@ -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".
>
> @@ -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;
> }
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.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v2 22/22] qapi: Remove 'qapi/qmp/qerror.h' header
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2023-10-05 4:50 ` [RFC PATCH v2 21/22] qapi: Inline and remove QERR_UNSUPPORTED definition Philippe Mathieu-Daudé
@ 2023-10-05 4:50 ` Philippe Mathieu-Daudé
2023-10-05 9:26 ` [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Markus Armbruster
2023-10-20 13:15 ` Markus Armbruster
23 siblings, 0 replies; 49+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-05 4:50 UTC (permalink / raw)
To: qemu-devel, Markus Armbruster
Cc: qemu-arm, qemu-ppc, qemu-block, qemu-s390x,
Philippe Mathieu-Daudé, Juan Quintela, Gonglei (Arei),
Zhenwei Pi, Marc-André Lureau, Laurent Vivier, Amit Shah,
Kevin Wolf, Hanna Reitz, Alberto Garcia, Fam Zheng, John Snow,
Vladimir Sementsov-Ogievskiy, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost, Mark Cave-Ayland,
Nicholas Piggin, Daniel Henrique Barboza, Cédric Le Goater,
David Gibson, Harsh Prateek Bora, Gerd Hoffmann, Peter Xu,
Leonardo Bras, Dr. David Alan Gilbert, Jason Wang, Michael Roth,
Konstantin Kostiuk, Michael S. Tsirkin, David Hildenbrand,
Richard Henderson, Stefan Berger, Peter Maydell, Ilya Leoshkevich,
Thomas Huth, integration
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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
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
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
deleted file mode 100644
index 7606f4525d..0000000000
--- a/include/qapi/qmp/qerror.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * QError Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- * Luiz Capitulino <lcapitulino@redhat.com>
- *
- * 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 */
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index d93ccd5528..5a41aa7be8 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -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"
diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
index e781ded17c..0006f8c400 100644
--- a/backends/dbus-vmstate.c
+++ b/backends/dbus-vmstate.c
@@ -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"
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 8f101afadc..35f19257bd 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -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"
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 9cb7d26cb5..a49e4a4970 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -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"
diff --git a/block/gluster.c b/block/gluster.c
index 8d97d698c3..91df6f1d07 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -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"
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 90e593ed38..9c3d3bedc6 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -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"
diff --git a/block/quorum.c b/block/quorum.c
index 8e9f279568..34ebbf4ce0 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -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"
diff --git a/block/snapshot.c b/block/snapshot.c
index eb43e957e1..131b4bd6d0 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -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"
diff --git a/block/vmdk.c b/block/vmdk.c
index 6779a181f0..ed9742f9da 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -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"
diff --git a/blockdev.c b/blockdev.c
index 228cebf9a2..5a76bb1498 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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"
diff --git a/blockjob.c b/blockjob.c
index f95f73244e..d359ea72e5 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -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"
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7d33b3ccd1..ff4cee00fc 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -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"
diff --git a/chardev/char.c b/chardev/char.c
index 447b4d9d06..cc61f3a6e7 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -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"
diff --git a/dump/dump.c b/dump/dump.c
index 642b952985..daa0c69305 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -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"
diff --git a/dump/win_dump.c b/dump/win_dump.c
index 0115a609e0..1772db8530 100644
--- a/dump/win_dump.c
+++ b/dump/win_dump.c
@@ -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"
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 7752c5fda5..ec68281b61 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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"
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 44fc1686e0..5005954b50 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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"
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9b62e0573d..165ce95a11 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -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"
diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index 4f6ee930e2..991b2efa25 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -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"
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 7f063f5852..a24755c8ff 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -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"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 83bfc9dc19..1147e8d018 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -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"
diff --git a/migration/migration.c b/migration/migration.c
index 5703cc34ae..a6b3e83867 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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"
diff --git a/migration/options.c b/migration/options.c
index 7360a22252..777200e65a 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -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"
diff --git a/migration/page_cache.c b/migration/page_cache.c
index d430ce742b..af6683c45e 100644
--- a/migration/page_cache.c
+++ b/migration/page_cache.c
@@ -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"
diff --git a/migration/ram.c b/migration/ram.c
index 0a4a0d7a0e..a5f05c5832 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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"
diff --git a/migration/savevm.c b/migration/savevm.c
index c0e0585bc1..3c49f2dbff 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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"
diff --git a/monitor/fds.c b/monitor/fds.c
index 17e9c126e3..4882db3232 100644
--- a/monitor/fds.c
+++ b/monitor/fds.c
@@ -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"
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 9d6533643d..912471f419 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -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"
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 2d2e71b867..c2d81b2f77 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -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"
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index 071029a6c7..46738415b7 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -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"
diff --git a/net/filter.c b/net/filter.c
index 1621513bab..8ff1eae923 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -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"
diff --git a/net/net.c b/net/net.c
index 5cdbd9c218..fdfe4f8eb1 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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"
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index bf0d8acbd6..7b595bb00b 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -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"
diff --git a/qapi/qapi-forward-visitor.c b/qapi/qapi-forward-visitor.c
index 3fb2c954aa..613e6d0f19 100644
--- a/qapi/qapi-forward-visitor.c
+++ b/qapi/qapi-forward-visitor.c
@@ -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"
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
index 82c3425566..f144ac1f70 100644
--- a/qapi/qapi-util.c
+++ b/qapi/qapi-util.c
@@ -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;
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 01793d6e74..a3214fa1a1 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -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"
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 17e9f3b638..82b33b6b64 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -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"
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 6ea6a0c676..bb1c43a6d7 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -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"
diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c
index 11536f148f..5508bc02ab 100644
--- a/qga/commands-bsd.c
+++ b/qga/commands-bsd.c
@@ -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"
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index f510add366..6ea8a03e61 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -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"
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 5c9f8e0923..db973c2e7e 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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"
diff --git a/qga/commands.c b/qga/commands.c
index 936634c50a..738d3d9da6 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -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"
diff --git a/qom/object.c b/qom/object.c
index eea61a5068..66b02c0f22 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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"
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index be04b2c5ab..391ea8561b 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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"
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 3d014f1bea..67ab1774eb 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -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"
diff --git a/softmmu/balloon.c b/softmmu/balloon.c
index d941c6b9c1..f2545a6e58 100644
--- a/softmmu/balloon.c
+++ b/softmmu/balloon.c
@@ -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;
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index f7c743b0ce..bee6afbd6d 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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"
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index b7b2bf18d4..9d608d5d65 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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"
diff --git a/softmmu/rtc.c b/softmmu/rtc.c
index 4904581abe..dc44576686 100644
--- a/softmmu/rtc.c
+++ b/softmmu/rtc.c
@@ -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"
diff --git a/softmmu/tpm.c b/softmmu/tpm.c
index 3a7d4b5c67..aee351e896 100644
--- a/softmmu/tpm.c
+++ b/softmmu/tpm.c
@@ -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"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 840ac84069..8bfe51fce4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -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"
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index 3c99fd8222..dabe89e4bc 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -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"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 273f865228..53124f5319 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -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"
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 4507714493..4b3fd70ea1 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -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"
diff --git a/ui/input-barrier.c b/ui/input-barrier.c
index ecbba4adc2..8df118b440 100644
--- a/ui/input-barrier.c
+++ b/ui/input-barrier.c
@@ -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"
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index 0e350fc333..a7ce9c1892 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -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"
diff --git a/util/block-helpers.c b/util/block-helpers.c
index de94909bc4..85b53e30d2 100644
--- a/util/block-helpers.c
+++ b/util/block-helpers.c
@@ -10,7 +10,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
#include "block-helpers.h"
/**
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 9440224e5b..6b86792ae7 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -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"
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index 4b4a442383..a21b7b1468 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -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))
--
2.41.0
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2023-10-05 4:50 ` [PATCH v2 22/22] qapi: Remove 'qapi/qmp/qerror.h' header Philippe Mathieu-Daudé
@ 2023-10-05 9:26 ` Markus Armbruster
2023-10-20 13:15 ` Markus Armbruster
23 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-05 9:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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.
Gee, a late birthday present for me! Thank you!
> 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...
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good
2023-10-05 4:50 [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2023-10-05 9:26 ` [PATCH v2 00/22] qapi: Kill 'qapi/qmp/qerror.h' for good Markus Armbruster
@ 2023-10-20 13:15 ` Markus Armbruster
23 siblings, 0 replies; 49+ messages in thread
From: Markus Armbruster @ 2023-10-20 13:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-arm, qemu-ppc, qemu-block, qemu-s390x
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.
^ permalink raw reply [flat|nested] 49+ messages in thread