[PATCH 3/3] qdev: Legacy properties are now unused, drop

Markus Armbruster posted 3 patches 3 weeks, 2 days ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>
[PATCH 3/3] qdev: Legacy properties are now unused, drop
Posted by Markus Armbruster 3 weeks, 2 days ago
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/core/qdev-properties.c | 46 ---------------------------------------
 1 file changed, 46 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 422a486969..46a12652f4 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1108,51 +1108,6 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
     object_class_property_set_description(oc, name, prop->info->description);
 }
 
-/**
- * Legacy property handling
- */
-
-static void qdev_get_legacy_property(Object *obj, Visitor *v,
-                                     const char *name, void *opaque,
-                                     Error **errp)
-{
-    const Property *prop = opaque;
-    char *s;
-
-    s = prop->info->print(obj, prop);
-    visit_type_str(v, name, &s, errp);
-    g_free(s);
-}
-
-/**
- * qdev_class_add_legacy_property:
- * @dev: Device to add the property to.
- * @prop: The qdev property definition.
- *
- * Add a legacy QOM property to @dev for qdev property @prop.
- *
- * Legacy properties are string versions of QOM properties.  The format of
- * the string depends on the property type.  Legacy properties are only
- * needed for "info qtree".
- *
- * Do not use this in new code!  QOM Properties added through this interface
- * will be given names in the "legacy" namespace.
- */
-static void qdev_class_add_legacy_property(DeviceClass *dc, const Property *prop)
-{
-    g_autofree char *name = NULL;
-
-    /* Register pointer properties as legacy properties */
-    if (!prop->info->print && prop->info->get) {
-        return;
-    }
-
-    name = g_strdup_printf("legacy-%s", prop->name);
-    object_class_property_add(OBJECT_CLASS(dc), name, "str",
-        prop->info->print ? qdev_get_legacy_property : prop->info->get,
-        NULL, NULL, (Property *)prop);
-}
-
 void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n)
 {
     /* We used a hole in DeviceClass because that's still a lot. */
@@ -1165,7 +1120,6 @@ void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n)
     for (size_t i = 0; i < n; ++i) {
         const Property *prop = &props[i];
         assert(prop->name);
-        qdev_class_add_legacy_property(dc, prop);
         qdev_class_add_property(dc, prop->name, prop);
     }
 }
-- 
2.49.0
Re: [PATCH 3/3] qdev: Legacy properties are now unused, drop
Posted by Marc-André Lureau 3 weeks, 2 days ago
Hi


On Wed, Oct 22, 2025 at 2:15 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

I don't think we have much reasonable way to use those "legacy-*"
properties from qom-get and similar, so it's probably ok to just
remove them without deprecation.

Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  hw/core/qdev-properties.c | 46 ---------------------------------------
>  1 file changed, 46 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 422a486969..46a12652f4 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1108,51 +1108,6 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
>      object_class_property_set_description(oc, name, prop->info->description);
>  }
>
> -/**
> - * Legacy property handling
> - */
> -
> -static void qdev_get_legacy_property(Object *obj, Visitor *v,
> -                                     const char *name, void *opaque,
> -                                     Error **errp)
> -{
> -    const Property *prop = opaque;
> -    char *s;
> -
> -    s = prop->info->print(obj, prop);
> -    visit_type_str(v, name, &s, errp);
> -    g_free(s);
> -}
> -
> -/**
> - * qdev_class_add_legacy_property:
> - * @dev: Device to add the property to.
> - * @prop: The qdev property definition.
> - *
> - * Add a legacy QOM property to @dev for qdev property @prop.
> - *
> - * Legacy properties are string versions of QOM properties.  The format of
> - * the string depends on the property type.  Legacy properties are only
> - * needed for "info qtree".
> - *
> - * Do not use this in new code!  QOM Properties added through this interface
> - * will be given names in the "legacy" namespace.
> - */
> -static void qdev_class_add_legacy_property(DeviceClass *dc, const Property *prop)
> -{
> -    g_autofree char *name = NULL;
> -
> -    /* Register pointer properties as legacy properties */
> -    if (!prop->info->print && prop->info->get) {
> -        return;
> -    }
> -
> -    name = g_strdup_printf("legacy-%s", prop->name);
> -    object_class_property_add(OBJECT_CLASS(dc), name, "str",
> -        prop->info->print ? qdev_get_legacy_property : prop->info->get,
> -        NULL, NULL, (Property *)prop);
> -}
> -
>  void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n)
>  {
>      /* We used a hole in DeviceClass because that's still a lot. */
> @@ -1165,7 +1120,6 @@ void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n)
>      for (size_t i = 0; i < n; ++i) {
>          const Property *prop = &props[i];
>          assert(prop->name);
> -        qdev_class_add_legacy_property(dc, prop);
>          qdev_class_add_property(dc, prop->name, prop);
>      }
>  }
> --
> 2.49.0
>
>


--
Marc-André Lureau
Re: [PATCH 3/3] qdev: Legacy properties are now unused, drop
Posted by Markus Armbruster 3 weeks, 2 days ago
Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
>
> On Wed, Oct 22, 2025 at 2:15 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> I don't think we have much reasonable way to use those "legacy-*"
> properties from qom-get and similar, so it's probably ok to just
> remove them without deprecation.

Almost all of them are unreadable via qom-get:

    (qemu) qom-get /machine/unattached/device[3]/pm bus
    "/machine/i440fx/pci.0"
    (qemu) qom-get /machine/unattached/device[3]/pm legacy-bus
    Error: Property 'PIIX4_PM.legacy-bus' is not readable

Same for all the other properties where the qdev property doesn't have a
.get().

Only the ones with a .print() are readable, i.e. only PCI address
properties:

    (qemu) qom-get /machine/unattached/device[3]/pm addr
    11
    (qemu) qom-get /machine/unattached/device[3]/pm legacy-addr
    "01.3"

PATCH 2's commit message explains why.

If a deprecation period is wanted, I'll replace this patch.

If not, I can work the above into the commit message.

> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Thanks!