qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vmbus: Don't make QOM property registration conditional
@ 2020-10-09 20:07 Eduardo Habkost
  2020-10-09 21:05 ` Maciej S. Szmigiero
  0 siblings, 1 reply; 6+ messages in thread
From: Eduardo Habkost @ 2020-10-09 20:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Maciej S. Szmigiero, Roman Kagan, Jon Doron

Having properties registered conditionally makes QOM type
introspection difficult.  Instead of skipping registration of the
"instanceid" property, always register the property but validate
its value against the instance id required by the class.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Note: due to the lack of concrete vmbus-dev subclasses in the
QEMU tree, this patch couldn't be tested.
---
 hw/hyperv/vmbus.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 896e981f85..481d7e8d3c 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -2371,6 +2371,14 @@ static void vmbus_dev_realize(DeviceState *dev, Error **errp)
 
     assert(!qemu_uuid_is_null(&vdev->instanceid));
 
+    if (!qemu_uuid_is_null(&vdc->instanceid)) {
+        /* Class wants to only have a single instance with a fixed UUID */
+        if (!qemu_uuid_is_equal(&vdev->instanceid, &vdc->instanceid)) {
+            error_setg(&err, "instance id can't be changed");
+            goto error_out;
+        }
+    }
+
     /* Check for instance id collision for this class id */
     QTAILQ_FOREACH(child, &BUS(vmbus)->children, sibling) {
         VMBusDevice *child_dev = VMBUS_DEVICE(child->child);
@@ -2437,18 +2445,22 @@ static void vmbus_dev_unrealize(DeviceState *dev)
     free_channels(vdev);
 }
 
+static Property vmbus_dev_props[] = {
+    DEFINE_PROP_UUID("instanceid", VMBusDevice, instanceid),
+    DEFINE_PROP_END_OF_LIST()
+};
+
+
 static void vmbus_dev_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *kdev = DEVICE_CLASS(klass);
+    device_class_set_props(kdev, vmbus_dev_props);
     kdev->bus_type = TYPE_VMBUS;
     kdev->realize = vmbus_dev_realize;
     kdev->unrealize = vmbus_dev_unrealize;
     kdev->reset = vmbus_dev_reset;
 }
 
-static Property vmbus_dev_instanceid =
-                        DEFINE_PROP_UUID("instanceid", VMBusDevice, instanceid);
-
 static void vmbus_dev_instance_init(Object *obj)
 {
     VMBusDevice *vdev = VMBUS_DEVICE(obj);
@@ -2457,8 +2469,6 @@ static void vmbus_dev_instance_init(Object *obj)
     if (!qemu_uuid_is_null(&vdc->instanceid)) {
         /* Class wants to only have a single instance with a fixed UUID */
         vdev->instanceid = vdc->instanceid;
-    } else {
-        qdev_property_add_static(DEVICE(vdev), &vmbus_dev_instanceid);
     }
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmbus: Don't make QOM property registration conditional
  2020-10-09 20:07 [PATCH] vmbus: Don't make QOM property registration conditional Eduardo Habkost
@ 2020-10-09 21:05 ` Maciej S. Szmigiero
  2020-10-09 21:33   ` Eduardo Habkost
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej S. Szmigiero @ 2020-10-09 21:05 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Paolo Bonzini, Jon Doron, qemu-devel, Roman Kagan

On 09.10.2020 22:07, Eduardo Habkost wrote:
> Having properties registered conditionally makes QOM type
> introspection difficult.  Instead of skipping registration of the
> "instanceid" property, always register the property but validate
> its value against the instance id required by the class.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Note: due to the lack of concrete vmbus-dev subclasses in the
> QEMU tree, this patch couldn't be tested.

Will test it tomorrow since I have a VMBus device implementation.

Maciej


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmbus: Don't make QOM property registration conditional
  2020-10-09 21:05 ` Maciej S. Szmigiero
@ 2020-10-09 21:33   ` Eduardo Habkost
  2020-10-10 23:30     ` Maciej S. Szmigiero
  0 siblings, 1 reply; 6+ messages in thread
From: Eduardo Habkost @ 2020-10-09 21:33 UTC (permalink / raw)
  To: Maciej S. Szmigiero; +Cc: Paolo Bonzini, Jon Doron, qemu-devel, Roman Kagan

On Fri, Oct 09, 2020 at 11:05:47PM +0200, Maciej S. Szmigiero wrote:
> On 09.10.2020 22:07, Eduardo Habkost wrote:
> > Having properties registered conditionally makes QOM type
> > introspection difficult.  Instead of skipping registration of the
> > "instanceid" property, always register the property but validate
> > its value against the instance id required by the class.
> > 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > Note: due to the lack of concrete vmbus-dev subclasses in the
> > QEMU tree, this patch couldn't be tested.
> 
> Will test it tomorrow since I have a VMBus device implementation.

Thanks!

Is anybody willing to volunteer to be listed as maintainer (or
reviewer, at least) of hw/hyperv/vmbus.c?

-- 
Eduardo



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmbus: Don't make QOM property registration conditional
  2020-10-09 21:33   ` Eduardo Habkost
@ 2020-10-10 23:30     ` Maciej S. Szmigiero
  2021-04-25 12:21       ` Maciej S. Szmigiero
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej S. Szmigiero @ 2020-10-10 23:30 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Paolo Bonzini, Jon Doron, qemu-devel, Roman Kagan

On 09.10.2020 23:33, Eduardo Habkost wrote:
> On Fri, Oct 09, 2020 at 11:05:47PM +0200, Maciej S. Szmigiero wrote:
>> On 09.10.2020 22:07, Eduardo Habkost wrote:
>>> Having properties registered conditionally makes QOM type
>>> introspection difficult.  Instead of skipping registration of the
>>> "instanceid" property, always register the property but validate
>>> its value against the instance id required by the class.
>>>
>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>> ---
>>> Note: due to the lack of concrete vmbus-dev subclasses in the
>>> QEMU tree, this patch couldn't be tested.
>>
>> Will test it tomorrow since I have a VMBus device implementation.
> 
> Thanks!
> 

Tested the patch with a hv-balloon device and is seems to work okay, so:
Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>

Maciej


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmbus: Don't make QOM property registration conditional
  2020-10-10 23:30     ` Maciej S. Szmigiero
@ 2021-04-25 12:21       ` Maciej S. Szmigiero
  2021-04-27 20:45         ` Eduardo Habkost
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej S. Szmigiero @ 2021-04-25 12:21 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Paolo Bonzini, Jon Doron, qemu-devel, Roman Kagan

On 11.10.2020 01:30, Maciej S. Szmigiero wrote:
> On 09.10.2020 23:33, Eduardo Habkost wrote:
>> On Fri, Oct 09, 2020 at 11:05:47PM +0200, Maciej S. Szmigiero wrote:
>>> On 09.10.2020 22:07, Eduardo Habkost wrote:
>>>> Having properties registered conditionally makes QOM type
>>>> introspection difficult.  Instead of skipping registration of the
>>>> "instanceid" property, always register the property but validate
>>>> its value against the instance id required by the class.
>>>>
>>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>>> ---
>>>> Note: due to the lack of concrete vmbus-dev subclasses in the
>>>> QEMU tree, this patch couldn't be tested.
>>>
>>> Will test it tomorrow since I have a VMBus device implementation.
>>
>> Thanks!
>>
> 
> Tested the patch with a hv-balloon device and is seems to work okay, so:
> Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> 

I see this patch wasn't picked up - it still makes sense and applies
cleanly to the current git, so I think it should be picked up.

Thanks,
Maciej


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmbus: Don't make QOM property registration conditional
  2021-04-25 12:21       ` Maciej S. Szmigiero
@ 2021-04-27 20:45         ` Eduardo Habkost
  0 siblings, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2021-04-27 20:45 UTC (permalink / raw)
  To: Maciej S. Szmigiero; +Cc: Paolo Bonzini, Roman Kagan, Jon Doron, qemu-devel

On Sun, Apr 25, 2021 at 02:21:38PM +0200, Maciej S. Szmigiero wrote:
> On 11.10.2020 01:30, Maciej S. Szmigiero wrote:
> > On 09.10.2020 23:33, Eduardo Habkost wrote:
> > > On Fri, Oct 09, 2020 at 11:05:47PM +0200, Maciej S. Szmigiero wrote:
> > > > On 09.10.2020 22:07, Eduardo Habkost wrote:
> > > > > Having properties registered conditionally makes QOM type
> > > > > introspection difficult.  Instead of skipping registration of the
> > > > > "instanceid" property, always register the property but validate
> > > > > its value against the instance id required by the class.
> > > > > 
> > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > ---
> > > > > Note: due to the lack of concrete vmbus-dev subclasses in the
> > > > > QEMU tree, this patch couldn't be tested.
> > > > 
> > > > Will test it tomorrow since I have a VMBus device implementation.
> > > 
> > > Thanks!
> > > 
> > 
> > Tested the patch with a hv-balloon device and is seems to work okay, so:
> > Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> > 
> 
> I see this patch wasn't picked up - it still makes sense and applies
> cleanly to the current git, so I think it should be picked up.

I'm queueing it for 6.1, thanks for the reminder!

-- 
Eduardo



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-27 20:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 20:07 [PATCH] vmbus: Don't make QOM property registration conditional Eduardo Habkost
2020-10-09 21:05 ` Maciej S. Szmigiero
2020-10-09 21:33   ` Eduardo Habkost
2020-10-10 23:30     ` Maciej S. Szmigiero
2021-04-25 12:21       ` Maciej S. Szmigiero
2021-04-27 20:45         ` Eduardo Habkost

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).