aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-05-05 17:29:22 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-05-15 07:07:58 +0200
commitd2623129a7dec1d3041ad1221dda1ca49c667532 (patch)
tree9bcac33dfaed2361cd536856159b9960135ccd46 /hw/s390x
parent9f742c28f52d55ff83dc441a0cea365239a4906d (diff)
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with the same name already exists. Since our property names are all hardcoded, failure is a programming error, and the appropriate way to handle it is passing &error_abort. Same for its variants, except for object_property_add_child(), which additionally fails when the child already has a parent. Parentage is also under program control, so this is a programming error, too. We have a bit over 500 callers. Almost half of them pass &error_abort, slightly fewer ignore errors, one test case handles errors, and the remaining few callers pass them to their own callers. The previous few commits demonstrated once again that ignoring programming errors is a bad idea. Of the few ones that pass on errors, several violate the Error API. The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. ich9_pm_add_properties(), sparc32_ledma_realize(), sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize() are wrong that way. When the one appropriate choice of argument is &error_abort, letting users pick the argument is a bad idea. Drop parameter @errp and assert the preconditions instead. There's one exception to "duplicate property name is a programming error": the way object_property_add() implements the magic (and undocumented) "automatic arrayification". Don't drop @errp there. Instead, rename object_property_add() to object_property_try_add(), and add the obvious wrapper object_property_add(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200505152926.18877-15-armbru@redhat.com> [Two semantic rebase conflicts resolved]
Diffstat (limited to 'hw/s390x')
-rw-r--r--hw/s390x/ap-bridge.c2
-rw-r--r--hw/s390x/css-bridge.c4
-rw-r--r--hw/s390x/event-facility.c6
-rw-r--r--hw/s390x/s390-skeys.c4
-rw-r--r--hw/s390x/s390-stattrib.c4
-rw-r--r--hw/s390x/s390-virtio-ccw.c10
-rw-r--r--hw/s390x/sclp.c5
-rw-r--r--hw/s390x/tod.c2
-rw-r--r--hw/s390x/virtio-ccw-balloon.c4
-rw-r--r--hw/s390x/virtio-ccw-blk.c2
-rw-r--r--hw/s390x/virtio-ccw-net.c2
11 files changed, 22 insertions, 23 deletions
diff --git a/hw/s390x/ap-bridge.c b/hw/s390x/ap-bridge.c
index 9284de4eec..d0dbd0f1b6 100644
--- a/hw/s390x/ap-bridge.c
+++ b/hw/s390x/ap-bridge.c
@@ -51,7 +51,7 @@ void s390_init_ap(void)
/* Create bridge device */
dev = qdev_create(NULL, TYPE_AP_BRIDGE);
object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE,
- OBJECT(dev), NULL);
+ OBJECT(dev));
qdev_init_nofail(dev);
/* Create bus on bridge device */
diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c
index c9ce06b043..5d5286bc6e 100644
--- a/hw/s390x/css-bridge.c
+++ b/hw/s390x/css-bridge.c
@@ -103,7 +103,7 @@ VirtualCssBus *virtual_css_bus_init(void)
/* Create bridge device */
dev = qdev_create(NULL, TYPE_VIRTUAL_CSS_BRIDGE);
object_property_add_child(qdev_get_machine(), TYPE_VIRTUAL_CSS_BRIDGE,
- OBJECT(dev), NULL);
+ OBJECT(dev));
qdev_init_nofail(dev);
/* Create bus on bridge device */
@@ -141,7 +141,7 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
device_class_set_props(dc, virtual_css_bridge_properties);
object_class_property_add_bool(klass, "cssid-unrestricted",
- prop_get_true, NULL, NULL);
+ prop_get_true, NULL);
object_class_property_set_description(klass, "cssid-unrestricted",
"A css device can use any cssid, regardless whether virtual"
" or not (read only, always true)");
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 9d6972afa8..97a4f0b1f5 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -449,18 +449,18 @@ static void init_event_facility(Object *obj)
event_facility->allow_all_mask_sizes = true;
object_property_add_bool(obj, "allow_all_mask_sizes",
sclp_event_get_allow_all_mask_sizes,
- sclp_event_set_allow_all_mask_sizes, NULL);
+ sclp_event_set_allow_all_mask_sizes);
/* Spawn a new bus for SCLP events */
qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),
TYPE_SCLP_EVENTS_BUS, sdev, NULL);
new = object_new(TYPE_SCLP_QUIESCE);
- object_property_add_child(obj, TYPE_SCLP_QUIESCE, new, NULL);
+ object_property_add_child(obj, TYPE_SCLP_QUIESCE, new);
object_unref(new);
qdev_set_parent_bus(DEVICE(new), BUS(&event_facility->sbus));
new = object_new(TYPE_SCLP_CPU_HOTPLUG);
- object_property_add_child(obj, TYPE_SCLP_CPU_HOTPLUG, new, NULL);
+ object_property_add_child(obj, TYPE_SCLP_CPU_HOTPLUG, new);
object_unref(new);
qdev_set_parent_bus(DEVICE(new), BUS(&event_facility->sbus));
/* the facility will automatically realize the devices via the bus */
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index a9a4ae7b39..d304b85640 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -45,7 +45,7 @@ void s390_skeys_init(void)
obj = object_new(TYPE_QEMU_S390_SKEYS);
}
object_property_add_child(qdev_get_machine(), TYPE_S390_SKEYS,
- obj, NULL);
+ obj);
object_unref(obj);
qdev_init_nofail(DEVICE(obj));
@@ -400,7 +400,7 @@ static void s390_skeys_instance_init(Object *obj)
{
object_property_add_bool(obj, "migration-enabled",
s390_skeys_get_migration_enabled,
- s390_skeys_set_migration_enabled, NULL);
+ s390_skeys_set_migration_enabled);
object_property_set_bool(obj, true, "migration-enabled", NULL);
}
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 58121b9f68..6d1e587527 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -47,7 +47,7 @@ void s390_stattrib_init(void)
}
object_property_add_child(qdev_get_machine(), TYPE_S390_STATTRIB,
- obj, NULL);
+ obj);
object_unref(obj);
qdev_init_nofail(DEVICE(obj));
@@ -387,7 +387,7 @@ static void s390_stattrib_instance_init(Object *obj)
object_property_add_bool(obj, "migration-enabled",
s390_stattrib_get_migration_enabled,
- s390_stattrib_set_migration_enabled, NULL);
+ s390_stattrib_set_migration_enabled);
object_property_set_bool(obj, true, "migration-enabled", NULL);
sas->migration_cur_gfn = 0;
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 2f94061ff6..67ae2e02ff 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -208,7 +208,7 @@ static void s390_init_ipl_dev(const char *kernel_filename,
}
g_free(netboot_fw_prop);
object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
- new, NULL);
+ new);
object_unref(new);
qdev_init_nofail(dev);
}
@@ -271,7 +271,7 @@ static void ccw_init(MachineState *machine)
dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE);
object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE,
- OBJECT(dev), NULL);
+ OBJECT(dev));
qdev_init_nofail(dev);
/* register hypercalls */
@@ -729,19 +729,19 @@ static inline void s390_machine_initfn(Object *obj)
{
object_property_add_bool(obj, "aes-key-wrap",
machine_get_aes_key_wrap,
- machine_set_aes_key_wrap, NULL);
+ machine_set_aes_key_wrap);
object_property_set_description(obj, "aes-key-wrap",
"enable/disable AES key wrapping using the CPACF wrapping key");
object_property_set_bool(obj, true, "aes-key-wrap", NULL);
object_property_add_bool(obj, "dea-key-wrap",
machine_get_dea_key_wrap,
- machine_set_dea_key_wrap, NULL);
+ machine_set_dea_key_wrap);
object_property_set_description(obj, "dea-key-wrap",
"enable/disable DEA key wrapping using the CPACF wrapping key");
object_property_set_bool(obj, true, "dea-key-wrap", NULL);
object_property_add_str(obj, "loadparm",
- machine_get_loadparm, machine_set_loadparm, NULL);
+ machine_get_loadparm, machine_set_loadparm);
object_property_set_description(obj, "loadparm",
"Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
" to upper case) to pass to machine loader, boot manager,"
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index ede056b3ef..43cc1e0a41 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -320,8 +320,7 @@ void s390_sclp_init(void)
{
Object *new = object_new(TYPE_SCLP);
- object_property_add_child(qdev_get_machine(), TYPE_SCLP, new,
- NULL);
+ object_property_add_child(qdev_get_machine(), TYPE_SCLP, new);
object_unref(OBJECT(new));
qdev_init_nofail(DEVICE(new));
}
@@ -383,7 +382,7 @@ static void sclp_init(Object *obj)
Object *new;
new = object_new(TYPE_SCLP_EVENT_FACILITY);
- object_property_add_child(obj, TYPE_SCLP_EVENT_FACILITY, new, NULL);
+ object_property_add_child(obj, TYPE_SCLP_EVENT_FACILITY, new);
object_unref(new);
sclp->event_facility = EVENT_FACILITY(new);
diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c
index 2499d6f656..7324e37b5e 100644
--- a/hw/s390x/tod.c
+++ b/hw/s390x/tod.c
@@ -26,7 +26,7 @@ void s390_init_tod(void)
} else {
obj = object_new(TYPE_QEMU_S390_TOD);
}
- object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj, NULL);
+ object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj);
object_unref(obj);
qdev_init_nofail(DEVICE(obj));
diff --git a/hw/s390x/virtio-ccw-balloon.c b/hw/s390x/virtio-ccw-balloon.c
index 5d28e72345..ef3308ecab 100644
--- a/hw/s390x/virtio-ccw-balloon.c
+++ b/hw/s390x/virtio-ccw-balloon.c
@@ -32,10 +32,10 @@ static void virtio_ccw_balloon_instance_init(Object *obj)
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_BALLOON);
object_property_add_alias(obj, "guest-stats", OBJECT(&dev->vdev),
- "guest-stats", &error_abort);
+ "guest-stats");
object_property_add_alias(obj, "guest-stats-polling-interval",
OBJECT(&dev->vdev),
- "guest-stats-polling-interval", &error_abort);
+ "guest-stats-polling-interval");
}
static Property virtio_ccw_balloon_properties[] = {
diff --git a/hw/s390x/virtio-ccw-blk.c b/hw/s390x/virtio-ccw-blk.c
index bf8520e60a..7287932b7e 100644
--- a/hw/s390x/virtio-ccw-blk.c
+++ b/hw/s390x/virtio-ccw-blk.c
@@ -32,7 +32,7 @@ static void virtio_ccw_blk_instance_init(Object *obj)
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_BLK);
object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
- "bootindex", &error_abort);
+ "bootindex");
}
static Property virtio_ccw_blk_properties[] = {
diff --git a/hw/s390x/virtio-ccw-net.c b/hw/s390x/virtio-ccw-net.c
index cd02699934..26c4d873bf 100644
--- a/hw/s390x/virtio-ccw-net.c
+++ b/hw/s390x/virtio-ccw-net.c
@@ -35,7 +35,7 @@ static void virtio_ccw_net_instance_init(Object *obj)
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_NET);
object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
- "bootindex", &error_abort);
+ "bootindex");
}
static Property virtio_ccw_net_properties[] = {