* [PATCH 0/2] Resolve some redundant property accessors
@ 2022-02-17 22:53 Bernhard Beschow
2022-02-17 22:53 ` [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters Bernhard Beschow
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-17 22:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Bernhard Beschow
The QOM API already provides appropriate accessors, so reuse them.
Testing done:
:$ make check
Ok: 569
Expected Fail: 0
Fail: 0
Unexpected Pass: 0
Skipped: 178
Timeout: 0
Bernhard Beschow (2):
hw/vfio/pci-quirks: Resolve redundant property getters
hw/riscv/sifive_u: Resolve redundant property accessors
hw/riscv/sifive_u.c | 24 ++++--------------------
hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
2 files changed, 13 insertions(+), 45 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
@ 2022-02-17 22:53 ` Bernhard Beschow
2022-02-21 22:24 ` Philippe Mathieu-Daudé
2022-02-17 22:53 ` [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter Bernhard Beschow
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-17 22:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Williamson, Bernhard Beschow
The QOM API already provides getters for uint64 and uint32 values, so reuse
them.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 0cf69a8c6d..f0147a050a 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1565,22 +1565,6 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
return 0;
}
-static void 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);
-}
-
-static void 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);
-}
-
int vfio_pci_nvidia_v100_ram_init(VFIOPCIDevice *vdev, Error **errp)
{
int ret;
@@ -1618,9 +1602,9 @@ int vfio_pci_nvidia_v100_ram_init(VFIOPCIDevice *vdev, Error **errp)
nv2reg->size, p);
QLIST_INSERT_HEAD(&vdev->bars[0].quirks, quirk, next);
- object_property_add(OBJECT(vdev), "nvlink2-tgt", "uint64",
- vfio_pci_nvlink2_get_tgt, NULL, NULL,
- (void *) (uintptr_t) cap->tgt);
+ object_property_add_uint64_ptr(OBJECT(vdev), "nvlink2-tgt",
+ (uint64_t *) &cap->tgt,
+ OBJ_PROP_FLAG_READ);
trace_vfio_pci_nvidia_gpu_setup_quirk(vdev->vbasedev.name, cap->tgt,
nv2reg->size);
free_exit:
@@ -1679,15 +1663,15 @@ int vfio_pci_nvlink2_init(VFIOPCIDevice *vdev, Error **errp)
QLIST_INSERT_HEAD(&vdev->bars[0].quirks, quirk, next);
}
- object_property_add(OBJECT(vdev), "nvlink2-tgt", "uint64",
- vfio_pci_nvlink2_get_tgt, NULL, NULL,
- (void *) (uintptr_t) captgt->tgt);
+ object_property_add_uint64_ptr(OBJECT(vdev), "nvlink2-tgt",
+ (uint64_t *) &captgt->tgt,
+ OBJ_PROP_FLAG_READ);
trace_vfio_pci_nvlink2_setup_quirk_ssatgt(vdev->vbasedev.name, captgt->tgt,
atsdreg->size);
- object_property_add(OBJECT(vdev), "nvlink2-link-speed", "uint32",
- vfio_pci_nvlink2_get_link_speed, NULL, NULL,
- (void *) (uintptr_t) capspeed->link_speed);
+ object_property_add_uint32_ptr(OBJECT(vdev), "nvlink2-link-speed",
+ &capspeed->link_speed,
+ OBJ_PROP_FLAG_READ);
trace_vfio_pci_nvlink2_setup_quirk_lnkspd(vdev->vbasedev.name,
capspeed->link_speed);
free_exit:
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
2022-02-17 22:53 ` [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters Bernhard Beschow
@ 2022-02-17 22:53 ` Bernhard Beschow
2022-02-25 20:40 ` Bernhard Beschow
2022-02-26 8:37 ` David Hildenbrand
2022-02-17 22:53 ` Bernhard Beschow
` (2 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-17 22:53 UTC (permalink / raw)
To: qemu-devel; +Cc: David Hildenbrand, Bernhard Beschow, Michael S. Tsirkin
*opaque is an alias to *obj. Using the ladder makes the code consistent with
with other devices, e.g. accel/kvm/kvm-all and accel/tcg/tcg-all. It also
makes the cast more typesafe.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/virtio/virtio-balloon.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 9a4f491b54..38732d4118 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -241,7 +241,7 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Error *err = NULL;
- VirtIOBalloon *s = opaque;
+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
int i;
if (!visit_start_struct(v, name, NULL, 0, &err)) {
@@ -276,7 +276,7 @@ static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
- VirtIOBalloon *s = opaque;
+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
visit_type_int(v, name, &s->stats_poll_interval, errp);
}
@@ -284,7 +284,7 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
- VirtIOBalloon *s = opaque;
+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
int64_t value;
if (!visit_type_int(v, name, &value, errp)) {
@@ -1014,12 +1014,12 @@ static void virtio_balloon_instance_init(Object *obj)
s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify;
object_property_add(obj, "guest-stats", "guest statistics",
- balloon_stats_get_all, NULL, NULL, s);
+ balloon_stats_get_all, NULL, NULL, NULL);
object_property_add(obj, "guest-stats-polling-interval", "int",
balloon_stats_get_poll_interval,
balloon_stats_set_poll_interval,
- NULL, s);
+ NULL, NULL);
}
static const VMStateDescription vmstate_virtio_balloon = {
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
@ 2022-02-17 22:53 ` Bernhard Beschow
2022-02-17 22:53 ` [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter Bernhard Beschow
` (3 subsequent siblings)
4 siblings, 0 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-17 22:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alistair Francis, Bin Meng, Bernhard Beschow, Palmer Dabbelt,
open list:SiFive Machines
The QOM API already provides accessors for uint32 values, so reuse them.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/riscv/sifive_u.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 7fbc7dea42..747eb4ee89 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -713,36 +713,20 @@ 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,
- const char *name, void *opaque,
- Error **errp)
-{
- visit_type_uint32(v, name, (uint32_t *)opaque, errp);
-}
-
-static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v,
- const char *name, void *opaque,
- Error **errp)
-{
- visit_type_uint32(v, name, (uint32_t *)opaque, errp);
-}
-
static void sifive_u_machine_instance_init(Object *obj)
{
SiFiveUState *s = RISCV_U_MACHINE(obj);
s->start_in_flash = false;
s->msel = 0;
- object_property_add(obj, "msel", "uint32",
- sifive_u_machine_get_uint32_prop,
- sifive_u_machine_set_uint32_prop, NULL, &s->msel);
+ object_property_add_uint32_ptr(obj, "msel", &s->msel,
+ OBJ_PROP_FLAG_READWRITE);
object_property_set_description(obj, "msel",
"Mode Select (MSEL[3:0]) pin state");
s->serial = OTP_SERIAL;
- object_property_add(obj, "serial", "uint32",
- sifive_u_machine_get_uint32_prop,
- sifive_u_machine_set_uint32_prop, NULL, &s->serial);
+ object_property_add_uint32_ptr(obj, "serial", &s->serial,
+ OBJ_PROP_FLAG_READWRITE);
object_property_set_description(obj, "serial", "Board serial number");
}
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
@ 2022-02-17 22:53 ` Bernhard Beschow
0 siblings, 0 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-17 22:53 UTC (permalink / raw)
To: qemu-devel
Cc: Bernhard Beschow, Alistair Francis, Bin Meng, Palmer Dabbelt,
open list:SiFive Machines
The QOM API already provides accessors for uint32 values, so reuse them.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/riscv/sifive_u.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 7fbc7dea42..747eb4ee89 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -713,36 +713,20 @@ 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,
- const char *name, void *opaque,
- Error **errp)
-{
- visit_type_uint32(v, name, (uint32_t *)opaque, errp);
-}
-
-static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v,
- const char *name, void *opaque,
- Error **errp)
-{
- visit_type_uint32(v, name, (uint32_t *)opaque, errp);
-}
-
static void sifive_u_machine_instance_init(Object *obj)
{
SiFiveUState *s = RISCV_U_MACHINE(obj);
s->start_in_flash = false;
s->msel = 0;
- object_property_add(obj, "msel", "uint32",
- sifive_u_machine_get_uint32_prop,
- sifive_u_machine_set_uint32_prop, NULL, &s->msel);
+ object_property_add_uint32_ptr(obj, "msel", &s->msel,
+ OBJ_PROP_FLAG_READWRITE);
object_property_set_description(obj, "msel",
"Mode Select (MSEL[3:0]) pin state");
s->serial = OTP_SERIAL;
- object_property_add(obj, "serial", "uint32",
- sifive_u_machine_get_uint32_prop,
- sifive_u_machine_set_uint32_prop, NULL, &s->serial);
+ object_property_add_uint32_ptr(obj, "serial", &s->serial,
+ OBJ_PROP_FLAG_READWRITE);
object_property_set_description(obj, "serial", "Board serial number");
}
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
2022-02-17 22:53 ` Bernhard Beschow
@ 2022-02-21 21:45 ` Alistair Francis
-1 siblings, 0 replies; 16+ messages in thread
From: Alistair Francis @ 2022-02-21 21:45 UTC (permalink / raw)
To: Bernhard Beschow
Cc: Palmer Dabbelt, Bin Meng, Alistair Francis,
qemu-devel@nongnu.org Developers, open list:SiFive Machines
On Fri, Feb 18, 2022 at 8:54 AM Bernhard Beschow <shentey@gmail.com> wrote:
>
> The QOM API already provides accessors for uint32 values, so reuse them.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_u.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 7fbc7dea42..747eb4ee89 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -713,36 +713,20 @@ 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,
> - const char *name, void *opaque,
> - Error **errp)
> -{
> - visit_type_uint32(v, name, (uint32_t *)opaque, errp);
> -}
> -
> -static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v,
> - const char *name, void *opaque,
> - Error **errp)
> -{
> - visit_type_uint32(v, name, (uint32_t *)opaque, errp);
> -}
> -
> static void sifive_u_machine_instance_init(Object *obj)
> {
> SiFiveUState *s = RISCV_U_MACHINE(obj);
>
> s->start_in_flash = false;
> s->msel = 0;
> - object_property_add(obj, "msel", "uint32",
> - sifive_u_machine_get_uint32_prop,
> - sifive_u_machine_set_uint32_prop, NULL, &s->msel);
> + object_property_add_uint32_ptr(obj, "msel", &s->msel,
> + OBJ_PROP_FLAG_READWRITE);
> object_property_set_description(obj, "msel",
> "Mode Select (MSEL[3:0]) pin state");
>
> s->serial = OTP_SERIAL;
> - object_property_add(obj, "serial", "uint32",
> - sifive_u_machine_get_uint32_prop,
> - sifive_u_machine_set_uint32_prop, NULL, &s->serial);
> + object_property_add_uint32_ptr(obj, "serial", &s->serial,
> + OBJ_PROP_FLAG_READWRITE);
> object_property_set_description(obj, "serial", "Board serial number");
> }
>
> --
> 2.35.1
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
@ 2022-02-21 21:45 ` Alistair Francis
0 siblings, 0 replies; 16+ messages in thread
From: Alistair Francis @ 2022-02-21 21:45 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel@nongnu.org Developers, Alistair Francis, Bin Meng,
Palmer Dabbelt, open list:SiFive Machines
On Fri, Feb 18, 2022 at 8:54 AM Bernhard Beschow <shentey@gmail.com> wrote:
>
> The QOM API already provides accessors for uint32 values, so reuse them.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_u.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 7fbc7dea42..747eb4ee89 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -713,36 +713,20 @@ 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,
> - const char *name, void *opaque,
> - Error **errp)
> -{
> - visit_type_uint32(v, name, (uint32_t *)opaque, errp);
> -}
> -
> -static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v,
> - const char *name, void *opaque,
> - Error **errp)
> -{
> - visit_type_uint32(v, name, (uint32_t *)opaque, errp);
> -}
> -
> static void sifive_u_machine_instance_init(Object *obj)
> {
> SiFiveUState *s = RISCV_U_MACHINE(obj);
>
> s->start_in_flash = false;
> s->msel = 0;
> - object_property_add(obj, "msel", "uint32",
> - sifive_u_machine_get_uint32_prop,
> - sifive_u_machine_set_uint32_prop, NULL, &s->msel);
> + object_property_add_uint32_ptr(obj, "msel", &s->msel,
> + OBJ_PROP_FLAG_READWRITE);
> object_property_set_description(obj, "msel",
> "Mode Select (MSEL[3:0]) pin state");
>
> s->serial = OTP_SERIAL;
> - object_property_add(obj, "serial", "uint32",
> - sifive_u_machine_get_uint32_prop,
> - sifive_u_machine_set_uint32_prop, NULL, &s->serial);
> + object_property_add_uint32_ptr(obj, "serial", &s->serial,
> + OBJ_PROP_FLAG_READWRITE);
> object_property_set_description(obj, "serial", "Board serial number");
> }
>
> --
> 2.35.1
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters
2022-02-17 22:53 ` [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters Bernhard Beschow
@ 2022-02-21 22:24 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 22:24 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel; +Cc: Alex Williamson
On 17/2/22 23:53, Bernhard Beschow wrote:
> The QOM API already provides getters for uint64 and uint32 values, so reuse
> them.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
> 1 file changed, 9 insertions(+), 25 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
2022-02-17 22:53 ` Bernhard Beschow
@ 2022-02-21 22:26 ` Philippe Mathieu-Daudé
-1 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 22:26 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Palmer Dabbelt, Bin Meng, Alistair Francis, open list:SiFive Machines
On 17/2/22 23:53, Bernhard Beschow wrote:
> The QOM API already provides accessors for uint32 values, so reuse them.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> hw/riscv/sifive_u.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors
@ 2022-02-21 22:26 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 22:26 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Alistair Francis, Bin Meng, Palmer Dabbelt, open list:SiFive Machines
On 17/2/22 23:53, Bernhard Beschow wrote:
> The QOM API already provides accessors for uint32 values, so reuse them.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> hw/riscv/sifive_u.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/2] Resolve some redundant property accessors
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
` (2 preceding siblings ...)
2022-02-17 22:53 ` Bernhard Beschow
@ 2022-02-21 22:28 ` Philippe Mathieu-Daudé
2022-02-21 22:52 ` Bernhard Beschow
2022-02-25 20:48 ` Bernhard Beschow
4 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 22:28 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
On 17/2/22 23:53, Bernhard Beschow wrote:
> The QOM API already provides appropriate accessors, so reuse them.
>
> Testing done:
>
> :$ make check
> Ok: 569
> Expected Fail: 0
> Fail: 0
> Unexpected Pass: 0
> Skipped: 178
> Timeout: 0
>
> Bernhard Beschow (2):
> hw/vfio/pci-quirks: Resolve redundant property getters
> hw/riscv/sifive_u: Resolve redundant property accessors
Good cleanup.
You might want to play with Coccinelle spatch [*] to clean all uses:
$ git grep object_property_add\(.*uint
hw/acpi/ich9.c:446: object_property_add(obj, ACPI_PM_PROP_GPE0_BLK,
"uint32",
hw/i386/sgx-epc.c:47: object_property_add(obj, SGX_EPC_SIZE_PROP,
"uint64", sgx_epc_get_size,
hw/intc/apic_common.c:462: object_property_add(obj, "id", "uint32",
hw/mem/pc-dimm.c:175: object_property_add(obj, PC_DIMM_SIZE_PROP,
"uint64", pc_dimm_get_size,
hw/misc/aspeed_lpc.c:420: object_property_add(obj, "idr1", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:422: object_property_add(obj, "odr1", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:424: object_property_add(obj, "str1", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:426: object_property_add(obj, "idr2", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:428: object_property_add(obj, "odr2", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:430: object_property_add(obj, "str2", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:432: object_property_add(obj, "idr3", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:434: object_property_add(obj, "odr3", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:436: object_property_add(obj, "str3", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:438: object_property_add(obj, "idr4", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:440: object_property_add(obj, "odr4", "uint32",
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:442: object_property_add(obj, "str4", "uint32",
aspeed_kcs_get_register_property,
hw/misc/npcm7xx_mft.c:493: object_property_add(obj, "max_rpm[*]",
"uint32",
hw/nvme/ctrl.c:6856: object_property_add(obj,
"smart_critical_warning", "uint8",
hw/pci-host/q35.c:224: object_property_add(obj,
PCI_HOST_PROP_PCI_HOLE_START, "uint32",
hw/pci-host/q35.c:228: object_property_add(obj,
PCI_HOST_PROP_PCI_HOLE_END, "uint32",
hw/pci-host/q35.c:232: object_property_add(obj,
PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
hw/pci-host/q35.c:236: object_property_add(obj,
PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
hw/ppc/spapr_drc.c:584: object_property_add(obj, "index", "uint32",
prop_get_index,
hw/riscv/sifive_u.c:736: object_property_add(obj, "msel", "uint32",
hw/riscv/sifive_u.c:743: object_property_add(obj, "serial", "uint32",
hw/sensor/adm1272.c:497: object_property_add(obj, "vin", "uint16",
hw/sensor/adm1272.c:501: object_property_add(obj, "vout", "uint16",
hw/sensor/adm1272.c:505: object_property_add(obj, "iout", "uint16",
hw/sensor/adm1272.c:509: object_property_add(obj, "pin", "uint16",
hw/sensor/max34451.c:730: object_property_add(obj, "vout[*]",
"uint16",
hw/sensor/max34451.c:740: object_property_add(obj,
"temperature[*]", "uint16",
hw/vfio/pci-quirks.c:1621: object_property_add(OBJECT(vdev),
"nvlink2-tgt", "uint64",
hw/vfio/pci-quirks.c:1682: object_property_add(OBJECT(vdev),
"nvlink2-tgt", "uint64",
hw/vfio/pci-quirks.c:1688: object_property_add(OBJECT(vdev),
"nvlink2-link-speed", "uint32",
net/colo-compare.c:1390: object_property_add(obj, "compare_timeout",
"uint64",
net/colo-compare.c:1394: object_property_add(obj,
"expired_scan_cycle", "uint32",
net/colo-compare.c:1398: object_property_add(obj, "max_queue_size",
"uint32",
softmmu/memory.c:1262: object_property_add(OBJECT(mr), "priority",
"uint32",
softmmu/memory.c:1266: object_property_add(OBJECT(mr), "size", "uint64",
target/arm/cpu64.c:863: object_property_add(obj, "sve-max-vq",
"uint32", cpu_max_get_sve_max_vq,
tests/unit/test-qdev-global-props.c:155: object_property_add(obj,
"prop1", "uint32", prop1_accessor, prop1_accessor,
tests/unit/test-qdev-global-props.c:157: object_property_add(obj,
"prop2", "uint32", prop2_accessor, prop2_accessor,
[*] https://coccinelle.gitlabpages.inria.fr/website/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/2] Resolve some redundant property accessors
2022-02-21 22:28 ` [PATCH 0/2] Resolve some " Philippe Mathieu-Daudé
@ 2022-02-21 22:52 ` Bernhard Beschow
0 siblings, 0 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-21 22:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Am 21. Februar 2022 22:28:00 UTC schrieb "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>:
>On 17/2/22 23:53, Bernhard Beschow wrote:
>> The QOM API already provides appropriate accessors, so reuse them.
>>
>> Testing done:
>>
>> :$ make check
>> Ok: 569
>> Expected Fail: 0
>> Fail: 0
>> Unexpected Pass: 0
>> Skipped: 178
>> Timeout: 0
>>
>> Bernhard Beschow (2):
>> hw/vfio/pci-quirks: Resolve redundant property getters
>> hw/riscv/sifive_u: Resolve redundant property accessors
>
>Good cleanup.
>
>You might want to play with Coccinelle spatch [*] to clean all uses:
Hi Philippe,
thanks for your review!
I've manually inspected most (all?) of them and found that the remaining setters were non-trivial, i.e. they do some extra stuff such as checking boundaries or invoking some extra actions. Do you have an idea how to deal with that?
Regards,
Bernhard
>$ git grep object_property_add\(.*uint
>hw/acpi/ich9.c:446: object_property_add(obj, ACPI_PM_PROP_GPE0_BLK,
>"uint32",
>hw/i386/sgx-epc.c:47: object_property_add(obj, SGX_EPC_SIZE_PROP,
>"uint64", sgx_epc_get_size,
>hw/intc/apic_common.c:462: object_property_add(obj, "id", "uint32",
>hw/mem/pc-dimm.c:175: object_property_add(obj, PC_DIMM_SIZE_PROP,
>"uint64", pc_dimm_get_size,
>hw/misc/aspeed_lpc.c:420: object_property_add(obj, "idr1", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:422: object_property_add(obj, "odr1", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:424: object_property_add(obj, "str1", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:426: object_property_add(obj, "idr2", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:428: object_property_add(obj, "odr2", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:430: object_property_add(obj, "str2", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:432: object_property_add(obj, "idr3", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:434: object_property_add(obj, "odr3", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:436: object_property_add(obj, "str3", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:438: object_property_add(obj, "idr4", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:440: object_property_add(obj, "odr4", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:442: object_property_add(obj, "str4", "uint32",
>aspeed_kcs_get_register_property,
>hw/misc/npcm7xx_mft.c:493: object_property_add(obj, "max_rpm[*]",
>"uint32",
>hw/nvme/ctrl.c:6856: object_property_add(obj,
>"smart_critical_warning", "uint8",
>hw/pci-host/q35.c:224: object_property_add(obj,
>PCI_HOST_PROP_PCI_HOLE_START, "uint32",
>hw/pci-host/q35.c:228: object_property_add(obj,
>PCI_HOST_PROP_PCI_HOLE_END, "uint32",
>hw/pci-host/q35.c:232: object_property_add(obj,
>PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
>hw/pci-host/q35.c:236: object_property_add(obj,
>PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
>hw/ppc/spapr_drc.c:584: object_property_add(obj, "index", "uint32",
>prop_get_index,
>hw/riscv/sifive_u.c:736: object_property_add(obj, "msel", "uint32",
>hw/riscv/sifive_u.c:743: object_property_add(obj, "serial", "uint32",
>hw/sensor/adm1272.c:497: object_property_add(obj, "vin", "uint16",
>hw/sensor/adm1272.c:501: object_property_add(obj, "vout", "uint16",
>hw/sensor/adm1272.c:505: object_property_add(obj, "iout", "uint16",
>hw/sensor/adm1272.c:509: object_property_add(obj, "pin", "uint16",
>hw/sensor/max34451.c:730: object_property_add(obj, "vout[*]",
>"uint16",
>hw/sensor/max34451.c:740: object_property_add(obj,
>"temperature[*]", "uint16",
>hw/vfio/pci-quirks.c:1621: object_property_add(OBJECT(vdev),
>"nvlink2-tgt", "uint64",
>hw/vfio/pci-quirks.c:1682: object_property_add(OBJECT(vdev),
>"nvlink2-tgt", "uint64",
>hw/vfio/pci-quirks.c:1688: object_property_add(OBJECT(vdev),
>"nvlink2-link-speed", "uint32",
>net/colo-compare.c:1390: object_property_add(obj, "compare_timeout",
>"uint64",
>net/colo-compare.c:1394: object_property_add(obj,
>"expired_scan_cycle", "uint32",
>net/colo-compare.c:1398: object_property_add(obj, "max_queue_size",
>"uint32",
>softmmu/memory.c:1262: object_property_add(OBJECT(mr), "priority",
>"uint32",
>softmmu/memory.c:1266: object_property_add(OBJECT(mr), "size", "uint64",
>target/arm/cpu64.c:863: object_property_add(obj, "sve-max-vq",
>"uint32", cpu_max_get_sve_max_vq,
>tests/unit/test-qdev-global-props.c:155: object_property_add(obj,
>"prop1", "uint32", prop1_accessor, prop1_accessor,
>tests/unit/test-qdev-global-props.c:157: object_property_add(obj,
>"prop2", "uint32", prop2_accessor, prop2_accessor,
>
>[*] https://coccinelle.gitlabpages.inria.fr/website/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter
2022-02-17 22:53 ` [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter Bernhard Beschow
@ 2022-02-25 20:40 ` Bernhard Beschow
2022-02-27 10:23 ` Michael S. Tsirkin
2022-02-26 8:37 ` David Hildenbrand
1 sibling, 1 reply; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-25 20:40 UTC (permalink / raw)
To: qemu-devel; +Cc: David Hildenbrand, Michael S. Tsirkin
Am 17. Februar 2022 22:53:50 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>*opaque is an alias to *obj. Using the ladder makes the code consistent with
>with other devices, e.g. accel/kvm/kvm-all and accel/tcg/tcg-all. It also
>makes the cast more typesafe.
>
>Signed-off-by: Bernhard Beschow <shentey@gmail.com>
>---
> hw/virtio/virtio-balloon.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
>index 9a4f491b54..38732d4118 100644
>--- a/hw/virtio/virtio-balloon.c
>+++ b/hw/virtio/virtio-balloon.c
>@@ -241,7 +241,7 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
> void *opaque, Error **errp)
> {
> Error *err = NULL;
>- VirtIOBalloon *s = opaque;
>+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> int i;
>
> if (!visit_start_struct(v, name, NULL, 0, &err)) {
>@@ -276,7 +276,7 @@ static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
> const char *name, void *opaque,
> Error **errp)
> {
>- VirtIOBalloon *s = opaque;
>+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> visit_type_int(v, name, &s->stats_poll_interval, errp);
> }
>
>@@ -284,7 +284,7 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
> const char *name, void *opaque,
> Error **errp)
> {
>- VirtIOBalloon *s = opaque;
>+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> int64_t value;
>
> if (!visit_type_int(v, name, &value, errp)) {
>@@ -1014,12 +1014,12 @@ static void virtio_balloon_instance_init(Object *obj)
> s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify;
>
> object_property_add(obj, "guest-stats", "guest statistics",
>- balloon_stats_get_all, NULL, NULL, s);
>+ balloon_stats_get_all, NULL, NULL, NULL);
>
> object_property_add(obj, "guest-stats-polling-interval", "int",
> balloon_stats_get_poll_interval,
> balloon_stats_set_poll_interval,
>- NULL, s);
>+ NULL, NULL);
> }
>
> static const VMStateDescription vmstate_virtio_balloon = {
Ping
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/2] Resolve some redundant property accessors
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
` (3 preceding siblings ...)
2022-02-21 22:28 ` [PATCH 0/2] Resolve some " Philippe Mathieu-Daudé
@ 2022-02-25 20:48 ` Bernhard Beschow
4 siblings, 0 replies; 16+ messages in thread
From: Bernhard Beschow @ 2022-02-25 20:48 UTC (permalink / raw)
To: qemu-devel
Am 17. Februar 2022 22:53:48 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>The QOM API already provides appropriate accessors, so reuse them.
>
>Testing done:
>
> :$ make check
> Ok: 569
> Expected Fail: 0
> Fail: 0
> Unexpected Pass: 0
> Skipped: 178
> Timeout: 0
>
>Bernhard Beschow (2):
> hw/vfio/pci-quirks: Resolve redundant property getters
> hw/riscv/sifive_u: Resolve redundant property accessors
>
> hw/riscv/sifive_u.c | 24 ++++--------------------
> hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
> 2 files changed, 13 insertions(+), 45 deletions(-)
>
Hi,
all 2 patches in this series are reviewed. What's missing?
Note: The lonely [PATCH] slipped underneath this series. Is this a problem?It was supposed to be submitted toplevel but git send-email doesn't seem to support sending multiple independent series at once.
Best regards,
Bernhard
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter
2022-02-17 22:53 ` [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter Bernhard Beschow
2022-02-25 20:40 ` Bernhard Beschow
@ 2022-02-26 8:37 ` David Hildenbrand
1 sibling, 0 replies; 16+ messages in thread
From: David Hildenbrand @ 2022-02-26 8:37 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel; +Cc: Michael S. Tsirkin
On 17.02.22 23:53, Bernhard Beschow wrote:
> *opaque is an alias to *obj. Using the ladder makes the code consistent with
> with other devices, e.g. accel/kvm/kvm-all and accel/tcg/tcg-all. It also
> makes the cast more typesafe.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> hw/virtio/virtio-balloon.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 9a4f491b54..38732d4118 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -241,7 +241,7 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
> void *opaque, Error **errp)
> {
> Error *err = NULL;
> - VirtIOBalloon *s = opaque;
> + VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> int i;
>
> if (!visit_start_struct(v, name, NULL, 0, &err)) {
> @@ -276,7 +276,7 @@ static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
> const char *name, void *opaque,
> Error **errp)
> {
> - VirtIOBalloon *s = opaque;
> + VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> visit_type_int(v, name, &s->stats_poll_interval, errp);
> }
>
> @@ -284,7 +284,7 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
> const char *name, void *opaque,
> Error **errp)
> {
> - VirtIOBalloon *s = opaque;
> + VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> int64_t value;
>
> if (!visit_type_int(v, name, &value, errp)) {
> @@ -1014,12 +1014,12 @@ static void virtio_balloon_instance_init(Object *obj)
> s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify;
>
> object_property_add(obj, "guest-stats", "guest statistics",
> - balloon_stats_get_all, NULL, NULL, s);
> + balloon_stats_get_all, NULL, NULL, NULL);
>
> object_property_add(obj, "guest-stats-polling-interval", "int",
> balloon_stats_get_poll_interval,
> balloon_stats_set_poll_interval,
> - NULL, s);
> + NULL, NULL);
> }
>
> static const VMStateDescription vmstate_virtio_balloon = {
LGTM
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter
2022-02-25 20:40 ` Bernhard Beschow
@ 2022-02-27 10:23 ` Michael S. Tsirkin
0 siblings, 0 replies; 16+ messages in thread
From: Michael S. Tsirkin @ 2022-02-27 10:23 UTC (permalink / raw)
To: Bernhard Beschow; +Cc: qemu-devel, David Hildenbrand
On Fri, Feb 25, 2022 at 08:40:00PM +0000, Bernhard Beschow wrote:
> Am 17. Februar 2022 22:53:50 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
> >*opaque is an alias to *obj. Using the ladder makes the code consistent with
> >with other devices, e.g. accel/kvm/kvm-all and accel/tcg/tcg-all. It also
> >makes the cast more typesafe.
> >
> >Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Send this kind of thing to qemu-trivial pls.
> >---
> > hw/virtio/virtio-balloon.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> >diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> >index 9a4f491b54..38732d4118 100644
> >--- a/hw/virtio/virtio-balloon.c
> >+++ b/hw/virtio/virtio-balloon.c
> >@@ -241,7 +241,7 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
> > void *opaque, Error **errp)
> > {
> > Error *err = NULL;
> >- VirtIOBalloon *s = opaque;
> >+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> > int i;
> >
> > if (!visit_start_struct(v, name, NULL, 0, &err)) {
> >@@ -276,7 +276,7 @@ static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
> > const char *name, void *opaque,
> > Error **errp)
> > {
> >- VirtIOBalloon *s = opaque;
> >+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> > visit_type_int(v, name, &s->stats_poll_interval, errp);
> > }
> >
> >@@ -284,7 +284,7 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
> > const char *name, void *opaque,
> > Error **errp)
> > {
> >- VirtIOBalloon *s = opaque;
> >+ VirtIOBalloon *s = VIRTIO_BALLOON(obj);
> > int64_t value;
> >
> > if (!visit_type_int(v, name, &value, errp)) {
> >@@ -1014,12 +1014,12 @@ static void virtio_balloon_instance_init(Object *obj)
> > s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify;
> >
> > object_property_add(obj, "guest-stats", "guest statistics",
> >- balloon_stats_get_all, NULL, NULL, s);
> >+ balloon_stats_get_all, NULL, NULL, NULL);
> >
> > object_property_add(obj, "guest-stats-polling-interval", "int",
> > balloon_stats_get_poll_interval,
> > balloon_stats_set_poll_interval,
> >- NULL, s);
> >+ NULL, NULL);
> > }
> >
> > static const VMStateDescription vmstate_virtio_balloon = {
>
> Ping
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-02-27 10:25 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 22:53 [PATCH 0/2] Resolve some redundant property accessors Bernhard Beschow
2022-02-17 22:53 ` [PATCH 1/2] hw/vfio/pci-quirks: Resolve redundant property getters Bernhard Beschow
2022-02-21 22:24 ` Philippe Mathieu-Daudé
2022-02-17 22:53 ` [PATCH] virtio/virtio-balloon: Prefer Object* over void* parameter Bernhard Beschow
2022-02-25 20:40 ` Bernhard Beschow
2022-02-27 10:23 ` Michael S. Tsirkin
2022-02-26 8:37 ` David Hildenbrand
2022-02-17 22:53 ` [PATCH 2/2] hw/riscv/sifive_u: Resolve redundant property accessors Bernhard Beschow
2022-02-17 22:53 ` Bernhard Beschow
2022-02-21 21:45 ` Alistair Francis
2022-02-21 21:45 ` Alistair Francis
2022-02-21 22:26 ` Philippe Mathieu-Daudé
2022-02-21 22:26 ` Philippe Mathieu-Daudé
2022-02-21 22:28 ` [PATCH 0/2] Resolve some " Philippe Mathieu-Daudé
2022-02-21 22:52 ` Bernhard Beschow
2022-02-25 20:48 ` Bernhard Beschow
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.