qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/7] qdev: Don't register unreadable legacy properties


From: Eduardo Habkost
Subject: [PATCH 3/7] qdev: Don't register unreadable legacy properties
Date: Wed, 4 Nov 2020 12:25:08 -0500

The existing code at qdev_class_add_legacy_property() will
register a property if both .print and .get are NULL, which is
useless as it will register a property that can't be read or
written.

The only PropertyInfo struct in the whole tree that has both
.print and .get set to NULL is qdev_prop_link.  This means every
link property in the code had a useless "legacy-" property being
registered.

Fix this by only registering legacy properties if a .print method
exists.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
 hw/core/qdev-properties.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 5bb4ff5f46..73884a212a 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -264,13 +264,13 @@ static void qdev_class_add_legacy_property(DeviceClass 
*dc, Property *prop)
     g_autofree char *name = NULL;
 
     /* Register pointer properties as legacy properties */
-    if (!prop->info->print && prop->info->get) {
+    if (!prop->info->print) {
         return;
     }
 
     name = g_strdup_printf("legacy-%s", prop->qdev_prop_name);
     object_class_property_add(OBJECT_CLASS(dc), name, "str",
-        prop->info->print ? qdev_get_legacy_property : prop->info->get,
+        qdev_get_legacy_property,
         NULL, NULL, prop);
 }
 
-- 
2.28.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]