Skip to contentSkip to conversation

qom: Let ObjectPropertyGet functions return a boolean value

RFC In review Philippe Mathieu-Daudé 3 participants 15 messages Jul 15, 2020 – Sep 7, 2020

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

cover qom: Let ObjectPropertyGet functions return a boolean value

RFC series to follow Markus direction to simplify error propagation. Not sure it is worth it yet. It starts to be interesting when using the QEMU_WARN_UNUSED_RESULT attribute in the visitors, such:

-- >8 --
@@ -525,6 +533,7 @@ bool visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
* Visit a uint16_t value.
* Like visit_type_int(), except clamps the value to uint16_t range. */
+QEMU_WARN_UNUSED_RESULT
bool visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,

                        Error **errp);

---

But to get there we need to update the QAPI generators first :)

Philippe Mathieu-Daudé (5):
hw/core/qdev-properties: Simplify get_reserved_region()
qom: Split ObjectPropertyAccessor as ObjectProperty[Get/Set]
qom: Use g_autofree in ObjectPropertyGet functions
qom: Let ObjectPropertyGet functions return a boolean value hw/virtio: Simplify virtio_mem_set_requested_size()

 include/hw/qdev-core.h           |   4 +-
 include/qom/object.h             |  50 +++++++++-----
 accel/kvm/kvm-all.c              |   4 +-
 accel/tcg/tcg-all.c              |   4 +-
 authz/list.c                     |   4 +-
 backends/cryptodev.c             |   4 +-
 backends/hostmem-file.c          |   4 +-
 backends/hostmem-memfd.c         |   4 +-
 backends/hostmem.c               |  13 ++--
 backends/tpm/tpm_util.c          |   7 +-
 block/throttle-groups.c          |   8 +--
 bootdevice.c                     |   4 +-
 chardev/char-socket.c            |   4 +-
 crypto/secret_keyring.c          |   5 +-
 hw/acpi/ich9.c                   |   4 +-
 hw/arm/virt.c                    |   4 +-
 hw/block/xen-block.c             |   9 ++-
 hw/core/machine.c                |   4 +-
 hw/core/qdev-properties-system.c |  33 +++++----
 hw/core/qdev-properties.c        |  89 ++++++++++++------------
 hw/core/qdev.c                   |   5 +-
 hw/cpu/core.c                    |   8 +--
 hw/gpio/aspeed_gpio.c            |   8 +--
 hw/i386/microvm.c                |  12 ++--
 hw/i386/pc.c                     |  12 ++--
 hw/i386/x86.c                    |   8 +--
 hw/ide/qdev.c                    |   4 +-
 hw/intc/apic_common.c            |   4 +-
 hw/mem/nvdimm.c                  |  11 ++-
 hw/mem/pc-dimm.c                 |   6 +-
 hw/misc/aspeed_sdmc.c            |   4 +-
 hw/misc/pca9552.c                |   8 +--
 hw/misc/tmp105.c                 |   4 +-
 hw/misc/tmp421.c                 |   8 +--
 hw/net/ne2000-isa.c              |   4 +-
 hw/pci-host/i440fx.c             |  16 ++---
 hw/pci-host/q35.c                |  16 ++---
 hw/ppc/spapr_caps.c              |  21 +++---
 hw/ppc/spapr_drc.c               |  21 +++---
 hw/riscv/sifive_u.c              |   4 +-
 hw/s390x/css.c                   |   4 +-
 hw/s390x/s390-pci-bus.c          |   4 +-
 hw/usb/dev-storage.c             |   4 +-
 hw/vfio/pci-quirks.c             |  14 ++--
 hw/virtio/virtio-balloon.c       |  16 +++--
 hw/virtio/virtio-mem.c           |  17 ++---
 iothread.c                       |   4 +-
 net/colo-compare.c               |   8 +--
 net/dump.c                       |   4 +-
 net/filter-buffer.c              |   4 +-
 qom/object.c                     | 115 ++++++++++++++++---------------
 softmmu/memory.c                 |  14 ++--
 target/arm/cpu64.c               |  14 ++--
 target/i386/cpu.c                |  48 ++++++++-----
 target/ppc/compat.c              |   4 +-
 target/s390x/cpu.c               |  11 +--
 target/s390x/cpu_models.c        |  14 ++--
 target/sparc/cpu.c               |   4 +-
 58 files changed, 397 insertions(+), 352 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/5 hw/core/qdev-properties: Simplify get_reserved_region()

Use the safer g_strdup_printf() over snprintf() + abort().

---
 hw/core/qdev-properties.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/core/qdev-properties.c +3 -6
index 098298c78e..d5f5aa150b 100644
@@ -581,13 +581,10 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
-    char buffer[64];
-    char *p = buffer;
-    int rc;
+    g_autofree char *p;
 
-    rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
-                  rr->low, rr->high, rr->type);
-    assert(rc < sizeof(buffer));
+    p = g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u",
+                        rr->low, rr->high, rr->type);
 
     visit_type_str(v, name, &p, errp);
 }
Signature · 1 line
2.21.3
#2 lore raw

Re: [PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region()

Quoted 18 lines · Philippe Mathieu-Daudé

Use the safer g_strdup_printf() over snprintf() + abort().

---
 hw/core/qdev-properties.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/core/qdev-properties.c +0 -3
index 098298c78e..d5f5aa150b 100644
@@ -581,13 +581,10 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
-    char buffer[64];
-    char *p = buffer;
-    int rc;

hw/core/qdev-properties.c static void get_reserved_region(Object *obj, Visitor *v, const char *name, · line 590

Quoted 10 lines
hw/core/qdev-properties.c +3 -3
+    g_autofree char *p;
 
-    rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
-                  rr->low, rr->high, rr->type);
-    assert(rc < sizeof(buffer));
+    p = g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u",
+                        rr->low, rr->high, rr->type);
 
     visit_type_str(v, name, &p, errp);
 }

I don't buy "safer" (the old code is already safe). I could buy "simpler".

It's also less efficient, but that shouldn't matter in a property getter.

#3 lore raw

Re: [PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region()

Quoted 28 lines · Markus Armbruster
Quoted 26 lines · Philippe Mathieu-Daudé

Use the safer g_strdup_printf() over snprintf() + abort().

---
 hw/core/qdev-properties.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/core/qdev-properties.c +3 -6
index 098298c78e..d5f5aa150b 100644
@@ -581,13 +581,10 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
-    char buffer[64];
-    char *p = buffer;
-    int rc;
+    g_autofree char *p;
 
-    rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
-                  rr->low, rr->high, rr->type);
-    assert(rc < sizeof(buffer));
+    p = g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u",
+                        rr->low, rr->high, rr->type);
 
Quoted 4 lines

hw/core/qdev-properties.c static void get_reserved_region(Object *obj, Visitor *v, const char *name, · line 590

Quoted 2 lines
hw/core/qdev-properties.c +0 -0
     visit_type_str(v, name, &p, errp);
 }

I don't buy "safer" (the old code is already safe).

I'm suspicious when I find an assert/abort in a code reachable by management interface, as IIUC we don't want to crash the process. I agree this shouldn't happen and if it happens we are screwed anyway.

Quoted 5 lines

I could buy
"simpler".

It's also less efficient, but that shouldn't matter in a property getter.

If we want more efficient code, we should replace all the g_strdup_printf() calls by snprintf() + assert() in the places where we don't expect failure. This seems counterproductive from a maintenance PoV. At some point we should make a decision and not allow more than 3 similar APIs at a time. We have been recommended to use GLib instead of snprintf() because it is "safer". Can we be consistent with recommendations? Else we should stop recommending to use GLib and friends.

Thanks,

Phil.

#4 lore raw

Re: [PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region()

Quoted 42 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Markus Armbruster
Quoted 26 lines · Philippe Mathieu-Daudé

Use the safer g_strdup_printf() over snprintf() + abort().

---
 hw/core/qdev-properties.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/core/qdev-properties.c +3 -6
index 098298c78e..d5f5aa150b 100644
@@ -581,13 +581,10 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
-    char buffer[64];
-    char *p = buffer;
-    int rc;
+    g_autofree char *p;
 
-    rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
-                  rr->low, rr->high, rr->type);
-    assert(rc < sizeof(buffer));
+    p = g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u",
+                        rr->low, rr->high, rr->type);
 
Quoted 4 lines

hw/core/qdev-properties.c static void get_reserved_region(Object *obj, Visitor *v, const char *name, · line 590

Quoted 2 lines
hw/core/qdev-properties.c +0 -0
     visit_type_str(v, name, &p, errp);
 }

I don't buy "safer" (the old code is already safe).

I'm suspicious when I find an assert/abort in a code reachable by management interface, as IIUC we don't want to crash the process. I agree this shouldn't happen and if it happens we are screwed anyway.

Quoted 3 lines

I could buy
"simpler".

Quoted 7 lines
Quoted 2 lines

It's also less efficient, but that shouldn't matter in a property getter.

If we want more efficient code, we should replace all the g_strdup_printf() calls by snprintf() + assert() in the places where we don't expect failure. This seems counterproductive from a maintenance PoV.

Mind, I'm not opposed to your patch. I just find the commit message's rationale misleading. Your patch doesn't make the code safer (it already is). It does make it simpler.

Quoted 5 lines

At some point we should make a decision and
not allow more than 3 similar APIs at a time. We have been recommended to use GLib instead of snprintf() because it is "safer". Can we be consistent with recommendations? Else we should stop recommending to use GLib and friends.

We recommend g_strdup_printf() over snprintf() because it's easier to use correctly, and usually easier to read.

Incorrect use of snprintf() is commonly unsafe. Correct use of snprintf() is safe, but commonly less readable than the equivalent g_strdup_printf(). snprintf()'s efficiency advantage rarely matters.

#5 lore raw

RFC 2/5 qom: Split ObjectPropertyAccessor as ObjectProperty[Get/Set]

In reply to Philippe Mathieu-Daudé

To make refactors easier, split the common ObjectPropertyAccessor type definition into ObjectPropertyGet() and ObjectPropertySet().

---
 include/hw/qdev-core.h |  4 ++--
 include/qom/object.h   | 48 ++++++++++++++++++++++++++++--------------
 hw/ppc/spapr_caps.c    |  4 ++--
 qom/object.c           | 44 +++++++++++++++++++-------------------
 4 files changed, 58 insertions(+), 42 deletions(-)
include/hw/qdev-core.h +2 -2
index fe78073c70..e2930beab8 100644
@@ -287,8 +287,8 @@ struct PropertyInfo {
     int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
     void (*set_default_value)(ObjectProperty *op, const Property *prop);
     void (*create)(ObjectClass *oc, Property *prop);
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
+    ObjectPropertyGet *get;
+    ObjectPropertySet *set;
     ObjectPropertyRelease *release;
 };
 
include/qom/object.h +32 -16

84 lines not on this page · raw message

hw/ppc/spapr_caps.c +2 -2
index 3225fc5a2e..7558db0c8b 100644
@@ -58,8 +58,8 @@ typedef struct SpaprCapabilityInfo {
     int index;
 
     /* Getter and Setter Function Pointers */
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
+    ObjectPropertyGet *get;
+    ObjectPropertySet *set;
     const char *type;
     /* Possible values if this is a custom string type */
     SpaprCapPossible *possible;
qom/object.c +22 -22

110 lines not on this page · raw message

Signature · 1 line
2.21.3
#6 lore raw

PATCH 3/5 qom: Use g_autofree in ObjectPropertyGet functions

In reply to Philippe Mathieu-Daudé

By using g_autofree we make it easier to have ObjectPropertyGet methods return a value (see next commit).

---
 backends/tpm/tpm_util.c          |  3 +--
 hw/block/xen-block.c             |  3 +--
 hw/core/qdev-properties-system.c | 13 +++++--------
 hw/mem/nvdimm.c                  |  3 +--
 hw/ppc/spapr_caps.c              |  3 +--
 qom/object.c                     |  6 ++----
 6 files changed, 11 insertions(+), 20 deletions(-)
backends/tpm/tpm_util.c +1 -2
index b58d298c1a..235b006498 100644
@@ -37,11 +37,10 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     TPMBackend **be = qdev_get_prop_ptr(dev, opaque);
-    char *p;
+    g_autofree char *p;
 
     p = g_strdup(*be ? (*be)->id : "");
     visit_type_str(v, name, &p, errp);
-    g_free(p);
 }
 
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
hw/block/xen-block.c +1 -2
index 8a7a3f5452..8c23b895d9 100644
@@ -338,7 +338,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
-    char *str;
+    g_autofree char *str = NULL;
 
     switch (vdev->type) {
     case XEN_BLOCK_VDEV_TYPE_DP:
@@ -366,7 +366,6 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
     }
 
     visit_type_str(v, name, &str, errp);
-    g_free(str);
 }
 
 static int vbd_name_to_disk(const char *name, const char **endp,
hw/core/qdev-properties-system.c +5 -8
index 3e4f16fc21..28682eda31 100644
@@ -56,7 +56,7 @@ static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
     Property *prop = opaque;
     void **ptr = qdev_get_prop_ptr(dev, prop);
     const char *value;
-    char *p;
+    g_autofree char *p;
 
     if (*ptr) {
         value = blk_name(*ptr);
@@ -72,7 +72,6 @@ static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
 
     p = g_strdup(value);
     visit_type_str(v, name, &p, errp);
-    g_free(p);
 }
 
 static void set_drive_helper(Object *obj, Visitor *v, const char *name,
@@ -213,11 +212,10 @@ static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     CharBackend *be = qdev_get_prop_ptr(dev, opaque);
-    char *p;
+    g_autofree char *p;
 
     p = g_strdup(be->chr && be->chr->label ? be->chr->label : "");
     visit_type_str(v, name, &p, errp);
-    g_free(p);
 }
 
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
@@ -287,10 +285,10 @@ static void get_netdev(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
-    char *p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
+    g_autofree char *p;
 
+    p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
     visit_type_str(v, name, &p, errp);
-    g_free(p);
 }
 
 static void set_netdev(Object *obj, Visitor *v, const char *name,
@@ -367,10 +365,9 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
-    char *p = g_strdup(audio_get_id(card));
+    g_autofree char *p = g_strdup(audio_get_id(card));
 
     visit_type_str(v, name, &p, errp);
-    g_free(p);
 }
 
 static void set_audiodev(Object *obj, Visitor *v, const char* name,
hw/mem/nvdimm.c +1 -2
index d0d6e553cf..b55de7dbe1 100644
@@ -69,12 +69,11 @@ static void nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     NVDIMMDevice *nvdimm = NVDIMM(obj);
-    char *value = NULL;
+    g_autofree char *value = NULL;
 
     value = qemu_uuid_unparse_strdup(&nvdimm->uuid);
 
     visit_type_str(v, name, &value, errp);
-    g_free(value);
 }
 
 
hw/ppc/spapr_caps.c +1 -2
index 7558db0c8b..cbc09b24b6 100644
@@ -101,7 +101,7 @@ static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
 {
     SpaprCapabilityInfo *cap = opaque;
     SpaprMachineState *spapr = SPAPR_MACHINE(obj);
-    char *val = NULL;
+    g_autofree char *val = NULL;
     uint8_t value = spapr_get_cap(spapr, cap->index);
 
     if (value >= cap->possible->num) {
@@ -112,7 +112,6 @@ static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
     val = g_strdup(cap->possible->vals[value]);
 
     visit_type_str(v, name, &val, errp);
-    g_free(val);
 }
 
 static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
qom/object.c +2 -4
index e5324f2af7..7c13117f7d 100644
@@ -1649,11 +1649,10 @@ static void object_get_child_property(Object *obj, Visitor *v,
                                       Error **errp)
 {
     Object *child = opaque;
-    char *path;
+    g_autofree char *path;
 
     path = object_get_canonical_path(child);
     visit_type_str(v, name, &path, errp);
-    g_free(path);
 }
 
 static Object *object_resolve_child_property(Object *parent, void *opaque,
@@ -2099,7 +2098,7 @@ static void property_get_str(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     StringProperty *prop = opaque;
-    char *value;
+    g_autofree char *value = NULL;
     Error *err = NULL;
 
     value = prop->get(obj, &err);
@@ -2109,7 +2108,6 @@ static void property_get_str(Object *obj, Visitor *v, const char *name,
     }
 
     visit_type_str(v, name, &value, errp);
-    g_free(value);
 }
 
 static void property_set_str(Object *obj, Visitor *v, const char *name,
Signature · 1 line
2.21.3
#7 lore raw

RFC 4/5 qom: Let ObjectPropertyGet functions return a boolean value

In reply to Philippe Mathieu-Daudé

Commits 1c94a35164..7b3cb8037c simplified the error propagation.

Similarly to commit 73ac1aac39 ("qdev: Make functions taking Error ** return bool, not void") let the ObjectPropertyGet functions return a boolean value, not void.

See commit e3fe3988d7 ("error: Document Error API usage rules") for rationale.

---
Sorry I don't see how to split that patch without using ugly casts in the middle.

---
 include/qom/object.h             |  4 +-
 accel/kvm/kvm-all.c              |  4 +-
 accel/tcg/tcg-all.c              |  4 +-
 authz/list.c                     |  4 +-
 backends/cryptodev.c             |  4 +-
 backends/hostmem-file.c          |  4 +-
 backends/hostmem-memfd.c         |  4 +-
 backends/hostmem.c               | 13 +++---
 backends/tpm/tpm_util.c          |  4 +-
 block/throttle-groups.c          |  8 ++--
 bootdevice.c                     |  4 +-
 chardev/char-socket.c            |  4 +-
 crypto/secret_keyring.c          |  5 +-
 hw/acpi/ich9.c                   |  4 +-
 hw/arm/virt.c                    |  4 +-
 hw/block/xen-block.c             |  6 +--
 hw/core/machine.c                |  4 +-
 hw/core/qdev-properties-system.c | 20 ++++----
 hw/core/qdev-properties.c        | 80 ++++++++++++++++----------------
 hw/core/qdev.c                   |  5 +-
 hw/cpu/core.c                    |  8 ++--
 hw/gpio/aspeed_gpio.c            |  8 ++--
 hw/i386/microvm.c                | 12 ++---
 hw/i386/pc.c                     | 12 ++---
 hw/i386/x86.c                    |  8 ++--
 hw/ide/qdev.c                    |  4 +-
 hw/intc/apic_common.c            |  4 +-
 hw/mem/nvdimm.c                  |  8 ++--
 hw/mem/pc-dimm.c                 |  6 +--
 hw/misc/aspeed_sdmc.c            |  4 +-
 hw/misc/pca9552.c                |  8 ++--
 hw/misc/tmp105.c                 |  4 +-
 hw/misc/tmp421.c                 |  8 ++--
 hw/net/ne2000-isa.c              |  4 +-
 hw/pci-host/i440fx.c             | 16 +++----
 hw/pci-host/q35.c                | 16 +++----
 hw/ppc/spapr_caps.c              | 14 +++---
 hw/ppc/spapr_drc.c               | 21 +++++----
 hw/riscv/sifive_u.c              |  4 +-
 hw/s390x/css.c                   |  4 +-
 hw/s390x/s390-pci-bus.c          |  4 +-
 hw/usb/dev-storage.c             |  4 +-
 hw/vfio/pci-quirks.c             | 14 +++---
 hw/virtio/virtio-balloon.c       | 16 ++++---
 hw/virtio/virtio-mem.c           | 12 ++---
 iothread.c                       |  4 +-
 net/colo-compare.c               |  8 ++--
 net/dump.c                       |  4 +-
 net/filter-buffer.c              |  4 +-
 qom/object.c                     | 65 +++++++++++++++-----------
 softmmu/memory.c                 | 14 +++---
 target/arm/cpu64.c               | 14 +++---
 target/i386/cpu.c                | 48 +++++++++++--------
 target/ppc/compat.c              |  4 +-
 target/s390x/cpu.c               | 11 +++--
 target/s390x/cpu_models.c        | 14 +++---
 target/sparc/cpu.c               |  4 +-
 57 files changed, 325 insertions(+), 281 deletions(-)
include/qom/object.h +3 -1
index e9496ba970..7ba2172932 100644
@@ -333,9 +333,11 @@ typedef void (ObjectPropertySet)(Object *obj,
  * @opaque: the object property opaque
  * @errp: a pointer to an Error that is filled if getting fails.
  *
+ * Return true on success, false on failure.
+ *
  * Called when trying to get a property.
  */
-typedef void (ObjectPropertyGet)(Object *obj,
+typedef bool (ObjectPropertyGet)(Object *obj,
                                  Visitor *v,
                                  const char *name,
                                  void *opaque,
accel/kvm/kvm-all.c +2 -2
index 63ef6af9a1..dfbc60fd6f 100644
@@ -3098,14 +3098,14 @@ static bool kvm_accel_has_memory(MachineState *ms, AddressSpace *as,
     return false;
 }
 
-static void kvm_get_kvm_shadow_mem(Object *obj, Visitor *v,
+static bool kvm_get_kvm_shadow_mem(Object *obj, Visitor *v,
                                    const char *name, void *opaque,
                                    Error **errp)
 {
     KVMState *s = KVM_STATE(obj);
     int64_t value = s->kvm_shadow_mem;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v,
accel/tcg/tcg-all.c +2 -2
index eace2c113b..114c149744 100644
@@ -167,14 +167,14 @@ static void tcg_set_thread(Object *obj, const char *value, Error **errp)
     }
 }
 
-static void tcg_get_tb_size(Object *obj, Visitor *v,
+static bool tcg_get_tb_size(Object *obj, Visitor *v,
                             const char *name, void *opaque,
                             Error **errp)
 {
     TCGState *s = TCG_STATE(obj);
     uint32_t value = s->tb_size;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void tcg_set_tb_size(Object *obj, Visitor *v,
authz/list.c +2 -2
index 8e904bfc93..9a195defab 100644
@@ -83,13 +83,13 @@ qauthz_list_prop_get_policy(Object *obj,
 }
 
 
-static void
+static bool
 qauthz_list_prop_get_rules(Object *obj, Visitor *v, const char *name,
                            void *opaque, Error **errp)
 {
     QAuthZList *lauthz = QAUTHZ_LIST(obj);
 
-    visit_type_QAuthZListRuleList(v, name, &lauthz->rules, errp);
+    return visit_type_QAuthZListRuleList(v, name, &lauthz->rules, errp);
 }
 
 static void
backends/cryptodev.c +2 -2
index ada4ebe78b..e0c5aa61ac 100644
@@ -139,14 +139,14 @@ int cryptodev_backend_crypto_operation(
     return -VIRTIO_CRYPTO_ERR;
 }
 
-static void
+static bool
 cryptodev_backend_get_queues(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
     uint32_t value = backend->conf.peers.queues;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void
backends/hostmem-file.c +2 -2
index 5b819020b4..2a1e0e8dc5 100644
@@ -94,14 +94,14 @@ static void file_memory_backend_set_discard_data(Object *o, bool value,
     MEMORY_BACKEND_FILE(o)->discard_data = value;
 }
 
-static void file_memory_backend_get_align(Object *o, Visitor *v,
+static bool file_memory_backend_get_align(Object *o, Visitor *v,
                                           const char *name, void *opaque,
                                           Error **errp)
 {
     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
     uint64_t val = fb->align;
 
-    visit_type_size(v, name, &val, errp);
+    return visit_type_size(v, name, &val, errp);
 }
 
 static void file_memory_backend_set_align(Object *o, Visitor *v,
backends/hostmem-memfd.c +2 -2
index 4c040a7541..278bdb3308 100644
@@ -95,14 +95,14 @@ memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name,
     m->hugetlbsize = value;
 }
 
-static void
+static bool
 memfd_backend_get_hugetlbsize(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
     HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(obj);
     uint64_t value = m->hugetlbsize;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static bool
backends/hostmem.c +7 -6
index c614f1bdc1..230a76571d 100644
@@ -39,14 +39,14 @@ host_memory_backend_get_name(HostMemoryBackend *backend)
     return object_get_canonical_path(OBJECT(backend));
 }
 
-static void
+static bool
 host_memory_backend_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
     uint64_t value = backend->size;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static void
@@ -74,7 +74,7 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name,
     backend->size = value;
 }
 
-static void
+static bool
 host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
@@ -104,7 +104,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
     } while (true);
 
 ret:
-    visit_type_uint16List(v, name, &host_nodes, errp);
+    return visit_type_uint16List(v, name, &host_nodes, errp);
 }
 
 static void
@@ -239,11 +239,12 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
     }
 }
 
-static void host_memory_backend_get_prealloc_threads(Object *obj, Visitor *v,
+static bool host_memory_backend_get_prealloc_threads(Object *obj, Visitor *v,
     const char *name, void *opaque, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
-    visit_type_uint32(v, name, &backend->prealloc_threads, errp);
+
+    return visit_type_uint32(v, name, &backend->prealloc_threads, errp);
 }
 
 static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v,
backends/tpm/tpm_util.c +2 -2
index 235b006498..66103b8d63 100644
@@ -32,7 +32,7 @@
 
 /* tpm backend property */
 
-static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
+static bool get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -40,7 +40,7 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
     g_autofree char *p;
 
     p = g_strdup(*be ? (*be)->id : "");
-    visit_type_str(v, name, &p, errp);
+    return visit_type_str(v, name, &p, errp);
 }
 
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
block/throttle-groups.c +4 -4
index 03a53c89ea..8d5fd02b1d 100644
@@ -852,7 +852,7 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
     }
 }
 
-static void throttle_group_get(Object *obj, Visitor *v, const char *name,
+static bool throttle_group_get(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     ThrottleGroup *tg = THROTTLE_GROUP(obj);
@@ -876,7 +876,7 @@ static void throttle_group_get(Object *obj, Visitor *v, const char *name,
         break;
     }
 
-    visit_type_int64(v, name, &value, errp);
+    return visit_type_int64(v, name, &value, errp);
 }
 
 static void throttle_group_set_limits(Object *obj, Visitor *v,
@@ -907,7 +907,7 @@ unlock:
     return;
 }
 
-static void throttle_group_get_limits(Object *obj, Visitor *v,
+static bool throttle_group_get_limits(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
                                       Error **errp)
 {
@@ -922,7 +922,7 @@ static void throttle_group_get_limits(Object *obj, Visitor *v,
 
     throttle_config_to_limits(&cfg, argp);
 
-    visit_type_ThrottleLimits(v, name, &argp, errp);
+    return visit_type_ThrottleLimits(v, name, &argp, errp);
 }
 
 static bool throttle_group_can_be_deleted(UserCreatable *uc)
bootdevice.c +2 -2
index add4e3d2d1..227c183c06 100644
@@ -283,11 +283,11 @@ typedef struct {
     DeviceState *dev;
 } BootIndexProperty;
 
-static void device_get_bootindex(Object *obj, Visitor *v, const char *name,
+static bool device_get_bootindex(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
     BootIndexProperty *prop = opaque;
-    visit_type_int32(v, name, prop->bootindex, errp);
+    return visit_type_int32(v, name, prop->bootindex, errp);
 }
 
 static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
chardev/char-socket.c +2 -2
index ef62dbf3d7..12468dbba1 100644
@@ -1462,13 +1462,13 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
     sock->addr = addr;
 }
 
-static void
+static bool
 char_socket_get_addr(Object *obj, Visitor *v, const char *name,
                      void *opaque, Error **errp)
 {
     SocketChardev *s = SOCKET_CHARDEV(obj);
 
-    visit_type_SocketAddress(v, name, &s->addr, errp);
+    return visit_type_SocketAddress(v, name, &s->addr, errp);
 }
 
 static bool
crypto/secret_keyring.c +3 -2
index 8bfc58ebf4..55459aab0b 100644
@@ -91,14 +91,15 @@ qcrypto_secret_prop_set_key(Object *obj, Visitor *v,
 }
 
 
-static void
+static bool
 qcrypto_secret_prop_get_key(Object *obj, Visitor *v,
                             const char *name, void *opaque,
                             Error **errp)
 {
     QCryptoSecretKeyring *secret = QCRYPTO_SECRET_KEYRING(obj);
     int32_t value = secret->serial;
-    visit_type_int32(v, name, &value, errp);
+
+    return visit_type_int32(v, name, &value, errp);
 }
 
 
hw/acpi/ich9.c +2 -2
index 6a19070cec..93d48231ba 100644
@@ -313,13 +313,13 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     }
 }
 
-static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
+static bool ich9_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
     ICH9LPCPMRegs *pm = opaque;
     uint32_t value = pm->pm_io_base + ICH9_PMIO_GPE0_STS;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static bool ich9_pm_get_memory_hotplug_support(Object *obj, Error **errp)
hw/arm/virt.c +2 -2
index 9005dae356..3282e1fc3a 100644
@@ -2030,13 +2030,13 @@ bool virt_is_acpi_enabled(VirtMachineState *vms)
     return true;
 }
 
-static void virt_get_acpi(Object *obj, Visitor *v, const char *name,
+static bool virt_get_acpi(Object *obj, Visitor *v, const char *name,
                           void *opaque, Error **errp)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
     OnOffAuto acpi = vms->acpi;
 
-    visit_type_OnOffAuto(v, name, &acpi, errp);
+    return visit_type_OnOffAuto(v, name, &acpi, errp);
 }
 
 static void virt_set_acpi(Object *obj, Visitor *v, const char *name,
hw/block/xen-block.c +3 -3
index 8c23b895d9..49b2133efc 100644
@@ -332,7 +332,7 @@ static char *disk_to_vbd_name(unsigned int disk)
     return name;
 }
 
-static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
+static bool xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -362,10 +362,10 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
     }
     default:
         error_setg(errp, "invalid vdev type");
-        return;
+        return false;
     }
 
-    visit_type_str(v, name, &str, errp);
+    return visit_type_str(v, name, &str, errp);
 }
 
 static int vbd_name_to_disk(const char *name, const char **endp,
hw/core/machine.c +2 -2
index eb267b828d..af4279c6b7 100644
@@ -275,14 +275,14 @@ static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
     ms->dumpdtb = g_strdup(value);
 }
 
-static void machine_get_phandle_start(Object *obj, Visitor *v,
+static bool machine_get_phandle_start(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
                                       Error **errp)
 {
     MachineState *ms = MACHINE(obj);
     int64_t value = ms->phandle_start;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void machine_set_phandle_start(Object *obj, Visitor *v,
hw/core/qdev-properties-system.c +11 -9
index 28682eda31..aee2e906f2 100644
@@ -49,7 +49,7 @@ static bool check_prop_still_unset(DeviceState *dev, const char *name,
 
 /* --- drive --- */
 
-static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
+static bool get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
                       Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -69,9 +69,9 @@ static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
     } else {
         value = "";
     }
-
     p = g_strdup(value);
-    visit_type_str(v, name, &p, errp);
+
+    return visit_type_str(v, name, &p, errp);
 }
 
 static void set_drive_helper(Object *obj, Visitor *v, const char *name,
@@ -207,7 +207,7 @@ const PropertyInfo qdev_prop_drive_iothread = {
 
 /* --- character device --- */
 
-static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
+static bool get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -215,7 +215,8 @@ static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
     g_autofree char *p;
 
     p = g_strdup(be->chr && be->chr->label ? be->chr->label : "");
-    visit_type_str(v, name, &p, errp);
+
+    return visit_type_str(v, name, &p, errp);
 }
 
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
@@ -279,7 +280,7 @@ const PropertyInfo qdev_prop_chr = {
 };
 
 /* --- netdev device --- */
-static void get_netdev(Object *obj, Visitor *v, const char *name,
+static bool get_netdev(Object *obj, Visitor *v, const char *name,
                        void *opaque, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -288,7 +289,8 @@ static void get_netdev(Object *obj, Visitor *v, const char *name,
     g_autofree char *p;
 
     p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
-    visit_type_str(v, name, &p, errp);
+
+    return visit_type_str(v, name, &p, errp);
 }
 
 static void set_netdev(Object *obj, Visitor *v, const char *name,
@@ -359,7 +361,7 @@ const PropertyInfo qdev_prop_netdev = {
 
 
 /* --- audiodev --- */
-static void get_audiodev(Object *obj, Visitor *v, const char* name,
+static bool get_audiodev(Object *obj, Visitor *v, const char* name,
                          void *opaque, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -367,7 +369,7 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name,
     QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
     g_autofree char *p = g_strdup(audio_get_id(card));
 
-    visit_type_str(v, name, &p, errp);
+    return visit_type_str(v, name, &p, errp);
 }
 
 static void set_audiodev(Object *obj, Visitor *v, const char* name,
hw/core/qdev-properties.c +40 -40

309 lines not on this page · raw message

hw/core/qdev.c +3 -2
index 01796823b4..85c8ec3ddb 100644
@@ -726,7 +726,7 @@ char *qdev_get_dev_path(DeviceState *dev)
  * Legacy property handling
  */
 
-static void qdev_get_legacy_property(Object *obj, Visitor *v,
+static bool qdev_get_legacy_property(Object *obj, Visitor *v,
                                      const char *name, void *opaque,
                                      Error **errp)
 {
@@ -737,7 +737,8 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v,
     char *ptr = buffer;
 
     prop->info->print(dev, prop, buffer, sizeof(buffer));
-    visit_type_str(v, name, &ptr, errp);
+
+    return visit_type_str(v, name, &ptr, errp);
 }
 
 /**
hw/cpu/core.c +4 -4
index 3a659291ea..93c0c4d44c 100644
@@ -15,13 +15,13 @@
 #include "sysemu/cpus.h"
 #include "hw/boards.h"
 
-static void core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
+static bool core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     CPUCore *core = CPU_CORE(obj);
     int64_t value = core->core_id;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
@@ -42,13 +42,13 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
     core->core_id = value;
 }
 
-static void core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
+static bool core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
                                      void *opaque, Error **errp)
 {
     CPUCore *core = CPU_CORE(obj);
     int64_t value = core->nr_threads;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
hw/gpio/aspeed_gpio.c +4 -4
index 985a259e05..d91b81758d 100644
@@ -726,7 +726,7 @@ static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx)
     return -1;
 }
 
-static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name,
+static bool aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name,
                                 void *opaque, Error **errp)
 {
     int pin = 0xfff;
@@ -739,17 +739,17 @@ static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name,
         /* 1.8V gpio */
         if (sscanf(name, "gpio%3[18A-E]%1d", group, &pin) != 2) {
             error_setg(errp, "%s: error reading %s", __func__, name);
-            return;
+            return false;
         }
     }
     set_idx = get_set_idx(s, group, &group_idx);
     if (set_idx == -1) {
         error_setg(errp, "%s: invalid group %s", __func__, group);
-        return;
+        return false;
     }
     pin =  pin + group_idx * GPIOS_PER_GROUP;
     level = aspeed_gpio_get_pin_level(s, set_idx, pin);
-    visit_type_bool(v, name, &level, errp);
+    return visit_type_bool(v, name, &level, errp);
 }
 
 static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name,
hw/i386/microvm.c +6 -6
index 81d0888930..170b5077dc 100644
@@ -339,13 +339,13 @@ static void microvm_machine_reset(MachineState *machine)
     }
 }
 
-static void microvm_machine_get_pic(Object *obj, Visitor *v, const char *name,
+static bool microvm_machine_get_pic(Object *obj, Visitor *v, const char *name,
                                     void *opaque, Error **errp)
 {
     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
     OnOffAuto pic = mms->pic;
 
-    visit_type_OnOffAuto(v, name, &pic, errp);
+    return visit_type_OnOffAuto(v, name, &pic, errp);
 }
 
 static void microvm_machine_set_pic(Object *obj, Visitor *v, const char *name,
@@ -356,13 +356,13 @@ static void microvm_machine_set_pic(Object *obj, Visitor *v, const char *name,
     visit_type_OnOffAuto(v, name, &mms->pic, errp);
 }
 
-static void microvm_machine_get_pit(Object *obj, Visitor *v, const char *name,
+static bool microvm_machine_get_pit(Object *obj, Visitor *v, const char *name,
                                     void *opaque, Error **errp)
 {
     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
     OnOffAuto pit = mms->pit;
 
-    visit_type_OnOffAuto(v, name, &pit, errp);
+    return visit_type_OnOffAuto(v, name, &pit, errp);
 }
 
 static void microvm_machine_set_pit(Object *obj, Visitor *v, const char *name,
@@ -373,13 +373,13 @@ static void microvm_machine_set_pit(Object *obj, Visitor *v, const char *name,
     visit_type_OnOffAuto(v, name, &mms->pit, errp);
 }
 
-static void microvm_machine_get_rtc(Object *obj, Visitor *v, const char *name,
+static bool microvm_machine_get_rtc(Object *obj, Visitor *v, const char *name,
                                     void *opaque, Error **errp)
 {
     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
     OnOffAuto rtc = mms->rtc;
 
-    visit_type_OnOffAuto(v, name, &rtc, errp);
+    return visit_type_OnOffAuto(v, name, &rtc, errp);
 }
 
 static void microvm_machine_set_rtc(Object *obj, Visitor *v, const char *name,
hw/i386/pc.c +6 -6
index 3d419d5991..a95252f6c8 100644
@@ -1758,7 +1758,7 @@ static HotplugHandler *pc_get_hotplug_handler(MachineState *machine,
     return NULL;
 }
 
-static void
+static bool
 pc_machine_get_device_memory_region_size(Object *obj, Visitor *v,
                                          const char *name, void *opaque,
                                          Error **errp)
@@ -1770,16 +1770,16 @@ pc_machine_get_device_memory_region_size(Object *obj, Visitor *v,
         value = memory_region_size(&ms->device_memory->mr);
     }
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
-static void pc_machine_get_vmport(Object *obj, Visitor *v, const char *name,
+static bool pc_machine_get_vmport(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
     OnOffAuto vmport = pcms->vmport;
 
-    visit_type_OnOffAuto(v, name, &vmport, errp);
+    return visit_type_OnOffAuto(v, name, &vmport, errp);
 }
 
 static void pc_machine_set_vmport(Object *obj, Visitor *v, const char *name,
@@ -1832,14 +1832,14 @@ static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
     pcms->pit_enabled = value;
 }
 
-static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v,
+static bool pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v,
                                             const char *name, void *opaque,
                                             Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
     uint64_t value = pcms->max_ram_below_4g;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
hw/i386/x86.c +4 -4
index 67bee1bcb8..583f4e4e52 100644
@@ -870,13 +870,13 @@ bool x86_machine_is_smm_enabled(X86MachineState *x86ms)
     return false;
 }
 
-static void x86_machine_get_smm(Object *obj, Visitor *v, const char *name,
+static bool x86_machine_get_smm(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     X86MachineState *x86ms = X86_MACHINE(obj);
     OnOffAuto smm = x86ms->smm;
 
-    visit_type_OnOffAuto(v, name, &smm, errp);
+    return visit_type_OnOffAuto(v, name, &smm, errp);
 }
 
 static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,
@@ -895,13 +895,13 @@ bool x86_machine_is_acpi_enabled(X86MachineState *x86ms)
     return true;
 }
 
-static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name,
+static bool x86_machine_get_acpi(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
     X86MachineState *x86ms = X86_MACHINE(obj);
     OnOffAuto acpi = x86ms->acpi;
 
-    visit_type_OnOffAuto(v, name, &acpi, errp);
+    return visit_type_OnOffAuto(v, name, &acpi, errp);
 }
 
 static void x86_machine_set_acpi(Object *obj, Visitor *v, const char *name,
hw/ide/qdev.c +2 -2
index 27ff1f7f66..a404596b70 100644
@@ -230,12 +230,12 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
                          dev->conf.lsecs);
 }
 
-static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *name,
+static bool ide_dev_get_bootindex(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     IDEDevice *d = IDE_DEVICE(obj);
 
-    visit_type_int32(v, name, &d->conf.bootindex, errp);
+    return visit_type_int32(v, name, &d->conf.bootindex, errp);
 }
 
 static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
hw/intc/apic_common.c +2 -2
index 81addd6390..c428f96a21 100644
@@ -424,14 +424,14 @@ static Property apic_properties_common[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void apic_common_get_id(Object *obj, Visitor *v, const char *name,
+static bool apic_common_get_id(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     APICCommonState *s = APIC_COMMON(obj);
     uint32_t value;
 
     value = s->apicbase & MSR_IA32_APICBASE_EXTD ? s->initial_apic_id : s->id;
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
hw/mem/nvdimm.c +4 -4
index b55de7dbe1..8b7940ca08 100644
@@ -32,13 +32,13 @@
 #include "hw/mem/memory-device.h"
 #include "sysemu/hostmem.h"
 
-static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *name,
+static bool nvdimm_get_label_size(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     NVDIMMDevice *nvdimm = NVDIMM(obj);
     uint64_t value = nvdimm->label_size;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
@@ -65,7 +65,7 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
     nvdimm->label_size = value;
 }
 
-static void nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
+static bool nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     NVDIMMDevice *nvdimm = NVDIMM(obj);
@@ -73,7 +73,7 @@ static void nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
 
     value = qemu_uuid_unparse_strdup(&nvdimm->uuid);
 
-    visit_type_str(v, name, &value, errp);
+    return visit_type_str(v, name, &value, errp);
 }
 
 
hw/mem/pc-dimm.c +3 -3
index 9d3f0b9691..d4f2dd69d7 100644
@@ -147,7 +147,7 @@ static Property pc_dimm_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
+static bool pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     Error *local_err = NULL;
@@ -156,10 +156,10 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
     value = memory_device_get_region_size(MEMORY_DEVICE(obj), &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
-        return;
+        return false;
     }
 
-    visit_type_uint64(v, name, &value, errp);
+    return visit_type_uint64(v, name, &value, errp);
 }
 
 static void pc_dimm_init(Object *obj)
hw/misc/aspeed_sdmc.c +2 -2
index 0737d8de81..7df5797689 100644
@@ -208,13 +208,13 @@ static void aspeed_sdmc_reset(DeviceState *dev)
     s->regs[R_CONF] = asc->compute_conf(s, 0);
 }
 
-static void aspeed_sdmc_get_ram_size(Object *obj, Visitor *v, const char *name,
+static bool aspeed_sdmc_get_ram_size(Object *obj, Visitor *v, const char *name,
                                      void *opaque, Error **errp)
 {
     AspeedSDMCState *s = ASPEED_SDMC(obj);
     int64_t value = s->ram_size;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *name,
hw/misc/pca9552.c +4 -4
index e4ccdeaf78..c6e25a7ef3 100644
@@ -249,7 +249,7 @@ static int pca955x_event(I2CSlave *i2c, enum i2c_event event)
     return 0;
 }
 
-static void pca955x_get_led(Object *obj, Visitor *v, const char *name,
+static bool pca955x_get_led(Object *obj, Visitor *v, const char *name,
                             void *opaque, Error **errp)
 {
     PCA955xClass *k = PCA955X_GET_CLASS(obj);
@@ -260,11 +260,11 @@ static void pca955x_get_led(Object *obj, Visitor *v, const char *name,
     rc = sscanf(name, "led%2d", &led);
     if (rc != 1) {
         error_setg(errp, "%s: error reading %s", __func__, name);
-        return;
+        return false;
     }
     if (led < 0 || led > k->pin_count) {
         error_setg(errp, "%s invalid led %s", __func__, name);
-        return;
+        return false;
     }
     /*
      * Get the LSx register as the qom interface should expose the device
@@ -273,7 +273,7 @@ static void pca955x_get_led(Object *obj, Visitor *v, const char *name,
      */
     reg = PCA9552_LS0 + led / 4;
     state = (pca955x_read(s, reg) >> (led % 8)) & 0x3;
-    visit_type_str(v, name, (char **)&led_state[state], errp);
+    return visit_type_str(v, name, (char **)&led_state[state], errp);
 }
 
 /*
hw/misc/tmp105.c +2 -2
index b47120492a..af55ad7996 100644
@@ -56,13 +56,13 @@ static void tmp105_alarm_update(TMP105State *s)
     tmp105_interrupt_update(s);
 }
 
-static void tmp105_get_temperature(Object *obj, Visitor *v, const char *name,
+static bool tmp105_get_temperature(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     TMP105State *s = TMP105(obj);
     int64_t value = s->temperature * 1000 / 256;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 /* Units are 0.001 centigrades relative to 0 C.  s->temperature is 8.8
hw/misc/tmp421.c +4 -4
index 49abe2d246..5c8ca3dc51 100644
@@ -110,7 +110,7 @@ typedef struct TMP421Class {
 static const int32_t mins[2] = { -40000, -55000 };
 static const int32_t maxs[2] = { 127000, 150000 };
 
-static void tmp421_get_temperature(Object *obj, Visitor *v, const char *name,
+static bool tmp421_get_temperature(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     TMP421State *s = TMP421(obj);
@@ -121,17 +121,17 @@ static void tmp421_get_temperature(Object *obj, Visitor *v, const char *name,
 
     if (sscanf(name, "temperature%d", &tempid) != 1) {
         error_setg(errp, "error reading %s: %s", name, g_strerror(errno));
-        return;
+        return false;
     }
 
     if (tempid >= 4 || tempid < 0) {
         error_setg(errp, "error reading %s", name);
-        return;
+        return false;
     }
 
     value = ((s->temperature[tempid] - offset) * 1000 + 128) / 256;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 /* Units are 0.001 centigrades relative to 0 C.  s->temperature is 8.8
hw/net/ne2000-isa.c +2 -2
index a878056426..4b49438e67 100644
@@ -94,14 +94,14 @@ static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }
 
-static void isa_ne2000_get_bootindex(Object *obj, Visitor *v,
+static bool isa_ne2000_get_bootindex(Object *obj, Visitor *v,
                                      const char *name, void *opaque,
                                      Error **errp)
 {
     ISANE2000State *isa = ISA_NE2000(obj);
     NE2000State *s = &isa->ne2000;
 
-    visit_type_int32(v, name, &s->c.bootindex, errp);
+    return visit_type_int32(v, name, &s->c.bootindex, errp);
 }
 
 static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
hw/pci-host/i440fx.c +8 -8
index 8ed2417f0c..5be78b46c4 100644
@@ -118,7 +118,7 @@ static const VMStateDescription vmstate_i440fx = {
     }
 };
 
-static void i440fx_pcihost_get_pci_hole_start(Object *obj, Visitor *v,
+static bool i440fx_pcihost_get_pci_hole_start(Object *obj, Visitor *v,
                                               const char *name, void *opaque,
                                               Error **errp)
 {
@@ -129,10 +129,10 @@ static void i440fx_pcihost_get_pci_hole_start(Object *obj, Visitor *v,
     val64 = range_is_empty(&s->pci_hole) ? 0 : range_lob(&s->pci_hole);
     value = val64;
     assert(value == val64);
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
-static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v,
+static bool i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v,
                                             const char *name, void *opaque,
                                             Error **errp)
 {
@@ -143,7 +143,7 @@ static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v,
     val64 = range_is_empty(&s->pci_hole) ? 0 : range_upb(&s->pci_hole) + 1;
     value = val64;
     assert(value == val64);
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 /*
@@ -168,13 +168,13 @@ static uint64_t i440fx_pcihost_get_pci_hole64_start_value(Object *obj)
     return value;
 }
 
-static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v,
+static bool i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v,
                                                 const char *name,
                                                 void *opaque, Error **errp)
 {
     uint64_t hole64_start = i440fx_pcihost_get_pci_hole64_start_value(obj);
 
-    visit_type_uint64(v, name, &hole64_start, errp);
+    return visit_type_uint64(v, name, &hole64_start, errp);
 }
 
 /*
@@ -183,7 +183,7 @@ static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v,
  * Then it is expanded to the PCI_HOST_PROP_PCI_HOLE64_SIZE
  * that can be configured by the user.
  */
-static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
+static bool i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
                                               const char *name, void *opaque,
                                               Error **errp)
 {
@@ -199,7 +199,7 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
     if (s->pci_hole64_fix && value < hole64_end) {
         value = hole64_end;
     }
-    visit_type_uint64(v, name, &value, errp);
+    return visit_type_uint64(v, name, &value, errp);
 }
 
 static void i440fx_pcihost_initfn(Object *obj)
hw/pci-host/q35.c +8 -8
index b67cb9c29f..7183c7dc23 100644
@@ -79,7 +79,7 @@ static const char *q35_host_root_bus_path(PCIHostState *host_bridge,
     return "0000:00";
 }
 
-static void q35_host_get_pci_hole_start(Object *obj, Visitor *v,
+static bool q35_host_get_pci_hole_start(Object *obj, Visitor *v,
                                         const char *name, void *opaque,
                                         Error **errp)
 {
@@ -91,10 +91,10 @@ static void q35_host_get_pci_hole_start(Object *obj, Visitor *v,
         ? 0 : range_lob(&s->mch.pci_hole);
     value = val64;
     assert(value == val64);
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
-static void q35_host_get_pci_hole_end(Object *obj, Visitor *v,
+static bool q35_host_get_pci_hole_end(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
                                       Error **errp)
 {
@@ -106,7 +106,7 @@ static void q35_host_get_pci_hole_end(Object *obj, Visitor *v,
         ? 0 : range_upb(&s->mch.pci_hole) + 1;
     value = val64;
     assert(value == val64);
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 /*
@@ -131,13 +131,13 @@ static uint64_t q35_host_get_pci_hole64_start_value(Object *obj)
     return value;
 }
 
-static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v,
+static bool q35_host_get_pci_hole64_start(Object *obj, Visitor *v,
                                           const char *name, void *opaque,
                                           Error **errp)
 {
     uint64_t hole64_start = q35_host_get_pci_hole64_start_value(obj);
 
-    visit_type_uint64(v, name, &hole64_start, errp);
+    return visit_type_uint64(v, name, &hole64_start, errp);
 }
 
 /*
@@ -146,7 +146,7 @@ static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v,
  * Then it is expanded to the PCI_HOST_PROP_PCI_HOLE64_SIZE
  * that can be configured by the user.
  */
-static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
+static bool q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
                                         const char *name, void *opaque,
                                         Error **errp)
 {
@@ -162,7 +162,7 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
     if (s->pci_hole64_fix && value < hole64_end) {
         value = hole64_end;
     }
-    visit_type_uint64(v, name, &value, errp);
+    return visit_type_uint64(v, name, &value, errp);
 }
 
 /*
hw/ppc/spapr_caps.c +7 -7
index cbc09b24b6..c72c33cc02 100644
@@ -70,14 +70,14 @@ typedef struct SpaprCapabilityInfo {
     bool (*migrate_needed)(void *opaque);
 } SpaprCapabilityInfo;
 
-static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
+static bool spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     SpaprCapabilityInfo *cap = opaque;
     SpaprMachineState *spapr = SPAPR_MACHINE(obj);
     bool value = spapr_get_cap(spapr, cap->index) == SPAPR_CAP_ON;
 
-    visit_type_bool(v, name, &value, errp);
+    return visit_type_bool(v, name, &value, errp);
 }
 
 static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
@@ -96,7 +96,7 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
 }
 
 
-static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
+static bool spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     SpaprCapabilityInfo *cap = opaque;
@@ -106,12 +106,12 @@ static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
 
     if (value >= cap->possible->num) {
         error_setg(errp, "Invalid value (%d) for cap-%s", value, cap->name);
-        return;
+        return false;
     }
 
     val = g_strdup(cap->possible->vals[value]);
 
-    visit_type_str(v, name, &val, errp);
+    return visit_type_str(v, name, &val, errp);
 }
 
 static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
@@ -144,7 +144,7 @@ out:
     g_free(val);
 }
 
-static void spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
+static bool spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     SpaprCapabilityInfo *cap = opaque;
@@ -152,7 +152,7 @@ static void spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
     uint8_t val = spapr_get_cap(spapr, cap->index);
     uint64_t pagesize = (1ULL << val);
 
-    visit_type_size(v, name, &pagesize, errp);
+    return visit_type_size(v, name, &pagesize, errp);
 }
 
 static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
hw/ppc/spapr_drc.c +12 -9
index 43d12bc33a..2ffbf5ea2b 100644
@@ -289,15 +289,16 @@ static SpaprDREntitySense logical_entity_sense(SpaprDrc *drc)
     }
 }
 
-static void prop_get_index(Object *obj, Visitor *v, const char *name,
+static bool prop_get_index(Object *obj, Visitor *v, const char *name,
                            void *opaque, Error **errp)
 {
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
     uint32_t value = spapr_drc_index(drc);
-    visit_type_uint32(v, name, &value, errp);
+
+    return visit_type_uint32(v, name, &value, errp);
 }
 
-static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
+static bool prop_get_fdt(Object *obj, Visitor *v, const char *name,
                          void *opaque, Error **errp)
 {
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
@@ -309,7 +310,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
     if (!drc->fdt) {
         visit_type_null(v, NULL, &null, errp);
         qobject_unref(null);
-        return;
+        return false;
     }
 
     fdt = drc->fdt;
@@ -328,7 +329,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
             fdt_depth++;
             name = fdt_get_name(fdt, fdt_offset, &name_len);
             if (!visit_start_struct(v, name, NULL, 0, errp)) {
-                return;
+                return false;
             }
             break;
         case FDT_END_NODE:
@@ -338,7 +339,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
             visit_end_struct(v, NULL);
             if (err) {
                 error_propagate(errp, err);
-                return;
+                return false;
             }
             fdt_depth--;
             break;
@@ -347,19 +348,19 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
             prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
             name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
             if (!visit_start_list(v, name, NULL, 0, errp)) {
-                return;
+                return false;
             }
             for (i = 0; i < prop_len; i++) {
                 if (!visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i],
                                       errp)) {
-                    return;
+                    return false;
                 }
             }
             visit_check_list(v, &err);
             visit_end_list(v, NULL);
             if (err) {
                 error_propagate(errp, err);
-                return;
+                return false;
             }
             break;
         }
@@ -369,6 +370,8 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
         }
         fdt_offset = fdt_offset_next;
     } while (fdt_depth != 0);
+
+    return true;
 }
 
 void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp)
hw/riscv/sifive_u.c +2 -2
index 19a976c9a6..692e22cbaa 100644
@@ -512,11 +512,11 @@ static void sifive_u_machine_set_start_in_flash(Object *obj, bool value, Error *
     s->start_in_flash = value;
 }
 
-static void sifive_u_machine_get_uint32_prop(Object *obj, Visitor *v,
+static bool sifive_u_machine_get_uint32_prop(Object *obj, Visitor *v,
                                              const char *name, void *opaque,
                                              Error **errp)
 {
-    visit_type_uint32(v, name, (uint32_t *)opaque, errp);
+    return visit_type_uint32(v, name, (uint32_t *)opaque, errp);
 }
 
 static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v,
hw/s390x/css.c +2 -2
index 519dc91316..b3163ccc09 100644
@@ -2341,7 +2341,7 @@ void css_reset(void)
     channel_subsys.max_ssid = 0;
 }
 
-static void get_css_devid(Object *obj, Visitor *v, const char *name,
+static bool get_css_devid(Object *obj, Visitor *v, const char *name,
                           void *opaque, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -2365,7 +2365,7 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name,
         snprintf(buffer, sizeof(buffer), "<unset>");
     }
 
-    visit_type_str(v, name, &p, errp);
+    return visit_type_str(v, name, &p, errp);
 }
 
 /*
hw/s390x/s390-pci-bus.c +2 -2
index 92146a2119..8c6cf66cb5 100644
@@ -1244,13 +1244,13 @@ static void s390_pci_device_reset(DeviceState *dev)
     fmb_timer_free(pbdev);
 }
 
-static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,
+static bool s390_pci_get_fid(Object *obj, Visitor *v, const char *name,
                          void *opaque, Error **errp)
 {
     Property *prop = opaque;
     uint32_t *ptr = qdev_get_prop_ptr(DEVICE(obj), prop);
 
-    visit_type_uint32(v, name, ptr, errp);
+    return visit_type_uint32(v, name, ptr, errp);
 }
 
 static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name,
hw/usb/dev-storage.c +2 -2
index 2ed6a8df24..caca911fb0 100644
@@ -719,13 +719,13 @@ static void usb_msd_class_storage_initfn(ObjectClass *klass, void *data)
     device_class_set_props(dc, msd_properties);
 }
 
-static void usb_msd_get_bootindex(Object *obj, Visitor *v, const char *name,
+static bool usb_msd_get_bootindex(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     USBDevice *dev = USB_DEVICE(obj);
     MSDState *s = USB_STORAGE_DEV(dev);
 
-    visit_type_int32(v, name, &s->conf.bootindex, errp);
+    return visit_type_int32(v, name, &s->conf.bootindex, errp);
 }
 
 static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
hw/vfio/pci-quirks.c +8 -6
index 3a14b7c303..8e2f441c01 100644
@@ -1484,7 +1484,7 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev)
  *
  * https://lists.gnu.org/archive/html/qemu-devel/2017-08/pdfUda5iEpgOS.pdf
  */
-static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v,
+static bool get_nv_gpudirect_clique_id(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
@@ -1492,7 +1492,7 @@ static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v,
     Property *prop = opaque;
     uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    visit_type_uint8(v, name, ptr, errp);
+    return visit_type_uint8(v, name, ptr, errp);
 }
 
 static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v,
@@ -1565,20 +1565,22 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
     return 0;
 }
 
-static void vfio_pci_nvlink2_get_tgt(Object *obj, Visitor *v,
+static bool vfio_pci_nvlink2_get_tgt(Object *obj, Visitor *v,
                                      const char *name,
                                      void *opaque, Error **errp)
 {
     uint64_t tgt = (uintptr_t) opaque;
-    visit_type_uint64(v, name, &tgt, errp);
+
+    return visit_type_uint64(v, name, &tgt, errp);
 }
 
-static void vfio_pci_nvlink2_get_link_speed(Object *obj, Visitor *v,
+static bool vfio_pci_nvlink2_get_link_speed(Object *obj, Visitor *v,
                                                  const char *name,
                                                  void *opaque, Error **errp)
 {
     uint32_t link_speed = (uint32_t)(uintptr_t) opaque;
-    visit_type_uint32(v, name, &link_speed, errp);
+
+    return visit_type_uint32(v, name, &link_speed, errp);
 }
 
 int vfio_pci_nvidia_v100_ram_init(VFIOPCIDevice *vdev, Error **errp)
hw/virtio/virtio-balloon.c +10 -6
index e670f1e595..befac94eaf 100644
@@ -232,11 +232,12 @@ static void balloon_stats_poll_cb(void *opaque)
     s->stats_vq_elem = NULL;
 }
 
-static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
+static bool balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
     Error *err = NULL;
     VirtIOBalloon *s = opaque;
+    bool ret;
     int i;
 
     if (!visit_start_struct(v, name, NULL, 0, &err)) {
@@ -254,25 +255,28 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
             goto out_nested;
         }
     }
-    visit_check_struct(v, &err);
+    ret = visit_check_struct(v, &err);
 out_nested:
     visit_end_struct(v, NULL);
 
-    if (!err) {
-        visit_check_struct(v, &err);
+    if (!ret) {
+        ret = visit_check_struct(v, &err);
     }
 out_end:
     visit_end_struct(v, NULL);
 out:
     error_propagate(errp, err);
+
+    return ret;
 }
 
-static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
+static bool balloon_stats_get_poll_interval(Object *obj, Visitor *v,
                                             const char *name, void *opaque,
                                             Error **errp)
 {
     VirtIOBalloon *s = opaque;
-    visit_type_int(v, name, &s->stats_poll_interval, errp);
+
+    return visit_type_int(v, name, &s->stats_poll_interval, errp);
 }
 
 static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
hw/virtio/virtio-mem.c +6 -6
index 65850530e7..ddf09ed1bf 100644
@@ -663,23 +663,23 @@ static void virtio_mem_remove_size_change_notifier(VirtIOMEM *vmem,
     notifier_remove(notifier);
 }
 
-static void virtio_mem_get_size(Object *obj, Visitor *v, const char *name,
+static bool virtio_mem_get_size(Object *obj, Visitor *v, const char *name,
                                 void *opaque, Error **errp)
 {
     const VirtIOMEM *vmem = VIRTIO_MEM(obj);
     uint64_t value = vmem->size;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
-static void virtio_mem_get_requested_size(Object *obj, Visitor *v,
+static bool virtio_mem_get_requested_size(Object *obj, Visitor *v,
                                           const char *name, void *opaque,
                                           Error **errp)
 {
     const VirtIOMEM *vmem = VIRTIO_MEM(obj);
     uint64_t value = vmem->requested_size;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
@@ -727,13 +727,13 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
     }
 }
 
-static void virtio_mem_get_block_size(Object *obj, Visitor *v, const char *name,
+static bool virtio_mem_get_block_size(Object *obj, Visitor *v, const char *name,
                                       void *opaque, Error **errp)
 {
     const VirtIOMEM *vmem = VIRTIO_MEM(obj);
     uint64_t value = vmem->block_size;
 
-    visit_type_size(v, name, &value, errp);
+    return visit_type_size(v, name, &value, errp);
 }
 
 static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
iothread.c +2 -2
index 0598a6d20d..b4349b28ea 100644
@@ -223,14 +223,14 @@ static PollParamInfo poll_shrink_info = {
     "poll-shrink", offsetof(IOThread, poll_shrink),
 };
 
-static void iothread_get_poll_param(Object *obj, Visitor *v,
+static bool iothread_get_poll_param(Object *obj, Visitor *v,
         const char *name, void *opaque, Error **errp)
 {
     IOThread *iothread = IOTHREAD(obj);
     PollParamInfo *info = opaque;
     int64_t *field = (void *)iothread + info->offset;
 
-    visit_type_int64(v, name, field, errp);
+    return visit_type_int64(v, name, field, errp);
 }
 
 static void iothread_set_poll_param(Object *obj, Visitor *v,
net/colo-compare.c +4 -4
index 398b7546ff..50492dfe4c 100644
@@ -1078,14 +1078,14 @@ static void compare_set_notify_dev(Object *obj, const char *value, Error **errp)
     s->notify_dev = g_strdup(value);
 }
 
-static void compare_get_timeout(Object *obj, Visitor *v,
+static bool compare_get_timeout(Object *obj, Visitor *v,
                                 const char *name, void *opaque,
                                 Error **errp)
 {
     CompareState *s = COLO_COMPARE(obj);
     uint32_t value = s->compare_timeout;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void compare_set_timeout(Object *obj, Visitor *v,
@@ -1106,14 +1106,14 @@ static void compare_set_timeout(Object *obj, Visitor *v,
     s->compare_timeout = value;
 }
 
-static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
+static bool compare_get_expired_scan_cycle(Object *obj, Visitor *v,
                                            const char *name, void *opaque,
                                            Error **errp)
 {
     CompareState *s = COLO_COMPARE(obj);
     uint32_t value = s->expired_scan_cycle;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
net/dump.c +2 -2
index 11a737a4bc..1e57bc63e7 100644
@@ -179,13 +179,13 @@ static void filter_dump_setup(NetFilterState *nf, Error **errp)
     net_dump_state_init(&nfds->ds, nfds->filename, nfds->maxlen, errp);
 }
 
-static void filter_dump_get_maxlen(Object *obj, Visitor *v, const char *name,
+static bool filter_dump_get_maxlen(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     NetFilterDumpState *nfds = FILTER_DUMP(obj);
     uint32_t value = nfds->maxlen;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void filter_dump_set_maxlen(Object *obj, Visitor *v, const char *name,
net/filter-buffer.c +2 -2
index dfa211794b..ee814aa1e3 100644
@@ -155,14 +155,14 @@ static void filter_buffer_class_init(ObjectClass *oc, void *data)
     nfc->status_changed = filter_buffer_status_changed;
 }
 
-static void filter_buffer_get_interval(Object *obj, Visitor *v,
+static bool filter_buffer_get_interval(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
     FilterBufferState *s = FILTER_BUFFER(obj);
     uint32_t value = s->interval;
 
-    visit_type_uint32(v, name, &value, errp);
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void filter_buffer_set_interval(Object *obj, Visitor *v,
qom/object.c +37 -28

210 lines not on this page · raw message

softmmu/memory.c +8 -6
index 9200b20130..66631433c5 100644
@@ -1170,20 +1170,22 @@ void memory_region_init(MemoryRegion *mr,
     memory_region_do_init(mr, owner, name, size);
 }
 
-static void memory_region_get_container(Object *obj, Visitor *v,
+static bool memory_region_get_container(Object *obj, Visitor *v,
                                         const char *name, void *opaque,
                                         Error **errp)
 {
     MemoryRegion *mr = MEMORY_REGION(obj);
     char *path = (char *)"";
+    bool ret;
 
     if (mr->container) {
         path = object_get_canonical_path(OBJECT(mr->container));
     }
-    visit_type_str(v, name, &path, errp);
+    ret = visit_type_str(v, name, &path, errp);
     if (mr->container) {
         g_free(path);
     }
+    return ret;
 }
 
 static Object *memory_region_resolve_container(Object *obj, void *opaque,
@@ -1194,23 +1196,23 @@ static Object *memory_region_resolve_container(Object *obj, void *opaque,
     return OBJECT(mr->container);
 }
 
-static void memory_region_get_priority(Object *obj, Visitor *v,
+static bool memory_region_get_priority(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
     MemoryRegion *mr = MEMORY_REGION(obj);
     int32_t value = mr->priority;
 
-    visit_type_int32(v, name, &value, errp);
+    return visit_type_int32(v, name, &value, errp);
 }
 
-static void memory_region_get_size(Object *obj, Visitor *v, const char *name,
+static bool memory_region_get_size(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     MemoryRegion *mr = MEMORY_REGION(obj);
     uint64_t value = memory_region_size(mr);
 
-    visit_type_uint64(v, name, &value, errp);
+    return visit_type_uint64(v, name, &value, errp);
 }
 
 static void memory_region_initfn(Object *obj)
target/arm/cpu64.c +8 -6
index 15494002d2..436eb86f8e 100644
@@ -445,7 +445,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
     cpu->sve_max_vq = max_vq;
 }
 
-static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name,
+static bool cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
     ARMCPU *cpu = ARM_CPU(obj);
@@ -457,7 +457,8 @@ static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name,
     } else {
         value = cpu->sve_max_vq;
     }
-    visit_type_uint32(v, name, &value, errp);
+
+    return visit_type_uint32(v, name, &value, errp);
 }
 
 static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
@@ -486,7 +487,7 @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
     cpu->sve_max_vq = max_vq;
 }
 
-static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name,
+static bool cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     ARMCPU *cpu = ARM_CPU(obj);
@@ -499,7 +500,8 @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name,
     } else {
         value = test_bit(vq - 1, cpu->sve_vq_map);
     }
-    visit_type_bool(v, name, &value, errp);
+
+    return visit_type_bool(v, name, &value, errp);
 }
 
 static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name,
@@ -527,13 +529,13 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name,
     set_bit(vq - 1, cpu->sve_vq_init);
 }
 
-static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name,
+static bool cpu_arm_get_sve(Object *obj, Visitor *v, const char *name,
                             void *opaque, Error **errp)
 {
     ARMCPU *cpu = ARM_CPU(obj);
     bool value = cpu_isar_feature(aa64_sve, cpu);
 
-    visit_type_bool(v, name, &value, errp);
+    return visit_type_bool(v, name, &value, errp);
 }
 
 static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name,
target/i386/cpu.c +29 -19

154 lines not on this page · raw message

target/ppc/compat.c +2 -2
index 08aede88dc..d59eadd4da 100644
@@ -238,7 +238,7 @@ int ppc_compat_max_vthreads(PowerPCCPU *cpu)
     return n_threads;
 }
 
-static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
+static bool ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
                                 void *opaque, Error **errp)
 {
     uint32_t compat_pvr = *((uint32_t *)opaque);
@@ -254,7 +254,7 @@ static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
         value = compat->name;
     }
 
-    visit_type_str(v, name, (char **)&value, errp);
+    return visit_type_str(v, name, (char **)&value, errp);
 }
 
 static void ppc_compat_prop_set(Object *obj, Visitor *v, const char *name,
target/s390x/cpu.c +7 -4
index 08eb674d22..0f4f5c0eec 100644
@@ -265,23 +265,26 @@ static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs)
     return panic_info;
 }
 
-static void s390_cpu_get_crash_info_qom(Object *obj, Visitor *v,
+static bool s390_cpu_get_crash_info_qom(Object *obj, Visitor *v,
                                         const char *name, void *opaque,
                                         Error **errp)
 {
     CPUState *cs = CPU(obj);
     GuestPanicInformation *panic_info;
+    bool ret;
 
     if (!cs->crash_occurred) {
         error_setg(errp, "No crash occurred");
-        return;
+        return false;
     }
 
     panic_info = s390_cpu_get_crash_info(cs);
 
-    visit_type_GuestPanicInformation(v, "crash-information", &panic_info,
-                                     errp);
+    ret = visit_type_GuestPanicInformation(v, "crash-information", &panic_info,
+                                           errp);
     qapi_free_GuestPanicInformation(panic_info);
+
+    return ret;
 }
 #endif
 
target/s390x/cpu_models.c +8 -6
index c2af226174..4d884be759 100644
@@ -978,7 +978,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)
 #endif
 }
 
-static void get_feature(Object *obj, Visitor *v, const char *name,
+static bool get_feature(Object *obj, Visitor *v, const char *name,
                         void *opaque, Error **errp)
 {
     S390Feat feat = (S390Feat) opaque;
@@ -988,11 +988,12 @@ static void get_feature(Object *obj, Visitor *v, const char *name,
     if (!cpu->model) {
         error_setg(errp, "Details about the host CPU model are not available, "
                          "features cannot be queried.");
-        return;
+        return false;
     }
 
     value = test_bit(feat, cpu->model->features);
-    visit_type_bool(v, name, &value, errp);
+
+    return visit_type_bool(v, name, &value, errp);
 }
 
 static void set_feature(Object *obj, Visitor *v, const char *name,
@@ -1029,7 +1030,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name,
     }
 }
 
-static void get_feature_group(Object *obj, Visitor *v, const char *name,
+static bool get_feature_group(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
     S390FeatGroup group = (S390FeatGroup) opaque;
@@ -1041,13 +1042,14 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name,
     if (!cpu->model) {
         error_setg(errp, "Details about the host CPU model are not available, "
                          "features cannot be queried.");
-        return;
+        return false;
     }
 
     /* a group is enabled if all features are enabled */
     bitmap_and(tmp, cpu->model->features, def->feat, S390_FEAT_MAX);
     value = bitmap_equal(tmp, def->feat, S390_FEAT_MAX);
-    visit_type_bool(v, name, &value, errp);
+
+    return visit_type_bool(v, name, &value, errp);
 }
 
 static void set_feature_group(Object *obj, Visitor *v, const char *name,
target/sparc/cpu.c +2 -2
index cf21efd85f..aafb2a7960 100644
@@ -786,13 +786,13 @@ static void sparc_cpu_initfn(Object *obj)
     }
 }
 
-static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,
+static bool sparc_get_nwindows(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
     SPARCCPU *cpu = SPARC_CPU(obj);
     int64_t value = cpu->env.def.nwindows;
 
-    visit_type_int(v, name, &value, errp);
+    return visit_type_int(v, name, &value, errp);
 }
 
 static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name,
Signature · 1 line
2.21.3
#8 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

Commits 1c94a35164..7b3cb8037c simplified the error propagation.

The complete series is b6d7e9b66f..a43770df5d. The part you quoted omits half of the transformation for qemu-option and QAPI. The other half is in

a5f9b9df25 error: Reduce unnecessary error propagation 992861fb1e error: Eliminate error_propagate() manually af175e85f9 error: Eliminate error_propagate() with Coccinelle, part 2 668f62ec62 error: Eliminate error_propagate() with Coccinelle, part 1 dcfe480544 error: Avoid unnecessary error_propagate() after error_setg()

I'd simply point to the complete series.

Quoted 2 lines

Similarly to commit 73ac1aac39 ("qdev: Make functions taking Error ** return bool, not void")

I think commit 6fd5bef10b "qom: Make functions taking Error ** return bool, not void" would be a closer match.

Quoted 2 lines

let the ObjectPropertyGet
functions return a boolean value, not void.

The conversion simplifies most calls at the cost of slightly complicating the callee. The complete series quoted above shows it can be a good trade:

 276 files changed, 2424 insertions(+), 3567 deletions(-)
Quoted 9 lines

See commit e3fe3988d7 ("error: Document Error API usage rules") for rationale.

---
Sorry I don't see how to split that patch without using ugly casts in the middle.
---

[...]

Quoted 1 line
 57 files changed, 325 insertions(+), 281 deletions(-)

This one's different: it converts a callback. Many more functions than calls.

It still improves consistency.

It should also help reduce Coverity CHECKED_RETURN false positives in getters; see below.

Quoted 18 lines
include/qom/object.h +3 -1
index e9496ba970..7ba2172932 100644
@@ -333,9 +333,11 @@ typedef void (ObjectPropertySet)(Object *obj,
  * @opaque: the object property opaque
  * @errp: a pointer to an Error that is filled if getting fails.
  *
+ * Return true on success, false on failure.
+ *
  * Called when trying to get a property.
  */
-typedef void (ObjectPropertyGet)(Object *obj,
+typedef bool (ObjectPropertyGet)(Object *obj,
                                  Visitor *v,
                                  const char *name,
                                  void *opaque,

[...]

Quoted 14 lines
target/ppc/compat.c +1 -1
index 08aede88dc..d59eadd4da 100644
@@ -238,7 +238,7 @@ int ppc_compat_max_vthreads(PowerPCCPU *cpu)
     return n_threads;
 }
 
-static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
+static bool ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
                                 void *opaque, Error **errp)
 {
     uint32_t compat_pvr = *((uint32_t *)opaque);

target/ppc/compat.c static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name, · line 257

Quoted 5 lines
target/ppc/compat.c +1 -1
@@ -254,7 +254,7 @@ static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
         value = compat->name;
     }
 
-    visit_type_str(v, name, (char **)&value, errp);
+    return visit_type_str(v, name, (char **)&value, errp);

Before the patch, Coverity reports

CID 1430435: Error handling issues (CHECKED_RETURN)
Calling "visit_type_str" without checking return value (as is done elsewhere 531 out of 561 times).

False positive; not checking is fine here. Still, avoiding false positives is nice, as long as it can be done without impairing readability.

Quoted 3 lines
target/ppc/compat.c +0 -0
 }
 
 static void ppc_compat_prop_set(Object *obj, Visitor *v, const char *name,

[...]

#9 lore raw

Making more functions taking Error ** return bool (commit b6d7e9b66f..a43770df5d) created a number of false positive CHECKED_RETURN Coverity issues. Peter notified me back then. This series could help (we'd have to double-check), but it covers only the getters, not the setters.

Peter, are you still interested in reducing the false positives (as opposed to marking them)?

Philippe, are you still pursuing this series?

#10 lore raw
Quoted 8 lines · Markus Armbruster

Making more functions taking Error ** return bool (commit b6d7e9b66f..a43770df5d) created a number of false positive CHECKED_RETURN Coverity issues. Peter notified me back then. This series could help (we'd have to double-check), but it covers only the getters, not the setters.

Peter, are you still interested in reducing the false positives (as opposed to marking them)?

I don't have a strong view on whether we should make the change in this series, though I do think overall we should have a decision on whether we like (Error** + void) or (Error** + bool) and try to aim to eventually converge on being consistent about it.

As far as the Coverity issues are concerned, I don't think we should let them drive our technical decisions. We should decide what we want to do with our APIs on other grounds, and then either that causes the issues to go away or we mark them as false-positives. I would ideally like us to do one or the other relatively soon simply because there are a lot of these issues currently piled up in the Coverity UI and it makes it harder to see the interesting issues.

thanks
-- PMM

#11 lore raw
In reply to Markus Armbruster
Quoted 10 lines · Markus Armbruster

Making more functions taking Error ** return bool (commit b6d7e9b66f..a43770df5d) created a number of false positive CHECKED_RETURN Coverity issues. Peter notified me back then. This series could help (we'd have to double-check), but it covers only the getters, not the setters.

Peter, are you still interested in reducing the false positives (as opposed to marking them)?

Philippe, are you still pursuing this series?

Have you looked at/audited the ObjectPropertySet call sites?

I'm not sure updating ObjectPropertySet is really interesting, and only changing ObjectPropertyGet letting an impaired API doesn't seem a great idea :)

#12 lore raw

RFC 5/5 hw/virtio: Simplify virtio_mem_set_requested_size()

In reply to Philippe Mathieu-Daudé

Simplify by directly using visit_type_size() return value.

---
 hw/virtio/virtio-mem.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
hw/virtio/virtio-mem.c +1 -4
index ddf09ed1bf..e407abc2d8 100644
@@ -687,12 +687,9 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
                                           Error **errp)
 {
     VirtIOMEM *vmem = VIRTIO_MEM(obj);
-    Error *err = NULL;
     uint64_t value;
 
-    visit_type_size(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    if (!visit_type_size(v, name, &value, errp)) {
         return;
     }
 
Signature · 1 line
2.21.3
#13 lore raw

Re: [RFC PATCH-for-5.2 5/5] hw/virtio: Simplify virtio_mem_set_requested_size()

Quoted 14 lines · Philippe Mathieu-Daudé

Simplify by directly using visit_type_size() return value.

---
 hw/virtio/virtio-mem.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
hw/virtio/virtio-mem.c +0 -0
index ddf09ed1bf..e407abc2d8 100644
@@ -687,12 +687,9 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
                                           Error **errp)
 {

hw/virtio/virtio-mem.c static void virtio_mem_set_requested_size(Object *obj, Visitor *v, · line 694

Quoted 10 lines
hw/virtio/virtio-mem.c +1 -4
     VirtIOMEM *vmem = VIRTIO_MEM(obj);
-    Error *err = NULL;
     uint64_t value;
 
-    visit_type_size(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    if (!visit_type_size(v, name, &value, errp)) {
         return;
     }

Crept in after I transformed the pattern in my "Less clumsy error checking" series. There are a few more instances. I expected that to happen, and intend to transform stragglers periodically until their supply dries up.

#14 lore raw
In reply to Philippe Mathieu-Daudé

Review bool visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, · line 538

Quoted 13 lines · Philippe Mathieu-Daudé

RFC series to follow Markus direction to simplify error propagation. Not sure it is worth it yet. It starts to be interesting when using the QEMU_WARN_UNUSED_RESULT attribute in the visitors, such:

-- >8 --

(quoted diff) +1 -0
@@ -525,6 +533,7 @@ bool visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
  * Visit a uint16_t value.
  * Like visit_type_int(), except clamps the value to uint16_t range.
  */
+QEMU_WARN_UNUSED_RESULT
 bool visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
                        Error **errp);

QEMU_WARN_UNUSED_RESULT is problematic with functions taking an Error ** argument, because using &error_abort or &error_fatal the intended way triggers the warning.

Does that make &error_abort and &error_fatal bad ideas? They do help keeping the code concise in places... Hundreds of places, according to git-grep.

Quoted 3 lines
(quoted diff) +0 -1
---

But to get there we need to update the QAPI generators first :)