[systemd-devel] sd-bus dynamic property table

Simon McVittie smcv at collabora.com
Mon May 13 18:24:29 UTC 2019


On Mon, 13 May 2019 at 08:25:03 -0700, Stephen Hemminger wrote:
> The next step is to add ethtool statistics. Each type of network device will have
> different set of named properties.

This is really a D-Bus API design query, not a systemd query.

The standard D-Bus Properties interface is not designed for use
with arbitrary/dynamic named attributes. It's intended to be a D-Bus
equivalent of GObject properties or Qt properties, which are set up
in the object's source code: their values might vary at runtime, but
the list of properties that exists in a class or interface is part of
the API of that class or interface and does not change[1]. Similarly,
D-Bus properties exist in an interface alongside methods and signals,
and an interface either has a Foo property or it doesn't: if it does,
then every object that implements the interface also has a Foo property.

If you need named attributes that vary between objects, I'd suggest
representing them as either a single large property with an a{sv}
as its value, or a D-Bus interface that structurally resembles
Properties but is not Properties (for instance you could call it
com.example.NetworkStatistics, replacing com.example with your reversed
domain name, and have a GetStatistics() -> a{sv} method and optionally
a StatisticsChanged signal).

The org.freedesktop.DBus.Debug.Stats interface in dbus-daemon (it's
compile-time conditional, so your dbus-daemon might not have it)
provides an example of an interface that puts arbitrary attributes
in the result of a method call.

    smcv

[1] except for maybe backward-compatible feature enhancements where
    newer versions introduce more properties


More information about the systemd-devel mailing list