]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qdev: Fix "info qtree" to show links
authorMarkus Armbruster <armbru@redhat.com>
Wed, 22 Oct 2025 10:14:19 +0000 (12:14 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 7 Jan 2026 13:30:36 +0000 (14:30 +0100)
qdev_print_props() retrieves a property's value from its legacy
property if it exists.  A legacy property is created by
qdev_class_add_legacy_property() when the property has a print()
method or does not have a get() method.

If it has a print() method, the legacy property's value is obtained
from the property's print() method.  This is used to format PCI
addresses nicely, i.e. like 01.3 instead of 11.

Else, if doesn't have a get() method, the legacy property is
unreadable.  "info qtree" silently skips unreadable properties.

Link properties don't have a get() method, and are therefore skipped.
This is wrong, because the underlying QOM property *is* readable.

Change qdev_print_props() to simply use a print() method directly if
it exists, else get the value via QOM.

"info qtree" now shows links fine.  For instance, machine "pc" onboard
device "PIIX4_PM" property "bus" is now visible.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20251022101420.36059-3-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
system/qdev-monitor.c

index 0bf514cb096551b9f7548d9c613fef6d9c0d1cf5..be18902bb2f9dc0200934d39536c0be527ce24ac 100644 (file)
@@ -762,19 +762,18 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, DeviceClass *dc,
     for (int i = 0, n = dc->props_count_; i < n; ++i) {
         const Property *prop = &dc->props_[i];
         char *value;
-        char *legacy_name = g_strdup_printf("legacy-%s", prop->name);
 
-        if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
-            value = object_property_get_str(OBJECT(dev), legacy_name, NULL);
+        if (prop->info->print) {
+            value = prop->info->print(OBJECT(dev), prop);
         } else {
             value = object_property_print(OBJECT(dev), prop->name, true,
                                           NULL);
         }
-        g_free(legacy_name);
 
         if (!value) {
             continue;
         }
+
         qdev_printf("%s = %s\n", prop->name,
                     *value ? value : "<null>");
         g_free(value);