Skip to contentSkip to conversation

error: Reduce qerror.h usage a bit more

PATCH In review Markus Armbruster 4 participants 33 messages Feb 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover error: Reduce qerror.h usage a bit more

This series gets rid of two out of 15 remaining QERR_ macros and confines use of one more to qga/. Bonus: better error messages.

Markus Armbruster (12):
error: Drop superfluous #include "qapi/qmp/qerror.h"
dump: Improve error message when target doesn't support memory dump
dump: Assert cpu_get_note_size() can't fail
hw/core: Improve error message when machine doesn't provide NMIs hw/smbios: Dumb down smbios_entry_add() stub
hw/acpi: Dumb down acpi_table_add() stub
hw/acpi: Move QMP command to hw/core/
qga: Drop dangling reference to QERR_QGA_LOGGING_DISABLED
replay: Simplify setting replay blockers
hw/core: Improve the query-hotpluggable-cpus error message migration/colo: Improve an x-colo-lost-heartbeat error message
rocker: Tweak stubbed out monitor commands' error messages

 MAINTAINERS                    |  1 -
 include/qapi/qmp/qerror.h      |  6 ------
 include/sysemu/replay.h        |  2 +-
 authz/listfile.c               |  1 -
 backends/cryptodev-vhost.c     |  1 -
 backends/rng.c                 |  1 -
 backends/vhost-user.c          |  1 -
 block/backup.c                 |  1 -
 block/commit.c                 |  1 -
 block/mirror.c                 |  1 -
 block/stream.c                 |  1 -
 dump/dump.c                    |  8 +++-----
 hw/acpi/acpi-stub.c            |  4 +---
 hw/acpi/vmgenid.c              | 18 ------------------
 hw/core/machine-qmp-cmds.c     | 21 +++++++++++++++++++--
 hw/core/machine.c              |  1 -
 hw/core/nmi.c                  |  3 +--
 hw/i386/pc.c                   |  1 -
 hw/i386/x86.c                  |  1 -
 hw/misc/xlnx-zynqmp-apu-ctrl.c |  1 -
 hw/net/rocker/qmp-norocker.c   | 12 +++++-------
 hw/smbios/smbios-stub.c        |  4 +---
 migration/colo-failover.c      |  3 +--
 migration/colo.c               |  1 -
 migration/migration-hmp-cmds.c |  1 -
 qga/commands.c                 |  5 ++---
 qga/main.c                     |  1 -
 replay/replay.c                |  6 +++++-
 replay/stubs-system.c          |  2 +-
 softmmu/qtest.c                |  1 -
 softmmu/rtc.c                  |  5 +----
 softmmu/vl.c                   | 13 +++----------
 stubs/vmgenid.c                | 10 ----------
 target/i386/monitor.c          |  1 -
 target/i386/sev-sysemu-stub.c  |  1 -
 target/i386/sev.c              |  1 -
 util/qemu-config.c             |  1 -
 stubs/meson.build              |  1 -
 38 files changed, 44 insertions(+), 100 deletions(-)
 delete mode 100644 stubs/vmgenid.c
Signature · 1 line
2.39.0
#1 lore raw

PATCH 1/12 error: Drop superfluous #include "qapi/qmp/qerror.h"

---
 authz/listfile.c               | 1 -
 backends/cryptodev-vhost.c     | 1 -
 backends/rng.c                 | 1 -
 backends/vhost-user.c          | 1 -
 block/backup.c                 | 1 -
 block/commit.c                 | 1 -
 block/mirror.c                 | 1 -
 block/stream.c                 | 1 -
 hw/core/machine.c              | 1 -
 hw/i386/pc.c                   | 1 -
 hw/i386/x86.c                  | 1 -
 hw/misc/xlnx-zynqmp-apu-ctrl.c | 1 -
 migration/colo.c               | 1 -
 migration/migration-hmp-cmds.c | 1 -
 qga/main.c                     | 1 -
 softmmu/qtest.c                | 1 -
 target/i386/monitor.c          | 1 -
 target/i386/sev-sysemu-stub.c  | 1 -
 target/i386/sev.c              | 1 -
 util/qemu-config.c             | 1 -
 20 files changed, 20 deletions(-)
authz/listfile.c +0 -1
index da3a0e69a2..45a60e987d 100644
@@ -30,7 +30,6 @@
 #include "qapi/qapi-visit-authz.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qobject.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qobject-input-visitor.h"
 
 
backends/cryptodev-vhost.c +0 -1
index 572f87b3be..74ea0ad63d 100644
@@ -28,7 +28,6 @@
 
 #ifdef CONFIG_VHOST_CRYPTO
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "hw/virtio/virtio-crypto.h"
 #include "sysemu/cryptodev-vhost-user.h"
backends/rng.c +0 -1
index 6c7bf64426..9bbd0c77b6 100644
@@ -13,7 +13,6 @@
 #include "qemu/osdep.h"
 #include "sysemu/rng.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/module.h"
 #include "qom/object_interfaces.h"
 
backends/vhost-user.c +0 -1
index 7bfcaef976..0596223ac4 100644
@@ -13,7 +13,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qom/object_interfaces.h"
 #include "sysemu/vhost-user-backend.h"
block/backup.c +0 -1
index 824d39acaa..5b8863b88c 100644
@@ -22,7 +22,6 @@
 #include "block/block-copy.h"
 #include "block/dirty-bitmap.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/cutils.h"
 #include "sysemu/block-backend.h"
 #include "qemu/bitmap.h"
block/commit.c +0 -1
index 41e3599281..387a720d03 100644
@@ -18,7 +18,6 @@
 #include "block/block_int.h"
 #include "block/blockjob_int.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 #include "qemu/memalign.h"
 #include "sysemu/block-backend.h"
block/mirror.c +0 -1
index ab326b67c9..0f6551cf5b 100644
@@ -21,7 +21,6 @@
 #include "block/dirty-bitmap.h"
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
 #include "qemu/bitmap.h"
 #include "qemu/memalign.h"
block/stream.c +0 -1
index 8744ad103f..e77a033233 100644
@@ -16,7 +16,6 @@
 #include "block/block_int.h"
 #include "block/blockjob_int.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qdict.h"
 #include "qemu/ratelimit.h"
 #include "sysemu/block-backend.h"
hw/core/machine.c +0 -1
index f7761baab5..89bf690365 100644
@@ -13,7 +13,6 @@
 #include "qemu/osdep.h"
 #include "qemu/option.h"
 #include "qemu/accel.h"
-#include "qapi/qmp/qerror.h"
 #include "sysemu/replay.h"
 #include "qemu/units.h"
 #include "hw/boards.h"
hw/i386/pc.c +0 -1
index 6e592bd969..a7a2ededf9 100644
@@ -92,7 +92,6 @@
 #include "hw/mem/memory-device.h"
 #include "sysemu/replay.h"
 #include "target/i386/cpu.h"
-#include "qapi/qmp/qerror.h"
 #include "e820_memory_layout.h"
 #include "fw_cfg.h"
 #include "trace.h"
hw/i386/x86.c +0 -1
index eaff4227bd..48be7a1c23 100644
@@ -28,7 +28,6 @@
 #include "qemu/datadir.h"
 #include "qemu/guest-random.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qapi-visit-common.h"
 #include "qapi/clone-visitor.h"
 #include "qapi/qapi-visit-machine.h"
hw/misc/xlnx-zynqmp-apu-ctrl.c +0 -1
index 20de23cf67..3d2be95e6d 100644
@@ -18,7 +18,6 @@
 #include "hw/register.h"
 
 #include "qemu/bitops.h"
-#include "qapi/qmp/qerror.h"
 
 #include "hw/misc/xlnx-zynqmp-apu-ctrl.h"
 
migration/colo.c +0 -1
index 232c8d44b1..0716e64689 100644
@@ -33,7 +33,6 @@
 #include "net/colo.h"
 #include "block/block.h"
 #include "qapi/qapi-events-migration.h"
-#include "qapi/qmp/qerror.h"
 #include "sysemu/cpus.h"
 #include "sysemu/runstate.h"
 #include "net/filter.h"
migration/migration-hmp-cmds.c +0 -1
index ef25bc8929..72519ea99f 100644
@@ -23,7 +23,6 @@
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-visit-migration.h"
 #include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/string-input-visitor.h"
 #include "qapi/string-output-visitor.h"
 #include "qemu/cutils.h"
qga/main.c +0 -1
index 85b7d6ced5..2b992a55b3 100644
@@ -24,7 +24,6 @@
 #include "qapi/qmp/qjson.h"
 #include "guest-agent-core.h"
 #include "qga-qapi-init-commands.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/error.h"
 #include "channel.h"
 #include "qemu/cutils.h"
softmmu/qtest.c +0 -1
index d3e0ab4eda..34bd2a33a7 100644
@@ -28,7 +28,6 @@
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "qemu/cutils.h"
-#include "qapi/qmp/qerror.h"
 #include "qom/object_interfaces.h"
 #include CONFIG_DEVICES
 #ifdef CONFIG_PSERIES
target/i386/monitor.c +0 -1
index ad5b7b8bb5..6512846327 100644
@@ -28,7 +28,6 @@
 #include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qerror.h"
 #include "sysemu/kvm.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc-target.h"
target/i386/sev-sysemu-stub.c +0 -1
index 7a29295d1e..96e1c15cc3 100644
@@ -15,7 +15,6 @@
 #include "monitor/monitor.h"
 #include "monitor/hmp-target.h"
 #include "qapi/qapi-commands-misc-target.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/error.h"
 #include "sev.h"
 
target/i386/sev.c +0 -1
index 32f7dbac4e..0ec970496e 100644
@@ -34,7 +34,6 @@
 #include "monitor/monitor.h"
 #include "monitor/hmp-target.h"
 #include "qapi/qapi-commands-misc-target.h"
-#include "qapi/qmp/qerror.h"
 #include "exec/confidential-guest-support.h"
 #include "hw/i386/pc.h"
 #include "exec/address-spaces.h"
util/qemu-config.c +0 -1
index d63f27438d..42076efe1e 100644
@@ -2,7 +2,6 @@
 #include "block/qdict.h" /* for qdict_extract_subqdict() */
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qlist.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.39.0
Reviewed-by on v1 1/12
#2 lore raw

Re: [PATCH 01/12] error: Drop superfluous #include "qapi/qmp/qerror.h"

authz/listfile.c

Quoted 25 lines · Markus Armbruster
---
 authz/listfile.c               | 1 -
 backends/cryptodev-vhost.c     | 1 -
 backends/rng.c                 | 1 -
 backends/vhost-user.c          | 1 -
 block/backup.c                 | 1 -
 block/commit.c                 | 1 -
 block/mirror.c                 | 1 -
 block/stream.c                 | 1 -
 hw/core/machine.c              | 1 -
 hw/i386/pc.c                   | 1 -
 hw/i386/x86.c                  | 1 -
 hw/misc/xlnx-zynqmp-apu-ctrl.c | 1 -
 migration/colo.c               | 1 -
 migration/migration-hmp-cmds.c | 1 -
 qga/main.c                     | 1 -
 softmmu/qtest.c                | 1 -
 target/i386/monitor.c          | 1 -
 target/i386/sev-sysemu-stub.c  | 1 -
 target/i386/sev.c              | 1 -
 util/qemu-config.c             | 1 -
 20 files changed, 20 deletions(-)
authz/listfile.c +0 -0
Reviewed-by
#3 lore raw

Re: [PATCH 01/12] error: Drop superfluous #include "qapi/qmp/qerror.h"

Quoted 30 lines · Juan Quintela

authz/listfile.c

Quoted 25 lines · Markus Armbruster
---
 authz/listfile.c               | 1 -
 backends/cryptodev-vhost.c     | 1 -
 backends/rng.c                 | 1 -
 backends/vhost-user.c          | 1 -
 block/backup.c                 | 1 -
 block/commit.c                 | 1 -
 block/mirror.c                 | 1 -
 block/stream.c                 | 1 -
 hw/core/machine.c              | 1 -
 hw/i386/pc.c                   | 1 -
 hw/i386/x86.c                  | 1 -
 hw/misc/xlnx-zynqmp-apu-ctrl.c | 1 -
 migration/colo.c               | 1 -
 migration/migration-hmp-cmds.c | 1 -
 qga/main.c                     | 1 -
 softmmu/qtest.c                | 1 -
 target/i386/monitor.c          | 1 -
 target/i386/sev-sysemu-stub.c  | 1 -
 target/i386/sev.c              | 1 -
 util/qemu-config.c             | 1 -
 20 files changed, 20 deletions(-)
authz/listfile.c +0 -0
#4 lore raw

PATCH 2/12 dump: Improve error message when target doesn't support memory dump

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message

(qemu) dump-guest-memory mumble
Error: this feature or command is not currently supported

to

Error: guest memory dumping is not supported on this target

---
 dump/dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dump/dump.c +2 -1
index 279b07f09b..80620da40d 100644
@@ -1854,7 +1854,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
      */
     ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
     if (ret < 0) {
-        error_setg(errp, QERR_UNSUPPORTED);
+        error_setg(errp,
+                   "guest memory dumping is not supported on this target");
         goto cleanup;
     }
 
Signature · 1 line
2.39.0
#5 lore raw

Re: [PATCH 02/12] dump: Improve error message when target doesn't support memory dump

Quoted 23 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message

(qemu) dump-guest-memory mumble
Error: this feature or command is not currently supported

to

Error: guest memory dumping is not supported on this target

---
  dump/dump.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
dump/dump.c +0 -0
index 279b07f09b..80620da40d 100644

dump/dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1858

Quoted 6 lines
dump/dump.c +2 -1
@@ -1854,7 +1854,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
       */
      ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
      if (ret < 0) {
-        error_setg(errp, QERR_UNSUPPORTED);
+        error_setg(errp,
+                   "guest memory dumping is not supported on this target");

"Dumping guest memory is not supported on this target"?

Quoted 3 lines
dump/dump.c +0 -0
          goto cleanup;
      }
 
#6 lore raw

Re: [PATCH 02/12] dump: Improve error message when target doesn't support memory dump

Quoted 18 lines · Philippe Mathieu-Daudé
Quoted 17 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.
Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message
(qemu) dump-guest-memory mumble
Error: this feature or command is not currently supported
to
Error: guest memory dumping is not supported on this target

---
  dump/dump.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
dump/dump.c +0 -0
index 279b07f09b..80620da40d 100644
@@ -1854,7 +1854,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
Quoted 8 lines

dump/dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1858

Quoted 6 lines
dump/dump.c +2 -1
       */
      ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
      if (ret < 0) {
-        error_setg(errp, QERR_UNSUPPORTED);
+        error_setg(errp,
+                   "guest memory dumping is not supported on this target");

"Dumping guest memory is not supported on this target"?

Sold!

Quoted 3 lines
Quoted 3 lines
dump/dump.c +0 -0
          goto cleanup;
      }
 
Reviewed-by on v1 2/12
#7 lore raw

Re: [PATCH 02/12] dump: Improve error message when target doesn't support memory dump

In reply to Markus Armbruster
Quoted 6 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message

Quoted 8 lines

(qemu) dump-guest-memory mumble
Error: this feature or command is not currently supported

to

Error: guest memory dumping is not supported on this target

Both your and philippe message are ok with me.

#8 lore raw

PATCH 3/12 dump: Assert cpu_get_note_size() can't fail

In reply to Markus Armbruster

The only way cpu_get_note_size() can return a negative value is integer overflow in the non-stub versions, which is a programming error. The stub version is not actually reachable, because the cpu_get_dump_info() stub will fail first. Use assert(). This gets rid of another use of QERR_UNSUPPORTED.

---
 dump/dump.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
dump/dump.c +1 -4
index 80620da40d..6be8a65fe3 100644
@@ -1865,10 +1865,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
 
     s->note_size = cpu_get_note_size(s->dump_info.d_class,
                                      s->dump_info.d_machine, nr_cpus);
-    if (s->note_size < 0) {
-        error_setg(errp, QERR_UNSUPPORTED);
-        goto cleanup;
-    }
+    assert(s->note_size >= 0);
 
     /*
      * The goal of this block is to (a) update the previously guessed
Signature · 1 line
2.39.0
Reviewed-by on v1 3/12
#9 lore raw

Re: [PATCH 03/12] dump: Assert cpu_get_note_size() can't fail

Quoted 7 lines · Markus Armbruster

The only way cpu_get_note_size() can return a negative value is integer overflow in the non-stub versions, which is a programming error. The stub version is not actually reachable, because the cpu_get_dump_info() stub will fail first. Use assert(). This gets rid of another use of QERR_UNSUPPORTED.

#10 lore raw

PATCH 4/12 hw/core: Improve error message when machine doesn't provide NMIs

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message

(qemu) nmi
Error: this feature or command is not currently supported

to

Error: machine does not provide NMIs

---
 hw/core/nmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/core/nmi.c +1 -2
index 481c4b3c7e..a7bce8a04a 100644
@@ -22,7 +22,6 @@
 #include "qemu/osdep.h"
 #include "hw/nmi.h"
 #include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/module.h"
 #include "monitor/monitor.h"
 
@@ -70,7 +69,7 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
     if (ns.handled) {
         error_propagate(errp, ns.err);
     } else {
-        error_setg(errp, QERR_UNSUPPORTED);
+        error_setg(errp, "machine does not provide NMIs");
     }
 }
 
Signature · 1 line
2.39.0
Reviewed-by on v1 4/12
#11 lore raw

Re: [PATCH 04/12] hw/core: Improve error message when machine doesn't provide NMIs

Quoted 6 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_UNSUPPORTED, and improve the rather vague error message

Quoted 8 lines

(qemu) nmi
Error: this feature or command is not currently supported

to

Error: machine does not provide NMIs

Much better error message.

#12 lore raw

PATCH 5/12 hw/smbios: Dumb down smbios_entry_add() stub

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

smbios_entry_add() is only ever called on behalf of CLI option -smbios. Since qemu-options.hx sets @arch_mask to QEMU_ARCH_I386 | QEMU_ARCH_ARM, it is reachable only for these targets. Since they provide a real smbios_entry_add(), the stub is unreachable.

There's no point in unreachable code keeping QERR_UNSUPPORTED alive. Dumb it down to g_assert_not_reached().

---
 hw/smbios/smbios-stub.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/smbios/smbios-stub.c +1 -3
index 64e5ba93ec..e8808adfda 100644
@@ -21,11 +21,9 @@
  */
 
 #include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "hw/firmware/smbios.h"
 
 void smbios_entry_add(QemuOpts *opts, Error **errp)
 {
-    error_setg(errp, QERR_UNSUPPORTED);
+    g_assert_not_reached();
 }
Signature · 1 line
2.39.0
Reviewed-by on v1 5/12
#13 lore raw

Re: [PATCH 05/12] hw/smbios: Dumb down smbios_entry_add() stub

Quoted 8 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

smbios_entry_add() is only ever called on behalf of CLI option -smbios. Since qemu-options.hx sets @arch_mask to QEMU_ARCH_I386 | QEMU_ARCH_ARM, it is reachable only for these targets. Since they provide a real smbios_entry_add(), the stub is unreachable.

Quoted 4 lines

There's no point in unreachable code keeping QERR_UNSUPPORTED alive. Dumb it down to g_assert_not_reached().

#14 lore raw

PATCH 6/12 hw/acpi: Dumb down acpi_table_add() stub

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

acpi_table_add() is only ever called on behalf of CLI option -acpitable. Since qemu-options.hx sets @arch_mask to QEMU_ARCH_I386, it is reachable only for these targets. Since they provide a real acpi_table_add(), the stub is unreachable.

There's no point in unreachable code keeping QERR_UNSUPPORTED alive. Dumb it down to g_assert_not_reached().

---
 hw/acpi/acpi-stub.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/acpi/acpi-stub.c +1 -3
index 4c9d081ed4..e268ce9b1a 100644
@@ -19,11 +19,9 @@
  */
 
 #include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
 #include "hw/acpi/acpi.h"
 
 void acpi_table_add(const QemuOpts *opts, Error **errp)
 {
-    error_setg(errp, QERR_UNSUPPORTED);
+    g_assert_not_reached();
 }
Signature · 1 line
2.39.0
Reviewed-by on v1 6/12
#15 lore raw

Re: [PATCH 06/12] hw/acpi: Dumb down acpi_table_add() stub

Quoted 8 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

acpi_table_add() is only ever called on behalf of CLI option -acpitable. Since qemu-options.hx sets @arch_mask to QEMU_ARCH_I386, it is reachable only for these targets. Since they provide a real acpi_table_add(), the stub is unreachable.

Quoted 4 lines

There's no point in unreachable code keeping QERR_UNSUPPORTED alive. Dumb it down to g_assert_not_reached().

#16 lore raw

PATCH 7/12 hw/acpi: Move QMP command to hw/core/

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

qmp_query_vm_generation_id() in stubs/vmgenid.c is the last user of QERR_UNSUPPORTED outside qga/. Unlike the stubs we just dropped, it is actually reachable, namely when CONFIG_ACPI_VMGENID is off. It always fails like

(qemu) info vm-generation-id
Error: this feature or command is not currently supported

Turns out the real qmp_query_vm_generation_id() doesn't actually depend on CONFIG_ACPI_VMGENID, and fails safely when it's off. Move it to hw/core/machine-qmp-cmds.c, and drop the stub. The error message becomes

Error: VM Generation ID device not found

Feels like an improvement to me.

---
 MAINTAINERS                |  1 -
 hw/acpi/vmgenid.c          | 18 ------------------
 hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++
 stubs/vmgenid.c            | 10 ----------
 stubs/meson.build          |  1 -
 5 files changed, 18 insertions(+), 30 deletions(-)
 delete mode 100644 stubs/vmgenid.c
MAINTAINERS +0 -1
index fa10ecaeb9..1abdd01661 100644
@@ -2267,7 +2267,6 @@ F: hw/acpi/vmgenid.c
 F: include/hw/acpi/vmgenid.h
 F: docs/specs/vmgenid.txt
 F: tests/qtest/vmgenid-test.c
-F: stubs/vmgenid.c
 
 LED
 M: Philippe Mathieu-Daudé <[email protected]>
hw/acpi/vmgenid.c +0 -18
index 0c9f158ac9..a39315c1b3 100644
@@ -12,7 +12,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
 #include "qemu/module.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
@@ -244,20 +243,3 @@ static void vmgenid_register_types(void)
 }
 
 type_init(vmgenid_register_types)
-
-GuidInfo *qmp_query_vm_generation_id(Error **errp)
-{
-    GuidInfo *info;
-    VmGenIdState *vms;
-    Object *obj = find_vmgenid_dev();
-
-    if (!obj) {
-        error_setg(errp, "VM Generation ID device not found");
-        return NULL;
-    }
-    vms = VMGENID(obj);
-
-    info = g_malloc0(sizeof(*info));
-    info->guid = qemu_uuid_unparse_strdup(&vms->guid);
-    return info;
-}
hw/core/machine-qmp-cmds.c +18 -0
index 44b5da8880..a6ed3a63c3 100644
@@ -8,6 +8,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "hw/acpi/vmgenid.h"
 #include "hw/boards.h"
 #include "hw/intc/intc.h"
 #include "hw/mem/memory-device.h"
@@ -383,3 +384,20 @@ HumanReadableText *qmp_x_query_irq(Error **errp)
 
     return human_readable_text_from_str(buf);
 }
+
+GuidInfo *qmp_query_vm_generation_id(Error **errp)
+{
+    GuidInfo *info;
+    VmGenIdState *vms;
+    Object *obj = find_vmgenid_dev();
+
+    if (!obj) {
+        error_setg(errp, "VM Generation ID device not found");
+        return NULL;
+    }
+    vms = VMGENID(obj);
+
+    info = g_malloc0(sizeof(*info));
+    info->guid = qemu_uuid_unparse_strdup(&vms->guid);
+    return info;
+}
stubs/vmgenid.c deleted +0 -10
deleted file mode 100644
index bfad656c6c..0000000000
@@ -1,10 +0,0 @@
-#include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
-#include "qapi/qmp/qerror.h"
-
-GuidInfo *qmp_query_vm_generation_id(Error **errp)
-{
-    error_setg(errp, QERR_UNSUPPORTED);
-    return NULL;
-}
stubs/meson.build +0 -1
index 981585cbdf..7657467a5d 100644
@@ -45,7 +45,6 @@ stub_ss.add(files('target-get-monitor-def.c'))
 stub_ss.add(files('target-monitor-defs.c'))
 stub_ss.add(files('trace-control.c'))
 stub_ss.add(files('uuid.c'))
-stub_ss.add(files('vmgenid.c'))
 stub_ss.add(files('vmstate.c'))
 stub_ss.add(files('vm-stop.c'))
 stub_ss.add(files('win32-kbd-hook.c'))
Signature · 1 line
2.39.0
Reviewed-by on v1 7/12
#17 lore raw

Re: [PATCH 07/12] hw/acpi: Move QMP command to hw/core/

Quoted 11 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

qmp_query_vm_generation_id() in stubs/vmgenid.c is the last user of QERR_UNSUPPORTED outside qga/. Unlike the stubs we just dropped, it is actually reachable, namely when CONFIG_ACPI_VMGENID is off. It always fails like

(qemu) info vm-generation-id
Error: this feature or command is not currently supported

Quoted 8 lines

Turns out the real qmp_query_vm_generation_id() doesn't actually depend on CONFIG_ACPI_VMGENID, and fails safely when it's off. Move it to hw/core/machine-qmp-cmds.c, and drop the stub. The error message becomes

Error: VM Generation ID device not found

Feels like an improvement to me.

Fully agree.

Quoted 1 line
#18 lore raw

PATCH 8/12 qga: Drop dangling reference to QERR_QGA_LOGGING_DISABLED

In reply to Markus Armbruster

slog()'s function comment advises to use QERR_QGA_LOGGING_DISABLED. This macro never existed. The reference got added in commit e3d4d25206a "guest agent: add guest agent RPCs/commands" along with QERR_QGA_LOGGING_FAILED, so maybe that one was meant. However, QERR_QGA_LOGGING_FAILED was never actually used, and was removed in commit d73f0beadb5 "qerror.h: Remove unused error classes".

Drop the dangling reference.

---
 qga/commands.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
qga/commands.c +2 -3
index 360077364e..172826f8f8 100644
@@ -32,9 +32,8 @@
 #define GUEST_FILE_READ_COUNT_MAX (48 * MiB)
 
 /* Note: in some situations, like with the fsfreeze, logging may be
- * temporarilly disabled. if it is necessary that a command be able
- * to log for accounting purposes, check ga_logging_enabled() beforehand,
- * and use the QERR_QGA_LOGGING_DISABLED to generate an error
+ * temporarily disabled. if it is necessary that a command be able
+ * to log for accounting purposes, check ga_logging_enabled() beforehand.
  */
 void slog(const gchar *fmt, ...)
 {
Signature · 1 line
2.39.0
Reviewed-by on v1 8/12
#19 lore raw

Re: [PATCH 08/12] qga: Drop dangling reference to QERR_QGA_LOGGING_DISABLED

Quoted 10 lines · Markus Armbruster

slog()'s function comment advises to use QERR_QGA_LOGGING_DISABLED. This macro never existed. The reference got added in commit e3d4d25206a "guest agent: add guest agent RPCs/commands" along with QERR_QGA_LOGGING_FAILED, so maybe that one was meant. However, QERR_QGA_LOGGING_FAILED was never actually used, and was removed in commit d73f0beadb5 "qerror.h: Remove unused error classes".

Drop the dangling reference.

Reviewed-by
#20 lore raw

Re: [PATCH 08/12] qga: Drop dangling reference to QERR_QGA_LOGGING_DISABLED

Quoted 15 lines · Juan Quintela
Quoted 10 lines · Markus Armbruster

slog()'s function comment advises to use QERR_QGA_LOGGING_DISABLED. This macro never existed. The reference got added in commit e3d4d25206a "guest agent: add guest agent RPCs/commands" along with QERR_QGA_LOGGING_FAILED, so maybe that one was meant. However, QERR_QGA_LOGGING_FAILED was never actually used, and was removed in commit d73f0beadb5 "qerror.h: Remove unused error classes".

Drop the dangling reference.

#21 lore raw

PATCH 9/12 replay: Simplify setting replay blockers

In reply to Markus Armbruster

replay_add_blocker() takes an Error *. All callers pass one created like this:

    error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "some feature");

Folding this into replay_add_blocker() simplifies the callers, losing a bit of generality we haven't needed in more than six years.

Since there are no other uses of macro QERR_REPLAY_NOT_SUPPORTED, replace the remaining one by its expansion, and drop the macro.

---
 include/qapi/qmp/qerror.h |  3 ---
 include/sysemu/replay.h   |  2 +-
 replay/replay.c           |  6 +++++-
 replay/stubs-system.c     |  2 +-
 softmmu/rtc.c             |  5 +----
 softmmu/vl.c              | 13 +++----------
 6 files changed, 11 insertions(+), 20 deletions(-)
include/qapi/qmp/qerror.h +0 -3
index 87ca83b155..09006e69f7 100644
@@ -59,9 +59,6 @@
 #define QERR_QGA_COMMAND_FAILED \
     "Guest agent command failed, error was '%s'"
 
-#define QERR_REPLAY_NOT_SUPPORTED \
-    "Record/replay feature is not supported for '%s'"
-
 #define QERR_UNSUPPORTED \
     "this feature or command is not currently supported"
 
include/sysemu/replay.h +1 -1
index 7ec0882b50..6e5ab09f71 100644
@@ -72,7 +72,7 @@ void replay_start(void);
 /*! Closes replay log file and frees other resources. */
 void replay_finish(void);
 /*! Adds replay blocker with the specified error description */
-void replay_add_blocker(Error *reason);
+void replay_add_blocker(const char *feature);
 /* Returns name of the replay log file */
 const char *replay_get_filename(void);
 /*
replay/replay.c +5 -1
index 9a0dc1cf44..c39156c522 100644
@@ -376,8 +376,12 @@ void replay_finish(void)
     replay_mode = REPLAY_MODE_NONE;
 }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
 {
+    Error *reason = NULL;
+
+    error_setg(&reason, "Record/replay feature is not supported for '%s'",
+               feature);
     replay_blockers = g_slist_prepend(replay_blockers, reason);
 }
 
replay/stubs-system.c +1 -1
index 5c262b08f1..50cefdb2d6 100644
@@ -12,7 +12,7 @@ void replay_input_sync_event(void)
     qemu_input_event_sync_impl();
 }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
 {
 }
 void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
softmmu/rtc.c +1 -4
index f7114bed7d..4b2bf75dd6 100644
@@ -152,11 +152,8 @@ void configure_rtc(QemuOpts *opts)
         if (!strcmp(value, "utc")) {
             rtc_base_type = RTC_BASE_UTC;
         } else if (!strcmp(value, "localtime")) {
-            Error *blocker = NULL;
             rtc_base_type = RTC_BASE_LOCALTIME;
-            error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED,
-                      "-rtc base=localtime");
-            replay_add_blocker(blocker);
+            replay_add_blocker("-rtc base=localtime");
         } else {
             rtc_base_type = RTC_BASE_DATETIME;
             configure_rtc_base_datetime(value);
softmmu/vl.c +3 -10
index 9177d95d4e..9d324fc6cd 100644
@@ -1855,9 +1855,7 @@ static void qemu_apply_machine_options(QDict *qdict)
     }
 
     if (current_machine->smp.cpus > 1) {
-        Error *blocker = NULL;
-        error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
-        replay_add_blocker(blocker);
+        replay_add_blocker("smp");
     }
 }
 
@@ -2770,13 +2768,8 @@ void qemu_init(int argc, char **argv)
                 drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
                 break;
             case QEMU_OPTION_snapshot:
-                {
-                    Error *blocker = NULL;
-                    snapshot = 1;
-                    error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED,
-                               "-snapshot");
-                    replay_add_blocker(blocker);
-                }
+                snapshot = 1;
+                replay_add_blocker("-snapshot");
                 break;
             case QEMU_OPTION_numa:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
Signature · 1 line
2.39.0
#22 lore raw

Re: [PATCH 09/12] replay: Simplify setting replay blockers

Quoted 27 lines · Markus Armbruster

replay_add_blocker() takes an Error *. All callers pass one created like this:

     error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "some feature");

Folding this into replay_add_blocker() simplifies the callers, losing a bit of generality we haven't needed in more than six years.

Since there are no other uses of macro QERR_REPLAY_NOT_SUPPORTED, replace the remaining one by its expansion, and drop the macro.

---
  include/qapi/qmp/qerror.h |  3 ---
  include/sysemu/replay.h   |  2 +-
  replay/replay.c           |  6 +++++-
  replay/stubs-system.c     |  2 +-
  softmmu/rtc.c             |  5 +----
  softmmu/vl.c              | 13 +++----------
  6 files changed, 11 insertions(+), 20 deletions(-)
replay/replay.c +0 -0
index 9a0dc1cf44..c39156c522 100644

replay/replay.c void replay_finish(void) · line 384

Quoted 10 lines
replay/replay.c +5 -1
@@ -376,8 +376,12 @@ void replay_finish(void)
      replay_mode = REPLAY_MODE_NONE;
  }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
  {
+    Error *reason = NULL;
+
+    error_setg(&reason, "Record/replay feature is not supported for '%s'",
+               feature);

Either name 'feature' as 'cli_option' and use '-%s' in format,

Quoted 38 lines
replay/replay.c +0 -0
      replay_blockers = g_slist_prepend(replay_blockers, reason);
  }
 
replay/stubs-system.c +1 -1
index 5c262b08f1..50cefdb2d6 100644
@@ -12,7 +12,7 @@ void replay_input_sync_event(void)
      qemu_input_event_sync_impl();
  }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
  {
  }
  void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
softmmu/rtc.c +1 -4
index f7114bed7d..4b2bf75dd6 100644
@@ -152,11 +152,8 @@ void configure_rtc(QemuOpts *opts)
          if (!strcmp(value, "utc")) {
              rtc_base_type = RTC_BASE_UTC;
          } else if (!strcmp(value, "localtime")) {
-            Error *blocker = NULL;
              rtc_base_type = RTC_BASE_LOCALTIME;
-            error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED,
-                      "-rtc base=localtime");
-            replay_add_blocker(blocker);
+            replay_add_blocker("-rtc base=localtime");
          } else {
              rtc_base_type = RTC_BASE_DATETIME;
              configure_rtc_base_datetime(value);
softmmu/vl.c +0 -0
index 9177d95d4e..9d324fc6cd 100644

softmmu/vl.c static void qemu_apply_machine_options(QDict *qdict) · line 1858

Quoted 7 lines
softmmu/vl.c +1 -3
@@ -1855,9 +1855,7 @@ static void qemu_apply_machine_options(QDict *qdict)
      }
 
      if (current_machine->smp.cpus > 1) {
-        Error *blocker = NULL;
-        error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
-        replay_add_blocker(blocker);
+        replay_add_blocker("smp");

... or use "-smp" here (yes, pre-existing).

Quoted 2 lines
softmmu/vl.c +0 -0
      }
  }
#23 lore raw

Re: [PATCH 09/12] replay: Simplify setting replay blockers

Quoted 81 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Markus Armbruster

replay_add_blocker() takes an Error *. All callers pass one created like this:

     error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "some feature");

Folding this into replay_add_blocker() simplifies the callers, losing a bit of generality we haven't needed in more than six years.

Since there are no other uses of macro QERR_REPLAY_NOT_SUPPORTED, replace the remaining one by its expansion, and drop the macro.

---
  include/qapi/qmp/qerror.h |  3 ---
  include/sysemu/replay.h   |  2 +-
  replay/replay.c           |  6 +++++-
  replay/stubs-system.c     |  2 +-
  softmmu/rtc.c             |  5 +----
  softmmu/vl.c              | 13 +++----------
  6 files changed, 11 insertions(+), 20 deletions(-)
replay/replay.c +0 -0
index 9a0dc1cf44..c39156c522 100644

replay/replay.c void replay_finish(void) · line 384

Quoted 10 lines
replay/replay.c +5 -1
@@ -376,8 +376,12 @@ void replay_finish(void)
      replay_mode = REPLAY_MODE_NONE;
  }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
  {
+    Error *reason = NULL;
+
+    error_setg(&reason, "Record/replay feature is not supported for '%s'",
+               feature);

Either name 'feature' as 'cli_option' and use '-%s' in format,

Quoted 40 lines
replay/replay.c +0 -0
      replay_blockers = g_slist_prepend(replay_blockers, reason);
  }
 
replay/stubs-system.c +1 -1
index 5c262b08f1..50cefdb2d6 100644
@@ -12,7 +12,7 @@ void replay_input_sync_event(void)
      qemu_input_event_sync_impl();
  }
 
-void replay_add_blocker(Error *reason)
+void replay_add_blocker(const char *feature)
  {
  }
  void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
softmmu/rtc.c +1 -4
index f7114bed7d..4b2bf75dd6 100644
@@ -152,11 +152,8 @@ void configure_rtc(QemuOpts *opts)
          if (!strcmp(value, "utc")) {
              rtc_base_type = RTC_BASE_UTC;
          } else if (!strcmp(value, "localtime")) {
-            Error *blocker = NULL;
              rtc_base_type = RTC_BASE_LOCALTIME;
-            error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED,
-                      "-rtc base=localtime");
-            replay_add_blocker(blocker);
+            replay_add_blocker("-rtc base=localtime");
          } else {
              rtc_base_type = RTC_BASE_DATETIME;
              configure_rtc_base_datetime(value);
softmmu/vl.c +0 -0
index 9177d95d4e..9d324fc6cd 100644
@@ -1855,9 +1855,7 @@ static void qemu_apply_machine_options(QDict *qdict)
      }
 
Quoted 10 lines

softmmu/vl.c static void qemu_apply_machine_options(QDict *qdict) · line 1858

Quoted 5 lines
softmmu/vl.c +1 -3
      if (current_machine->smp.cpus > 1) {
-        Error *blocker = NULL;
-        error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
-        replay_add_blocker(blocker);
+        replay_add_blocker("smp");

... or use "-smp" here (yes, pre-existing).

Quoted 2 lines
softmmu/vl.c +0 -0
      }
  }

This patch doesn't change error messages. If we want to improve some, we should do so in a separate patch.

Let's review the error messages that pass through replay_add_blocker().

0. General format

qemu-system-x86_64: Record/replay: Record/replay feature is not supported for '%s'

Pretty bad. Better:

qemu-system-x86_64: record/replay is not supported %s

Still neglects to identify the erroneous bit of configuration like we do elsewhere, e.g.

    $ qemu-system-x86_64 -device e100
    qemu-system-x86_64: -device e100: 'e100' is not a valid device model name

Let's not worry about that now.

1. SMP

    $ qemu-system-x86_64 -icount shift=auto,rr=record,rrfile=/dev/null -smp 2
    qemu-system-x86_64: Record/replay: Record/replay feature is not supported for 'smp'

First attempt at improvement:

qemu-system-x86_64: record/replay is not supported with -smp

But that's a lie, it works just fine with -smp 1. So:

qemu-system-x86_64: record/replay is not supported with multiple CPUs

2. RTC

    $ qemu-system-x86_64 -icount shift=auto,rr=record,rrfile=/dev/null -rtc base=localtime
    qemu-system-x86_64: Record/replay: Record/replay feature is not supported for '-rtc base=localtime'

Obvious improvement:

qemu-system-x86_64: record/replay is not supported with -rtc base=localtime

Fine, except for the part where we assume where the configuration comes from. Watch this:

    $ cat rtc.cfg
    [rtc]
        base = "localtime"
    $ qemu-system-x86_64 -icount shift=auto,rr=record,rrfile=/dev/null -readconfig rtc.cfg
    qemu-system-x86_64: Record/replay: Record/replay feature is not supported for '-rtc base=localtime'

To make sense of this, user needs to make the connection from "-rtc base=localtime" to what he actually wrote in the configuration file. Let's not worry about that now, either.

3. Snapshot

    $ qemu-system-x86_64 -icount shift=auto,rr=record,rrfile=/dev/null -snapshot
    qemu-system-x86_64: Record/replay: Record/replay feature is not supported for '-snapshot'

Obvious improvement:

qemu-system-x86_64: record/replay is not supported with -snapshot

#24 lore raw

PATCH 10/12 hw/core: Improve the query-hotpluggable-cpus error message

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_FEATURE_DISABLED, and improve the slightly awkward error message

(qemu) info hotpluggable-cpus
Error: The feature 'query-hotpluggable-cpus' is not enabled

to

Error: machine does not support hot-plugging CPUs

---
 hw/core/machine-qmp-cmds.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/core/machine-qmp-cmds.c +1 -2
index a6ed3a63c3..2d904747c0 100644
@@ -16,7 +16,6 @@
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qapi/qapi-commands-machine.h"
-#include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/type-helpers.h"
@@ -141,7 +140,7 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
     if (!mc->has_hotpluggable_cpus) {
-        error_setg(errp, QERR_FEATURE_DISABLED, "query-hotpluggable-cpus");
+        error_setg(errp, "machine does not support hot-plugging CPUs");
         return NULL;
     }
 
Signature · 1 line
2.39.0
#25 lore raw

Re: [PATCH 10/12] hw/core: Improve the query-hotpluggable-cpus error message

Quoted 31 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_FEATURE_DISABLED, and improve the slightly awkward error message

(qemu) info hotpluggable-cpus
Error: The feature 'query-hotpluggable-cpus' is not enabled

to

Error: machine does not support hot-plugging CPUs

---
  hw/core/machine-qmp-cmds.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
hw/core/machine-qmp-cmds.c +0 -1
index a6ed3a63c3..2d904747c0 100644
@@ -16,7 +16,6 @@
  #include "qapi/error.h"
  #include "qapi/qapi-builtin-visit.h"
  #include "qapi/qapi-commands-machine.h"
-#include "qapi/qmp/qerror.h"
  #include "qapi/qmp/qobject.h"
  #include "qapi/qobject-input-visitor.h"
  #include "qapi/type-helpers.h"

hw/core/machine-qmp-cmds.c HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp) · line 143

Quoted 5 lines
hw/core/machine-qmp-cmds.c +1 -1
@@ -141,7 +140,7 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)
      MachineClass *mc = MACHINE_GET_CLASS(ms);
 
      if (!mc->has_hotpluggable_cpus) {
-        error_setg(errp, QERR_FEATURE_DISABLED, "query-hotpluggable-cpus");
+        error_setg(errp, "machine does not support hot-plugging CPUs");

"hotplug CPUs" or "hot-pluggable CPUs"?

Quoted 3 lines
hw/core/machine-qmp-cmds.c +0 -0
          return NULL;
      }
 
#26 lore raw

Re: [PATCH 10/12] hw/core: Improve the query-hotpluggable-cpus error message

Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.
Get rid of a use of QERR_FEATURE_DISABLED, and improve the slightly awkward error message
(qemu) info hotpluggable-cpus
Error: The feature 'query-hotpluggable-cpus' is not enabled
to
Error: machine does not support hot-plugging CPUs

---
  hw/core/machine-qmp-cmds.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
hw/core/machine-qmp-cmds.c +0 -1
index a6ed3a63c3..2d904747c0 100644
@@ -16,7 +16,6 @@
  #include "qapi/error.h"
  #include "qapi/qapi-builtin-visit.h"
  #include "qapi/qapi-commands-machine.h"
-#include "qapi/qmp/qerror.h"
  #include "qapi/qmp/qobject.h"
  #include "qapi/qobject-input-visitor.h"
Quoted 8 lines

hw/core/machine-qmp-cmds.c HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp) · line 142

Quoted 6 lines
hw/core/machine-qmp-cmds.c +1 -1
  #include "qapi/type-helpers.h"
@@ -141,7 +140,7 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)
      MachineClass *mc = MACHINE_GET_CLASS(ms);
        if (!mc->has_hotpluggable_cpus) {
-        error_setg(errp, QERR_FEATURE_DISABLED, "query-hotpluggable-cpus");
+        error_setg(errp, "machine does not support hot-plugging CPUs");

"hotplug CPUs" or "hot-pluggable CPUs"?

I think "hotplug CPUs" is strictly worse than "hotpluggable CPUs", because "hotpluggable" is an adjective, while "hotplug" is not.

I slightly prefer "does not support hot-plugging CPUs" over "does not support hot-pluggable CPUs".

As always, I'm happy to take advice from native speakers :)

Quoted 4 lines
Quoted 4 lines
hw/core/machine-qmp-cmds.c +0 -0
          return NULL;
      }
 
#27 lore raw

PATCH 11/12 migration/colo: Improve an x-colo-lost-heartbeat error message

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_FEATURE_DISABLED, and improve the somewhat imprecise error message

(qemu) x_colo_lost_heartbeat
Error: The feature 'colo' is not enabled

to

Error: VM is not in COLO mode

---
 migration/colo-failover.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/colo-failover.c +1 -2
index 42453481c4..6cb6f90357 100644
@@ -17,7 +17,6 @@
 #include "migration.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-migration.h"
-#include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "trace.h"
 
@@ -78,7 +77,7 @@ FailoverStatus failover_get_state(void)
 void qmp_x_colo_lost_heartbeat(Error **errp)
 {
     if (get_colo_mode() == COLO_MODE_NONE) {
-        error_setg(errp, QERR_FEATURE_DISABLED, "colo");
+        error_setg(errp, "VM is not in COLO mode");
         return;
     }
 
Signature · 1 line
2.39.0
Reviewed-by on v1 11/12
#28 lore raw

Re: [PATCH 11/12] migration/colo: Improve an x-colo-lost-heartbeat error message

Quoted 6 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_FEATURE_DISABLED, and improve the somewhat imprecise error message

Quoted 8 lines

(qemu) x_colo_lost_heartbeat
Error: The feature 'colo' is not enabled

to

Error: VM is not in COLO mode

Althought in this case which error message is better is not so clear. Colo mode is compiled in, but it is not being "enabled".

Later, Juan.

#29 lore raw

Re: [PATCH 11/12] migration/colo: Improve an x-colo-lost-heartbeat error message

Quoted 12 lines · Juan Quintela
Quoted 11 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

Get rid of a use of QERR_FEATURE_DISABLED, and improve the somewhat imprecise error message

(qemu) x_colo_lost_heartbeat
Error: The feature 'colo' is not enabled

to

Quoted 8 lines
Quoted 3 lines

Error: VM is not in COLO mode

Althought in this case which error message is better is not so clear. Colo mode is compiled in, but it is not being "enabled".

In my new error message, I tried to convey that it is about the state of the VM, not the state of the QEMU binary.

#30 lore raw

PATCH 12/12 rocker: Tweak stubbed out monitor commands' error messages

In reply to Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

The stubbed out Rocker monitor commands are the last remaining users of QERR_FEATURE_DISABLED. They fail like this:

(qemu) info rocker mumble
Error: The feature 'rocker' is not enabled

The real rocker commands fail like this when the named object doesn't exist:

Error: rocker mumble not found

If that's good enough when Rocker is enabled, then it's good enough when it's disabled, so replace QERR_FEATURE_DISABLED with that, and drop the macro.

---
 include/qapi/qmp/qerror.h    |  3 ---
 hw/net/rocker/qmp-norocker.c | 12 +++++-------
 2 files changed, 5 insertions(+), 10 deletions(-)
include/qapi/qmp/qerror.h +0 -3
index 09006e69f7..8dd9fcb071 100644
@@ -29,9 +29,6 @@
 #define QERR_DEVICE_NO_HOTPLUG \
     "Device '%s' does not support hotplugging"
 
-#define QERR_FEATURE_DISABLED \
-    "The feature '%s' is not enabled"
-
 #define QERR_INVALID_PARAMETER \
     "Invalid parameter '%s'"
 
hw/net/rocker/qmp-norocker.c +5 -7
index 5ef4f9324c..f6c1196a24 100644
@@ -1,6 +1,5 @@
 /*
- * QMP Target options - Commands handled based on a target config
- *                      versus a host config
+ * QMP command stubs
  *
  * Copyright (c) 2015 David Ahern <[email protected]>
  *
@@ -18,17 +17,16 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-rocker.h"
-#include "qapi/qmp/qerror.h"
 
 RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
 {
-    error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
+    error_setg(errp, "rocker %s not found", name);
     return NULL;
 };
 
 RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp)
 {
-    error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
+    error_setg(errp, "rocker %s not found", name);
     return NULL;
 };
 
@@ -37,7 +35,7 @@ RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
                                                    uint32_t tbl_id,
                                                    Error **errp)
 {
-    error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
+    error_setg(errp, "rocker %s not found", name);
     return NULL;
 };
 
@@ -46,6 +44,6 @@ RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
                                                      uint8_t type,
                                                      Error **errp)
 {
-    error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
+    error_setg(errp, "rocker %s not found", name);
     return NULL;
 };
Signature · 1 line
2.39.0
Reviewed-by on v1 12/12
#31 lore raw

Re: [PATCH 12/12] rocker: Tweak stubbed out monitor commands' error messages

Quoted 12 lines · Markus Armbruster

The QERR_ macros are leftovers from the days of "rich" error objects. We've been trying to reduce their remaining use.

The stubbed out Rocker monitor commands are the last remaining users of QERR_FEATURE_DISABLED. They fail like this:

(qemu) info rocker mumble
Error: The feature 'rocker' is not enabled

The real rocker commands fail like this when the named object doesn't exist:

Quoted 7 lines

Error: rocker mumble not found

If that's good enough when Rocker is enabled, then it's good enough when it's disabled, so replace QERR_FEATURE_DISABLED with that, and drop the macro.

Reviewed-by on the v1 series
#32 lore raw
In reply to Markus Armbruster
Quoted 16 lines · Markus Armbruster

This series gets rid of two out of 15 remaining QERR_ macros and confines use of one more to qga/. Bonus: better error messages.

Markus Armbruster (12):
error: Drop superfluous #include "qapi/qmp/qerror.h"
dump: Improve error message when target doesn't support memory dump
dump: Assert cpu_get_note_size() can't fail
hw/core: Improve error message when machine doesn't provide NMIs hw/smbios: Dumb down smbios_entry_add() stub
hw/acpi: Dumb down acpi_table_add() stub
hw/acpi: Move QMP command to hw/core/
qga: Drop dangling reference to QERR_QGA_LOGGING_DISABLED
replay: Simplify setting replay blockers
hw/core: Improve the query-hotpluggable-cpus error message migration/colo: Improve an x-colo-lost-heartbeat error message
rocker: Tweak stubbed out monitor commands' error messages

Series: