List units¶
Source · io.systemd.Unit · systemd v258+ · Unprivileged
A systemctl list-units over Varlink, using io.systemd.Unit.List, which PID 1
gained in systemd v258. It checks support at run time first, which is
where a real program would fall back to go-systemd's D-Bus API.
Run it¶
Output (illustrative)
UNIT LOAD ACTIVE SUB DESCRIPTION
-.mount loaded active mounted Root Mount
dbus.service loaded active running D-Bus System Message Bus
ssh.service loaded active running OpenBSD Secure Shell server
systemd-journald.service loaded active running Journal Service
systemd-resolved.service loaded active running Network Name Resolution
timers.target loaded active active Timer Units
The code¶
How it works¶
- Feature detection.
c.Supports(ctx, "List")fetches the live interface description and checks for the method before calling it. - Streaming.
Listsupportsmore;ListMoreyields one*ListOutper unit, with aContext(configuration) andRuntime(state) each. - Pinned to v258. In the v258 bindings
Runtime.LoadStateandActiveStateare plain strings. In v260 (andlatest) they became optional*string, so withlatestyou'd writevarlink.Deref(u.Runtime.ActiveState). See Versioning. -unitsets the optionalNamefilter withvarlink.Ptr.