* [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
@ 2013-04-11 22:38 fred.konrad
2013-04-12 8:29 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: fred.konrad @ 2013-04-11 22:38 UTC (permalink / raw)
To: aliguori, qemu-devel
Cc: peter.maydell, mark.burton, Luiz Capitulino, cornelia.huck,
afaerber, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
To keep compatibility with the old virtio-balloon-x, add the dynamic properties
to virtio-balloon-pci and virtio-balloon-ccw.
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/s390x/virtio-ccw.c | 8 ++++++++
hw/virtio/virtio-balloon.c | 16 ++++++++--------
hw/virtio/virtio-pci.c | 8 ++++++++
include/hw/virtio/virtio-balloon.h | 9 +++++++++
4 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 4dec0cd..ea5ed6d 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -626,6 +626,14 @@ static void virtio_ccw_balloon_instance_init(Object *obj)
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj);
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BALLOON);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+
+ object_property_add(obj, "guest-stats", "guest statistics",
+ balloon_stats_get_all, NULL, NULL, &dev->vdev, NULL);
+
+ object_property_add(obj, "guest-stats-polling-interval", "int",
+ balloon_stats_get_poll_interval,
+ balloon_stats_set_poll_interval,
+ NULL, &dev->vdev, NULL);
}
static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index c2c446e..2e2ea30 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -105,8 +105,8 @@ static void balloon_stats_poll_cb(void *opaque)
virtio_notify(vdev, s->svq);
}
-static void balloon_stats_get_all(Object *obj, struct Visitor *v,
- void *opaque, const char *name, Error **errp)
+void balloon_stats_get_all(Object *obj, struct Visitor *v, void *opaque,
+ const char *name, Error **errp)
{
VirtIOBalloon *s = opaque;
int i;
@@ -129,17 +129,17 @@ static void balloon_stats_get_all(Object *obj, struct Visitor *v,
visit_end_struct(v, errp);
}
-static void balloon_stats_get_poll_interval(Object *obj, struct Visitor *v,
- void *opaque, const char *name,
- Error **errp)
+void balloon_stats_get_poll_interval(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
{
VirtIOBalloon *s = opaque;
visit_type_int(v, &s->stats_poll_interval, name, errp);
}
-static void balloon_stats_set_poll_interval(Object *obj, struct Visitor *v,
- void *opaque, const char *name,
- Error **errp)
+void balloon_stats_set_poll_interval(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
{
VirtIOBalloon *s = opaque;
int64_t value;
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 2b22588..9a3d291 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1450,6 +1450,14 @@ static void virtio_balloon_pci_instance_init(Object *obj)
VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BALLOON);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+
+ object_property_add(obj, "guest-stats", "guest statistics",
+ balloon_stats_get_all, NULL, NULL, &dev->vdev, NULL);
+
+ object_property_add(obj, "guest-stats-polling-interval", "int",
+ balloon_stats_get_poll_interval,
+ balloon_stats_set_poll_interval,
+ NULL, &dev->vdev, NULL);
}
static const TypeInfo virtio_balloon_pci_info = {
diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h
index 3b459bb..023d0f0 100644
--- a/include/hw/virtio/virtio-balloon.h
+++ b/include/hw/virtio/virtio-balloon.h
@@ -69,4 +69,13 @@ typedef struct VirtIOBalloon {
int64_t stats_poll_interval;
} VirtIOBalloon;
+void balloon_stats_get_all(Object *obj, struct Visitor *v, void *opaque,
+ const char *name, Error **errp);
+void balloon_stats_get_poll_interval(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+void balloon_stats_set_poll_interval(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
2013-04-11 22:38 [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties fred.konrad
@ 2013-04-12 8:29 ` Peter Maydell
2013-04-12 8:36 ` KONRAD Frédéric
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2013-04-12 8:29 UTC (permalink / raw)
To: fred.konrad
Cc: aliguori, mark.burton, qemu-devel, Luiz Capitulino, cornelia.huck,
afaerber
On 11 April 2013 23:38, <fred.konrad@greensocs.com> wrote:
> From: KONRAD Frederic <fred.konrad@greensocs.com>
>
> To keep compatibility with the old virtio-balloon-x, add the dynamic properties
> to virtio-balloon-pci and virtio-balloon-ccw.
Does the approach I suggested on IRC where virtio-balloon-pci's
property set/get callbacks just set/get the property on
virtio-balloon via the public interface not work? Having to
expose virtio-balloon's callback functions seems a bit of
an encapsulation violation...
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
2013-04-12 8:29 ` Peter Maydell
@ 2013-04-12 8:36 ` KONRAD Frédéric
2013-04-12 9:14 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: KONRAD Frédéric @ 2013-04-12 8:36 UTC (permalink / raw)
To: Peter Maydell
Cc: aliguori, mark.burton, qemu-devel, Luiz Capitulino, cornelia.huck,
afaerber
On 12/04/2013 10:29, Peter Maydell wrote:
> On 11 April 2013 23:38, <fred.konrad@greensocs.com> wrote:
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> To keep compatibility with the old virtio-balloon-x, add the dynamic properties
>> to virtio-balloon-pci and virtio-balloon-ccw.
> Does the approach I suggested on IRC where virtio-balloon-pci's
> property set/get callbacks just set/get the property on
> virtio-balloon via the public interface not work? Having to
> expose virtio-balloon's callback functions seems a bit of
> an encapsulation violation...
>
> thanks
> -- PMM
Oh, I didn't understand that like that.
What do you mean by the public interface?
I thought you wanted two set/get callbacks which call directly
virtio-balloon callbacks.
Thanks,
Fred
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
2013-04-12 8:36 ` KONRAD Frédéric
@ 2013-04-12 9:14 ` Peter Maydell
2013-04-12 9:19 ` KONRAD Frédéric
2013-04-12 9:33 ` KONRAD Frédéric
0 siblings, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2013-04-12 9:14 UTC (permalink / raw)
To: KONRAD Frédéric
Cc: aliguori, mark.burton, qemu-devel, Luiz Capitulino, cornelia.huck,
afaerber
On 12 April 2013 09:36, KONRAD Frédéric <fred.konrad@greensocs.com> wrote:
> On 12/04/2013 10:29, Peter Maydell wrote:
>> Does the approach I suggested on IRC where virtio-balloon-pci's
>> property set/get callbacks just set/get the property on
>> virtio-balloon via the public interface not work? Having to
>> expose virtio-balloon's callback functions seems a bit of
>> an encapsulation violation...
> Oh, I didn't understand that like that.
>
> What do you mean by the public interface?
I mean the interface that any user of an object should
use to access properties, ie object_property_set()
and object_property_get(). Something like:
static void balloon_pci_fwd_get(Object *obj,
struct Visitor *v, void *opaque, const char *name, Error **errp)
{
VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
object_property_get(OBJECT(&dev->vdev), v, name, errp);
}
Ditto for fwd_set; note that you can use the same accessors
for any property you need to forward to the underlying
virtio-balloon-device. Untested :-)
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
2013-04-12 9:14 ` Peter Maydell
@ 2013-04-12 9:19 ` KONRAD Frédéric
2013-04-12 9:33 ` KONRAD Frédéric
1 sibling, 0 replies; 6+ messages in thread
From: KONRAD Frédéric @ 2013-04-12 9:19 UTC (permalink / raw)
To: Peter Maydell
Cc: aliguori, mark.burton, qemu-devel, Luiz Capitulino, cornelia.huck,
afaerber
On 12/04/2013 11:14, Peter Maydell wrote:
> On 12 April 2013 09:36, KONRAD Frédéric <fred.konrad@greensocs.com> wrote:
>> On 12/04/2013 10:29, Peter Maydell wrote:
>>> Does the approach I suggested on IRC where virtio-balloon-pci's
>>> property set/get callbacks just set/get the property on
>>> virtio-balloon via the public interface not work? Having to
>>> expose virtio-balloon's callback functions seems a bit of
>>> an encapsulation violation...
>> Oh, I didn't understand that like that.
>>
>> What do you mean by the public interface?
> I mean the interface that any user of an object should
> use to access properties, ie object_property_set()
> and object_property_get(). Something like:
>
> static void balloon_pci_fwd_get(Object *obj,
> struct Visitor *v, void *opaque, const char *name, Error **errp)
> {
> VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
> object_property_get(OBJECT(&dev->vdev), v, name, errp);
> }
>
> Ditto for fwd_set; note that you can use the same accessors
> for any property you need to forward to the underlying
> virtio-balloon-device. Untested :-)
>
> -- PMM
Ok understood,
will fix that.
Thanks,
Fred
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties.
2013-04-12 9:14 ` Peter Maydell
2013-04-12 9:19 ` KONRAD Frédéric
@ 2013-04-12 9:33 ` KONRAD Frédéric
1 sibling, 0 replies; 6+ messages in thread
From: KONRAD Frédéric @ 2013-04-12 9:33 UTC (permalink / raw)
To: Peter Maydell
Cc: aliguori, mark.burton, qemu-devel, Luiz Capitulino, cornelia.huck,
afaerber
On 12/04/2013 11:14, Peter Maydell wrote:
> On 12 April 2013 09:36, KONRAD Frédéric <fred.konrad@greensocs.com> wrote:
>> On 12/04/2013 10:29, Peter Maydell wrote:
>>> Does the approach I suggested on IRC where virtio-balloon-pci's
>>> property set/get callbacks just set/get the property on
>>> virtio-balloon via the public interface not work? Having to
>>> expose virtio-balloon's callback functions seems a bit of
>>> an encapsulation violation...
>> Oh, I didn't understand that like that.
>>
>> What do you mean by the public interface?
> I mean the interface that any user of an object should
> use to access properties, ie object_property_set()
> and object_property_get(). Something like:
>
> static void balloon_pci_fwd_get(Object *obj,
> struct Visitor *v, void *opaque, const char *name, Error **errp)
> {
> VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
> object_property_get(OBJECT(&dev->vdev), v, name, errp);
> }
>
> Ditto for fwd_set; note that you can use the same accessors
> for any property you need to forward to the underlying
> virtio-balloon-device. Untested :-)
>
> -- PMM
Note, I'm having a kind of similar issue with virtio-rng:
virtio-rng-pci have actually a child device named "default-backend".
The logic wants that default-backend is a child of virtio-rng-device but
as we
want to keep compatibility.
And it's not possible to have this default-backend be a child of
virtio-rng-pci and virtio-rng-device at the same time.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-12 9:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 22:38 [Qemu-devel] [PATCH] virtio-balloon: fix dynamic properties fred.konrad
2013-04-12 8:29 ` Peter Maydell
2013-04-12 8:36 ` KONRAD Frédéric
2013-04-12 9:14 ` Peter Maydell
2013-04-12 9:19 ` KONRAD Frédéric
2013-04-12 9:33 ` KONRAD Frédéric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).