On Sun, 15 Nov 2026, Yonggang Luo wrote:
On Thu, Nov 12, 2026 at 9:31 PM Daniel P. Berrangé <[email protected]> wrote:

All QOM types must have a globally unique typename, however, for
user convenience, some might also want to have aliases which are
permitted to be ambiguous. Define an "Aliased" interface which
can be implemented by types which want to support aliases.

When resolving an alias, if there are multiple QOM types with a
matching alias this is considered an error. Ambiguity can be
resolved by matching system state, with the selected target
being the currently implemented filter.

Signed-off-by: Daniel P. Berrangé <[email protected]>
---
 include/qom/object_interfaces.h | 77 +++++++++++++++++++++++++++++++++
 qom/object_interfaces.c         | 57 ++++++++++++++++++++++++
 2 files changed, 134 insertions(+)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index d222a3d7481..010e37d63f7 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -27,6 +27,17 @@ DECLARE_CLASS_CHECKERS(TargetSpecificClass, TARGET_SPECIFIC,

 typedef struct TargetSpecific TargetSpecific;

+#define TYPE_ALIASED "aliased"
+
+typedef struct AliasedClass AliasedClass;
+DECLARE_CLASS_CHECKERS(AliasedClass, ALIASED,
+                       TYPE_ALIASED)
+#define ALIASED(obj) \
+     INTERFACE_CHECK(Aliased, (obj), \
+                     TYPE_ALIASED)
+
+typedef struct Aliased Aliased;

I wonder if it would be simpler to add the possibility to define aliases to all QOM objects as standard instead of by an interface? This is useful for other cases, it came up here too for example:
https://lists.nongnu.org/archive/html/qemu-ppc/2025-02/msg00113.html
Or maybe this could be done with this interface by common super classes implementing it such as device and machine allowing aliases that commonly need it to use it but then it would be quite widespread use to consider just adding it to object right away which may also help interaction with arch. Why separating it into an interface is better when we need it for most objects?

Regards,
BALATON Zoltan

Reply via email to