]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qdev: Legacy properties are now unused internally, drop
authorMarkus Armbruster <armbru@redhat.com>
Wed, 22 Oct 2025 10:14:20 +0000 (12:14 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 7 Jan 2026 13:30:36 +0000 (14:30 +0100)
Legacy properties are an accidental and undocumented external
interface.  qom-set doesn't work for them (no .set() method).  qom-get
and qom-list-get work only when the underlying qdev property has a
.print() method, i.e. the PCI address properties, as explained in the
previous commit.  Here's one that works:

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

And here's one that doesn't:

    (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

Actual use of this undocumented interface seems quite unlikely.  A
deprecation period seems unnecessary.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20251022101420.36059-4-armbru@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Commit message improved]

hw/core/qdev-properties.c

index 05489c8fbbf93acc7882695076dd69ccb3180b85..c96ccfb263530242395f43849a3c8c30dc722b85 100644 (file)
@@ -1110,51 +1110,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. */
@@ -1167,7 +1122,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);
     }
 }