hw/virtio/virtio-balloon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
*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
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
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
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
© 2016 - 2026 Red Hat, Inc.