mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
qom/object: Use common get/set uint helpers
Several objects implemented their own uint property getters and setters, despite them being straightforward (without any checks/validations on the values themselves) and identical across objects. This makes use of an enhanced API for object_property_add_uintXX_ptr() which offers default setters. Some of these setters used to update the value even if the type visit failed (eg. because the value being set overflowed over the given type). The new setter introduces a check for these errors, not updating the value if an error occurred. The error is propagated. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a8c1e3bbee
commit
64a7b8de42
8 changed files with 37 additions and 276 deletions
|
@ -3223,30 +3223,6 @@ static void spapr_set_resize_hpt(Object *obj, const char *value, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
static void spapr_get_vsmt(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
visit_type_uint32(v, name, (uint32_t *)opaque, errp);
|
||||
}
|
||||
|
||||
static void spapr_set_vsmt(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
visit_type_uint32(v, name, (uint32_t *)opaque, errp);
|
||||
}
|
||||
|
||||
static void spapr_get_kernel_addr(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
visit_type_uint64(v, name, (uint64_t *)opaque, errp);
|
||||
}
|
||||
|
||||
static void spapr_set_kernel_addr(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
visit_type_uint64(v, name, (uint64_t *)opaque, errp);
|
||||
}
|
||||
|
||||
static char *spapr_get_ic_mode(Object *obj, Error **errp)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||
|
@ -3344,17 +3320,19 @@ static void spapr_instance_init(Object *obj)
|
|||
object_property_set_description(obj, "resize-hpt",
|
||||
"Resizing of the Hash Page Table (enabled, disabled, required)",
|
||||
NULL);
|
||||
object_property_add(obj, "vsmt", "uint32", spapr_get_vsmt,
|
||||
spapr_set_vsmt, NULL, &spapr->vsmt, &error_abort);
|
||||
object_property_add_uint32_ptr(obj, "vsmt",
|
||||
&spapr->vsmt, OBJ_PROP_FLAG_READWRITE,
|
||||
&error_abort);
|
||||
object_property_set_description(obj, "vsmt",
|
||||
"Virtual SMT: KVM behaves as if this were"
|
||||
" the host's SMT mode", &error_abort);
|
||||
|
||||
object_property_add_bool(obj, "vfio-no-msix-emulation",
|
||||
spapr_get_msix_emulation, NULL, NULL);
|
||||
|
||||
object_property_add(obj, "kernel-addr", "uint64", spapr_get_kernel_addr,
|
||||
spapr_set_kernel_addr, NULL, &spapr->kernel_addr,
|
||||
&error_abort);
|
||||
object_property_add_uint64_ptr(obj, "kernel-addr",
|
||||
&spapr->kernel_addr, OBJ_PROP_FLAG_READWRITE,
|
||||
&error_abort);
|
||||
object_property_set_description(obj, "kernel-addr",
|
||||
stringify(KERNEL_LOAD_ADDR)
|
||||
" for -kernel is the default",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue