qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"Maciej S . Szmigiero" <maciej.szmigiero@oracle.com>,
	Eduardo Habkost <ehabkost@redhat.com>
Subject: [PULL v2 01/15] vmbus: Don't make QOM property registration conditional
Date: Thu,  8 Jul 2021 15:55:38 -0400	[thread overview]
Message-ID: <20210708195552.2730970-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20210708195552.2730970-1-ehabkost@redhat.com>

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>
Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Message-Id: <20201009200701.1830060-1-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 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 984caf898dc..c9887d5a7bc 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -2372,6 +2372,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);
@@ -2438,18 +2446,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);
@@ -2458,8 +2470,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.31.1



  reply	other threads:[~2021-07-08 20:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 19:55 [PULL v2 00/15] Machine queue, 2021-07-07 Eduardo Habkost
2021-07-08 19:55 ` Eduardo Habkost [this message]
2021-07-08 19:55 ` [PULL v2 02/15] Deprecate pmem=on with non-DAX capable backend file Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 03/15] memory: Introduce RamDiscardManager for RAM memory regions Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 04/15] memory: Helpers to copy/free a MemoryRegionSection Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 05/15] virtio-mem: Factor out traversing unplugged ranges Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 06/15] virtio-mem: Don't report errors when ram_block_discard_range() fails Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 07/15] virtio-mem: Implement RamDiscardManager interface Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 08/15] vfio: Support for RamDiscardManager in the !vIOMMU case Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 09/15] vfio: Query and store the maximum number of possible DMA mappings Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 10/15] vfio: Sanity check maximum number of DMA mappings with RamDiscardManager Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 11/15] vfio: Support for RamDiscardManager in the vIOMMU case Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 12/15] softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require) Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 13/15] softmmu/physmem: Extend ram_block_discard_(require|disable) by two discard types Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 14/15] virtio-mem: Require only coordinated discards Eduardo Habkost
2021-07-08 19:55 ` [PULL v2 15/15] vfio: Disable only uncoordinated discards for VFIO_TYPE1 iommus Eduardo Habkost
2021-07-10 15:05 ` [PULL v2 00/15] Machine queue, 2021-07-07 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708195552.2730970-2-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=maciej.szmigiero@oracle.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).