Parsing dbus introspect

William Kennington wak at google.com
Fri Oct 18 13:46:45 AEDT 2019


Looks like systemd doesn't even use an xml parser
https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c

On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture at google.com> wrote:
>
> With dbus-sensors, if I follow the Association property, i can find
> the board that owns the sensor.  However, we have a use-case where we
> want sensors to be able to have their own EntityId and EntityInstance
> values configured via the json --
>
> This lead to three situations:
> 1) sensor's board doesn't implement the Ipmi decoration
> 2) sensor's board implements the Ipmi decoration
> 3) sensor's board implements the Ipmi decoration, but the sensor has
> override values in the sensor dbus object owned by EntityManager.
>
> The way I see to do it is to introspect on the dbus path and service,
> and then search the list of interfaces to find one that starts
> "xyz.openbmc_project.Configuration" and then search that interface for
> an "EntityId" and "EntityInstance" property, and if present, read
> them.
>
> So this leads me to this email:
> 1) Has anyone already got an XML parser they like and has used it in
> this way?  Just to save me from figuring out the exact way to wire it
> up.
>
> busctl call xyz.openbmc_project.EntityManager
> /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> org.freedesktop.DBus.Introspectable Introspect
>
> s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> </interface>\n <interface
> name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> direction=\"out\"/>\n  </method>\n </interface>\n <interface
> name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
>   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> </interface>\n <interface
> name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> </interface>\n</node>\n"
>
> It's pretty easy -- it takes no parameters and returns a string that I
> feed into an XML parser, and then walk the nodes --> but has anyone
> already done this? Maybe I can use their code as a snippet or if it's
> in a common OpenBMC library?
>
> If nobody else has done this yet, I'll reply to this email with the
> patch that does it :)  I'm definitely interested in suggestions on a
> favored c++ XML parser.
>
> Thanks
> Patrick


More information about the openbmc mailing list