Rewrite child application management

Forked applications are managed by a class, which can track more than
one child.
Systemd mode uses transient units, libsystemd is replaced by
gdbus-codegen, the management objects shares the interface with forked
application.
This commit is contained in:
Patrick Nicolas
2025-07-22 20:49:32 +02:00
parent 2f5496c06e
commit d3e10dc31b
8 changed files with 1759 additions and 363 deletions
+848
View File
@@ -0,0 +1,848 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"https://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping"/>
<method name="GetMachineId">
<arg type="s" name="machine_uuid" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="GetAll">
<arg name="interface_name" direction="in" type="s"/>
<arg name="props" direction="out" type="a{sv}"/>
</method>
<method name="Set">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="in" type="v"/>
</method>
<signal name="PropertiesChanged">
<arg type="s" name="interface_name"/>
<arg type="a{sv}" name="changed_properties"/>
<arg type="as" name="invalidated_properties"/>
</signal>
</interface>
<interface name="org.freedesktop.systemd1.Manager">
<property name="Version" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Features" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Virtualization" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ConfidentialVirtualization" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Architecture" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Tainted" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FirmwareTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FirmwareTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="LoaderTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="LoaderTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="KernelTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="KernelTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UserspaceTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UserspaceTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ShutdownStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ShutdownStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SecurityStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SecurityStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SecurityFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SecurityFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="GeneratorsStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="GeneratorsStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="GeneratorsFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="GeneratorsFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitsLoadTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDSecurityStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDSecurityStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDSecurityFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDSecurityFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDGeneratorsStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDGeneratorsStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDGeneratorsFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDGeneratorsFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDUnitsLoadStartTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDUnitsLoadStartTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDUnitsLoadFinishTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InitRDUnitsLoadFinishTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="LogLevel" type="s" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="LogTarget" type="s" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="NNames" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="NFailedUnits" type="u" access="read">
</property>
<property name="NJobs" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="NInstalledJobs" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="NFailedJobs" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="Progress" type="d" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="Environment" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="ConfirmSpawn" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ShowStatus" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="UnitPath" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultStandardOutput" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultStandardError" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="WatchdogDevice" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="WatchdogLastPingTimestamp" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="WatchdogLastPingTimestampMonotonic" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="RuntimeWatchdogUSec" type="t" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="RuntimeWatchdogPreUSec" type="t" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="RuntimeWatchdogPreGovernor" type="s" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="RebootWatchdogUSec" type="t" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="KExecWatchdogUSec" type="t" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="ServiceWatchdogs" type="b" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</property>
<property name="ControlGroup" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="SystemState" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="ExitCode" type="y" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="DefaultTimerAccuracyUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultTimeoutStartUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultTimeoutStopUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultTimeoutAbortUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="DefaultDeviceTimeoutUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultRestartUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultStartLimitIntervalUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultStartLimitBurst" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultCPUAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultBlockIOAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultIOAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultIPAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultMemoryAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultTasksAccounting" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitCPU" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitCPUSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitFSIZE" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitFSIZESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitDATA" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitDATASoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitSTACK" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitSTACKSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitCORE" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitCORESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRSS" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRSSSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNOFILE" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNOFILESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitAS" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitASSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNPROC" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNPROCSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitMEMLOCK" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitMEMLOCKSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitLOCKS" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitLOCKSSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitSIGPENDING" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitSIGPENDINGSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitMSGQUEUE" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitMSGQUEUESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNICE" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitNICESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRTPRIO" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRTPRIOSoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRTTIME" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultLimitRTTIMESoft" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultTasksMax" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="DefaultMemoryPressureThresholdUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="DefaultMemoryPressureWatch" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="TimerSlackNSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultOOMPolicy" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultOOMScoreAdjust" type="i" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CtrlAltDelBurstAction" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SoftRebootsCount" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<method name="GetUnit">
<arg type="s" name="name" direction="in"/>
<arg type="o" name="unit" direction="out"/>
</method>
<method name="GetUnitByPID">
<arg type="u" name="pid" direction="in"/>
<arg type="o" name="unit" direction="out"/>
</method>
<method name="GetUnitByInvocationID">
<arg type="ay" name="invocation_id" direction="in"/>
<arg type="o" name="unit" direction="out"/>
</method>
<method name="GetUnitByControlGroup">
<arg type="s" name="cgroup" direction="in"/>
<arg type="o" name="unit" direction="out"/>
</method>
<method name="GetUnitByPIDFD">
<arg type="h" name="pidfd" direction="in"/>
<arg type="o" name="unit" direction="out"/>
<arg type="s" name="unit_id" direction="out"/>
<arg type="ay" name="invocation_id" direction="out"/>
</method>
<method name="LoadUnit">
<arg type="s" name="name" direction="in"/>
<arg type="o" name="unit" direction="out"/>
</method>
<method name="StartUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="StartUnitWithFlags">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="t" name="flags" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="StartUnitReplace">
<arg type="s" name="old_unit" direction="in"/>
<arg type="s" name="new_unit" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="StopUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="ReloadUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="RestartUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="TryRestartUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="ReloadOrRestartUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="ReloadOrTryRestartUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="EnqueueUnitJob">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="job_type" direction="in"/>
<arg type="s" name="job_mode" direction="in"/>
<arg type="u" name="job_id" direction="out"/>
<arg type="o" name="job_path" direction="out"/>
<arg type="s" name="unit_id" direction="out"/>
<arg type="o" name="unit_path" direction="out"/>
<arg type="s" name="job_type" direction="out"/>
<arg type="a(uosos)" name="affected_jobs" direction="out"/>
</method>
<method name="KillUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="whom" direction="in"/>
<arg type="i" name="signal" direction="in"/>
</method>
<method name="QueueSignalUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="whom" direction="in"/>
<arg type="i" name="signal" direction="in"/>
<arg type="i" name="value" direction="in"/>
</method>
<method name="CleanUnit">
<arg type="s" name="name" direction="in"/>
<arg type="as" name="mask" direction="in"/>
</method>
<method name="FreezeUnit">
<arg type="s" name="name" direction="in"/>
</method>
<method name="ThawUnit">
<arg type="s" name="name" direction="in"/>
</method>
<method name="ResetFailedUnit">
<arg type="s" name="name" direction="in"/>
</method>
<method name="SetUnitProperties">
<arg type="s" name="name" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="a(sv)" name="properties" direction="in"/>
</method>
<method name="BindMountUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="source" direction="in"/>
<arg type="s" name="destination" direction="in"/>
<arg type="b" name="read_only" direction="in"/>
<arg type="b" name="mkdir" direction="in"/>
</method>
<method name="MountImageUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="source" direction="in"/>
<arg type="s" name="destination" direction="in"/>
<arg type="b" name="read_only" direction="in"/>
<arg type="b" name="mkdir" direction="in"/>
<arg type="a(ss)" name="options" direction="in"/>
</method>
<method name="RefUnit">
<arg type="s" name="name" direction="in"/>
</method>
<method name="UnrefUnit">
<arg type="s" name="name" direction="in"/>
</method>
<method name="StartTransientUnit">
<arg type="s" name="name" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="a(sv)" name="properties" direction="in"/>
<arg type="a(sa(sv))" name="aux" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="GetUnitProcesses">
<arg type="s" name="name" direction="in"/>
<arg type="a(sus)" name="processes" direction="out"/>
</method>
<method name="AttachProcessesToUnit">
<arg type="s" name="unit_name" direction="in"/>
<arg type="s" name="subcgroup" direction="in"/>
<arg type="au" name="pids" direction="in"/>
</method>
<method name="AbandonScope">
<arg type="s" name="name" direction="in"/>
</method>
<method name="GetJob">
<arg type="u" name="id" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="GetJobAfter">
<arg type="u" name="id" direction="in"/>
<arg type="a(usssoo)" name="jobs" direction="out"/>
</method>
<method name="GetJobBefore">
<arg type="u" name="id" direction="in"/>
<arg type="a(usssoo)" name="jobs" direction="out"/>
</method>
<method name="CancelJob">
<arg type="u" name="id" direction="in"/>
</method>
<method name="ClearJobs">
</method>
<method name="ResetFailed">
</method>
<method name="SetShowStatus">
<arg type="s" name="mode" direction="in"/>
</method>
<method name="ListUnits">
<arg type="a(ssssssouso)" name="units" direction="out"/>
</method>
<method name="ListUnitsFiltered">
<arg type="as" name="states" direction="in"/>
<arg type="a(ssssssouso)" name="units" direction="out"/>
</method>
<method name="ListUnitsByPatterns">
<arg type="as" name="states" direction="in"/>
<arg type="as" name="patterns" direction="in"/>
<arg type="a(ssssssouso)" name="units" direction="out"/>
</method>
<method name="ListUnitsByNames">
<arg type="as" name="names" direction="in"/>
<arg type="a(ssssssouso)" name="units" direction="out"/>
</method>
<method name="ListJobs">
<arg type="a(usssoo)" name="jobs" direction="out"/>
</method>
<method name="Subscribe">
</method>
<method name="Unsubscribe">
</method>
<method name="Dump">
<arg type="s" name="output" direction="out"/>
</method>
<method name="DumpUnitsMatchingPatterns">
<arg type="as" name="patterns" direction="in"/>
<arg type="s" name="output" direction="out"/>
</method>
<method name="DumpByFileDescriptor">
<arg type="h" name="fd" direction="out"/>
</method>
<method name="DumpUnitsMatchingPatternsByFileDescriptor">
<arg type="as" name="patterns" direction="in"/>
<arg type="h" name="fd" direction="out"/>
</method>
<method name="Reload">
</method>
<method name="Reexecute">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="Exit">
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="Reboot">
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="SoftReboot">
<arg type="s" name="new_root" direction="in"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="PowerOff">
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="Halt">
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="KExec">
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="SwitchRoot">
<arg type="s" name="new_root" direction="in"/>
<arg type="s" name="init" direction="in"/>
<annotation name="org.freedesktop.systemd1.Privileged" value="true"/>
</method>
<method name="SetEnvironment">
<arg type="as" name="assignments" direction="in"/>
</method>
<method name="UnsetEnvironment">
<arg type="as" name="names" direction="in"/>
</method>
<method name="UnsetAndSetEnvironment">
<arg type="as" name="names" direction="in"/>
<arg type="as" name="assignments" direction="in"/>
</method>
<method name="EnqueueMarkedJobs">
<arg type="ao" name="jobs" direction="out"/>
</method>
<method name="ListUnitFiles">
<arg type="a(ss)" name="unit_files" direction="out"/>
</method>
<method name="ListUnitFilesByPatterns">
<arg type="as" name="states" direction="in"/>
<arg type="as" name="patterns" direction="in"/>
<arg type="a(ss)" name="unit_files" direction="out"/>
</method>
<method name="GetUnitFileState">
<arg type="s" name="file" direction="in"/>
<arg type="s" name="state" direction="out"/>
</method>
<method name="EnableUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="DisableUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="EnableUnitFilesWithFlags">
<arg type="as" name="files" direction="in"/>
<arg type="t" name="flags" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="DisableUnitFilesWithFlags">
<arg type="as" name="files" direction="in"/>
<arg type="t" name="flags" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="DisableUnitFilesWithFlagsAndInstallInfo">
<arg type="as" name="files" direction="in"/>
<arg type="t" name="flags" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="ReenableUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="LinkUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="PresetUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="PresetUnitFilesWithMode">
<arg type="as" name="files" direction="in"/>
<arg type="s" name="mode" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="b" name="carries_install_info" direction="out"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="MaskUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="UnmaskUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="RevertUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="SetDefaultTarget">
<arg type="s" name="name" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="GetDefaultTarget">
<arg type="s" name="name" direction="out"/>
</method>
<method name="PresetAllUnitFiles">
<arg type="s" name="mode" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="AddDependencyUnitFiles">
<arg type="as" name="files" direction="in"/>
<arg type="s" name="target" direction="in"/>
<arg type="s" name="type" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="b" name="force" direction="in"/>
<arg type="a(sss)" name="changes" direction="out"/>
</method>
<method name="GetUnitFileLinks">
<arg type="s" name="name" direction="in"/>
<arg type="b" name="runtime" direction="in"/>
<arg type="as" name="links" direction="out"/>
</method>
<method name="SetExitCode">
<arg type="y" name="number" direction="in"/>
</method>
<method name="LookupDynamicUserByName">
<arg type="s" name="name" direction="in"/>
<arg type="u" name="uid" direction="out"/>
</method>
<method name="LookupDynamicUserByUID">
<arg type="u" name="uid" direction="in"/>
<arg type="s" name="name" direction="out"/>
</method>
<method name="GetDynamicUsers">
<arg type="a(us)" name="users" direction="out"/>
</method>
<method name="DumpUnitFileDescriptorStore">
<arg type="s" name="name" direction="in"/>
<arg type="a(suuutuusu)" name="entries" direction="out"/>
</method>
<method name="StartAuxiliaryScope">
<arg type="s" name="name" direction="in"/>
<arg type="ah" name="pidfds" direction="in"/>
<arg type="t" name="flags" direction="in"/>
<arg type="a(sv)" name="properties" direction="in"/>
<arg type="o" name="job" direction="out"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
</method>
<signal name="UnitNew">
<arg type="s" name="id"/>
<arg type="o" name="unit"/>
</signal>
<signal name="UnitRemoved">
<arg type="s" name="id"/>
<arg type="o" name="unit"/>
</signal>
<signal name="JobNew">
<arg type="u" name="id"/>
<arg type="o" name="job"/>
<arg type="s" name="unit"/>
</signal>
<signal name="JobRemoved">
<arg type="u" name="id"/>
<arg type="o" name="job"/>
<arg type="s" name="unit"/>
<arg type="s" name="result"/>
</signal>
<signal name="StartupFinished">
<arg type="t" name="firmware"/>
<arg type="t" name="loader"/>
<arg type="t" name="kernel"/>
<arg type="t" name="initrd"/>
<arg type="t" name="userspace"/>
<arg type="t" name="total"/>
</signal>
<signal name="UnitFilesChanged">
</signal>
<signal name="Reloading">
<arg type="b" name="active"/>
</signal>
</interface>
<node name="job"/>
<node name="unit"/>
</node>
+386
View File
@@ -0,0 +1,386 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"https://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping"/>
<method name="GetMachineId">
<arg type="s" name="machine_uuid" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="GetAll">
<arg name="interface_name" direction="in" type="s"/>
<arg name="props" direction="out" type="a{sv}"/>
</method>
<method name="Set">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="in" type="v"/>
</method>
<signal name="PropertiesChanged">
<arg type="s" name="interface_name"/>
<arg type="a{sv}" name="changed_properties"/>
<arg type="as" name="invalidated_properties"/>
</signal>
</interface>
<interface name="org.freedesktop.systemd1.Unit">
<property name="Id" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Names" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Following" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="Requires" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Requisite" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Wants" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="BindsTo" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="PartOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Upholds" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RequiredBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RequisiteOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="WantedBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="BoundBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UpheldBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ConsistsOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Conflicts" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ConflictedBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Before" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="After" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnSuccess" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnSuccessOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnFailure" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnFailureOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Triggers" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="TriggeredBy" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="PropagatesReloadTo" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ReloadPropagatedFrom" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="PropagatesStopTo" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="StopPropagatedFrom" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="JoinsNamespaceOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SliceOf" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RequiresMountsFor" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="WantsMountsFor" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Documentation" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Description" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="AccessSELinuxContext" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="LoadState" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ActiveState" type="s" access="read">
</property>
<property name="FreezerState" type="s" access="read">
</property>
<property name="SubState" type="s" access="read">
</property>
<property name="FragmentPath" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SourcePath" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DropInPaths" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="UnitFileState" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="UnitFilePreset" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="StateChangeTimestamp" type="t" access="read">
</property>
<property name="StateChangeTimestampMonotonic" type="t" access="read">
</property>
<property name="InactiveExitTimestamp" type="t" access="read">
</property>
<property name="InactiveExitTimestampMonotonic" type="t" access="read">
</property>
<property name="ActiveEnterTimestamp" type="t" access="read">
</property>
<property name="ActiveEnterTimestampMonotonic" type="t" access="read">
</property>
<property name="ActiveExitTimestamp" type="t" access="read">
</property>
<property name="ActiveExitTimestampMonotonic" type="t" access="read">
</property>
<property name="InactiveEnterTimestamp" type="t" access="read">
</property>
<property name="InactiveEnterTimestampMonotonic" type="t" access="read">
</property>
<property name="CanStart" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanStop" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanReload" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanIsolate" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanClean" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanFreeze" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="CanLiveMount" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Job" type="(uo)" access="read">
</property>
<property name="StopWhenUnneeded" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RefuseManualStart" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RefuseManualStop" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="AllowIsolate" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="DefaultDependencies" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SurviveFinalKillSignal" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnSuccessJobMode" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="OnFailureJobMode" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="IgnoreOnIsolate" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="NeedDaemonReload" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="Markers" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="JobTimeoutUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="JobRunningTimeoutUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="JobTimeoutAction" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="JobTimeoutRebootArgument" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="ConditionResult" type="b" access="read">
</property>
<property name="AssertResult" type="b" access="read">
</property>
<property name="ConditionTimestamp" type="t" access="read">
</property>
<property name="ConditionTimestampMonotonic" type="t" access="read">
</property>
<property name="AssertTimestamp" type="t" access="read">
</property>
<property name="AssertTimestampMonotonic" type="t" access="read">
</property>
<property name="Conditions" type="a(sbbsi)" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates"/>
</property>
<property name="Asserts" type="a(sbbsi)" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates"/>
</property>
<property name="LoadError" type="(ss)" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Transient" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Perpetual" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="StartLimitIntervalUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="StartLimitBurst" type="u" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="StartLimitAction" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FailureAction" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="FailureActionExitStatus" type="i" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SuccessAction" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="SuccessActionExitStatus" type="i" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="RebootArgument" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="InvocationID" type="ay" access="read">
</property>
<property name="CollectMode" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Refs" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="ActivationDetails" type="a(ss)" access="read">
</property>
<property name="DebugInvocation" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<method name="Start">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="Stop">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="Reload">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="Restart">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="TryRestart">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="ReloadOrRestart">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="ReloadOrTryRestart">
<arg type="s" name="mode" direction="in"/>
<arg type="o" name="job" direction="out"/>
</method>
<method name="EnqueueJob">
<arg type="s" name="job_type" direction="in"/>
<arg type="s" name="job_mode" direction="in"/>
<arg type="u" name="job_id" direction="out"/>
<arg type="o" name="job_path" direction="out"/>
<arg type="s" name="unit_id" direction="out"/>
<arg type="o" name="unit_path" direction="out"/>
<arg type="s" name="job_type" direction="out"/>
<arg type="a(uosos)" name="affected_jobs" direction="out"/>
</method>
<method name="Kill">
<arg type="s" name="whom" direction="in"/>
<arg type="i" name="signal" direction="in"/>
</method>
<method name="QueueSignal">
<arg type="s" name="whom" direction="in"/>
<arg type="i" name="signal" direction="in"/>
<arg type="i" name="value" direction="in"/>
</method>
<method name="ResetFailed">
</method>
<method name="SetProperties">
<arg type="b" name="runtime" direction="in"/>
<arg type="a(sv)" name="properties" direction="in"/>
</method>
<method name="Ref">
</method>
<method name="Unref">
</method>
<method name="Clean">
<arg type="as" name="mask" direction="in"/>
</method>
<method name="Freeze">
</method>
<method name="Thaw">
</method>
</interface>
</node>
+16
View File
@@ -188,6 +188,22 @@ if (WIVRN_BUILD_SERVER)
target_link_libraries(wivrn-server PUBLIC wivrn-server-dbus)
target_link_libraries(wivrn-server PUBLIC PkgConfig::libnotify)
if(WIVRN_USE_SYSTEMD)
add_custom_command(OUTPUT systemd_manager.c systemd_manager.h
COMMAND ${GDBUS_CODEGEN} ${CMAKE_CURRENT_SOURCE_DIR}/../dbus/org.freedesktop.systemd1.Manager.xml --interface-prefix org.freedesktop.systemd1 --generate-c-code systemd_manager --c-namespace systemd
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../dbus/org.freedesktop.systemd1.Manager.xml )
add_custom_command(OUTPUT systemd_unit.c systemd_unit.h
COMMAND ${GDBUS_CODEGEN} ${CMAKE_CURRENT_SOURCE_DIR}/../dbus/org.freedesktop.systemd1.Unit.xml --interface-prefix org.freedesktop.systemd1 --generate-c-code systemd_unit --c-namespace unit
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../dbus/org.freedesktop.systemd1.Manager.xml )
target_sources(wivrn-server-dbus PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/systemd_manager.c ${CMAKE_CURRENT_BINARY_DIR}/systemd_manager.h
${CMAKE_CURRENT_BINARY_DIR}/systemd_unit.c ${CMAKE_CURRENT_BINARY_DIR}/systemd_unit.h)
target_sources(
wivrn-server
PRIVATE start_systemd_unit.cpp
)
endif()
target_link_libraries(
wivrn-server
PRIVATE
+24 -66
View File
@@ -33,7 +33,6 @@
#include <cstdint>
#include <filesystem>
#include <iostream>
#include <iterator>
#include <libnotify/notification.h>
#include <memory>
#include <poll.h>
@@ -53,6 +52,10 @@
#include <shared/ipc_protocol.h>
#include <util/u_file.h>
#if WIVRN_USE_SYSTEMD
#include "start_systemd_unit.h"
#endif
// Insert the on load constructor to init trace marker.
U_TRACE_TARGET_SETUP(U_TRACE_WHICH_SERVICE)
@@ -124,21 +127,6 @@ int create_listen_socket()
return fd;
}
void display_child_status(int wstatus, const std::string & name)
{
std::cerr << name << " exited, exit status " << WEXITSTATUS(wstatus);
if (WIFSIGNALED(wstatus))
{
std::cerr << ", received signal " << sigabbrev_np(WTERMSIG(wstatus)) << " ("
<< strsignal(WTERMSIG(wstatus)) << ")"
<< (WCOREDUMP(wstatus) ? ", core dumped" : "") << std::endl;
}
else
{
std::cerr << std::endl;
}
}
static std::filesystem::path flatpak_app_path()
{
if (auto value = flatpak_key(flatpak::section::instance, "app-path"))
@@ -197,9 +185,7 @@ guint server_kill_watch;
pid_t server_pid;
std::optional<std::jthread> connection_thread;
guint app_watch;
guint app_kill_watch;
pid_t app_pid;
std::unique_ptr<children_manager> children;
bool quitting_main_loop;
bool do_fork;
@@ -236,37 +222,6 @@ void stop_publishing();
void update_fsm();
void start_app(const std::vector<std::string> & args)
{
#if WIVRN_USE_SYSTEMD
app_pid = use_systemd ? start_unit_file(args) : fork_application(args);
#else
app_pid = fork_application();
#endif
assert(app_watch == 0);
assert(app_kill_watch == 0);
if (app_pid > 0)
{
app_watch = g_child_watch_add(app_pid, [](pid_t, int status, void *) {
display_child_status(status, "Application");
g_source_remove(app_watch);
if (app_kill_watch)
g_source_remove(app_kill_watch);
app_watch = 0;
app_kill_watch = 0;
update_fsm(); }, nullptr);
}
else
{
app_watch = 0;
if (app_pid < 0)
throw std::system_error(-app_pid, std::system_category());
}
}
void start_server(configuration config)
{
server_pid = do_fork ? fork() : 0;
@@ -339,17 +294,6 @@ void start_server(configuration config)
runtime_setter.emplace();
}
void kill_app()
{
kill(-app_pid, SIGTERM);
// Send SIGKILL after 1s if it is still running
app_kill_watch = g_timeout_add(1000, [](void *) {
assert(app_pid > 0);
kill(-app_pid, SIGKILL);
return G_SOURCE_REMOVE; }, 0);
}
void kill_server()
{
// Write to the server's stdin to make it quit
@@ -421,7 +365,7 @@ void stop_publishing()
void update_fsm()
{
bool server_running = server_watch != 0 or connection_thread;
bool app_running = app_watch != 0;
bool app_running = children->running();
if (quitting_main_loop)
{
@@ -431,15 +375,18 @@ void update_fsm()
kill_server();
if (app_running)
kill_app();
children->stop();
if (not server_running and not app_running)
{
children.reset(nullptr);
g_main_loop_quit(main_loop);
}
}
else
{
if (not server_running and app_running)
kill_app();
children->stop();
if (not server_running)
{
@@ -483,7 +430,7 @@ gboolean headset_connected_success(void *)
start_server(c);
try
{
start_app(c.application);
children->start_application(c.application);
}
catch (std::exception & e)
{
@@ -520,7 +467,7 @@ gboolean headset_connected_incorrect_pin(void *)
gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data)
{
assert(server_watch == 0);
assert(app_watch == 0);
assert(not children->running());
assert(not connection_thread);
assert(listener);
@@ -817,6 +764,17 @@ void on_headset_info_packet(const wivrn::from_headset::headset_info_packet & inf
void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer user_data)
{
#if WIVRN_USE_SYSTEMD
if (use_systemd)
{
children = std::make_unique<systemd_units_manager>(connection, update_fsm);
}
else
#endif
{
children = std::make_unique<forked_children>(update_fsm);
}
dbus_server = wivrn_server_skeleton_new();
g_signal_connect(dbus_server,
+104 -291
View File
@@ -1,296 +1,79 @@
// Copyright 2024, Gavin John et al.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Main file for WiVRn Monado service.
* @author Gavin John
/*
* WiVRn VR streaming
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "start_application.h"
#include "driver/configuration.h"
#include "utils/flatpak.h"
#include <cassert>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#include <vector>
#if WIVRN_USE_SYSTEMD
#include <chrono>
#include <string>
#include <systemd/sd-bus.h>
#include <thread>
namespace
namespace wivrn
{
struct deleter
{
void operator()(sd_bus * p)
{
sd_bus_unref(p);
}
void operator()(sd_bus_message * p)
{
sd_bus_message_unref(p);
}
};
children_manager::~children_manager() {}
struct raii_sd_bus_error
{
sd_bus_error data = SD_BUS_ERROR_NULL;
forked_children::forked_children(std::function<void()> state_changed_cb) :
state_changed_cb(state_changed_cb) {}
auto operator&()
{
return &data;
}
~raii_sd_bus_error()
{
sd_bus_error_free(&data);
}
};
using sd_bus_ptr = std::unique_ptr<sd_bus, deleter>;
using sd_msg_ptr = std::unique_ptr<sd_bus_message, deleter>;
struct container
{
container(sd_bus_message * msg, char type, const char * contents) :
msg(msg)
{
int ret = sd_bus_message_open_container(msg, type, contents);
if (ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_open_container failed");
}
~container()
{
int ret = sd_bus_message_close_container(msg);
if (ret < 0)
std::cerr << "sd_bus_message_close_container failed" << std::endl;
}
sd_bus_message * msg;
};
sd_bus_ptr get_user_bus()
{
sd_bus * bus = nullptr;
int ret;
// reimplement sd_bus_open_user to honor the env variable
if (const char * bus_address = getenv("DBUS_SESSION_BUS_ADDRESS"))
{
if (ret = sd_bus_new(&bus); ret < 0)
throw std::system_error(-ret, std::system_category(), "failed to create dbus object");
sd_bus_ptr res(bus);
if (ret = sd_bus_set_address(bus, bus_address); ret < 0)
throw std::system_error(-ret, std::system_category(), std::string("failed to connect to dbus at address ") + bus_address);
if (ret = sd_bus_set_bus_client(bus, 1); ret < 0)
throw std::system_error(-ret, std::system_category(), std::string("failed to configure dbus at address ") + bus_address);
if (ret = sd_bus_set_trusted(bus, 1); ret < 0)
throw std::system_error(-ret, std::system_category(), std::string("failed to trust dbus at address ") + bus_address);
if (ret = sd_bus_start(bus); ret < 0)
throw std::system_error(-ret, std::system_category(), std::string("failed to start dbus connection ") + bus_address);
return res;
}
if (ret = sd_bus_open_user(&bus); ret < 0)
throw std::system_error(-ret, std::system_category(), "failed to connect to dbus");
return sd_bus_ptr(bus);
}
} // namespace
static int get_service_pid(sd_bus * bus, const std::string & service_name, pid_t & pid)
{
sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message * msg = nullptr;
const char * destination = "org.freedesktop.systemd1";
const char * path = "/org/freedesktop/systemd1";
const char * interface = "org.freedesktop.systemd1.Manager";
const char * member = "GetUnit";
int ret = 0;
// Call the method
ret = sd_bus_call_method(bus, destination, path, interface, member, &error, &msg, "s", service_name.c_str());
if (ret < 0)
{
std::cerr << "Failed to issue method call: " << error.message << std::endl;
goto finish;
}
// Parse the response message
const char * object_path;
ret = sd_bus_message_read(msg, "o", &object_path);
if (ret < 0)
{
std::cerr << "Failed to parse response message: " << strerror(-ret) << std::endl;
goto finish;
}
// Get the service's main PID
ret = sd_bus_get_property_trivial(bus, destination, object_path, "org.freedesktop.systemd1.Service", "MainPID", &error, 'u', &pid);
if (ret < 0)
{
std::cerr << "Failed to get PID: " << error.message << std::endl;
goto finish;
}
finish:
sd_bus_error_free(&error);
sd_bus_message_unref(msg);
return ret;
}
std::string start_service(sd_bus * bus, const std::string & service_name, const std::vector<std::string> & args)
{
assert(not args.empty());
raii_sd_bus_error error;
sd_bus_message * msg = nullptr;
const char * destination = "org.freedesktop.systemd1";
const char * path = "/org/freedesktop/systemd1";
const char * interface = "org.freedesktop.systemd1.Manager";
const char * member = "StartTransientUnit";
const char * mode = "replace";
int ret = sd_bus_message_new_method_call(bus, &msg, destination, path, interface, member);
if (ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_new_method_call failed");
sd_msg_ptr raii_msg(msg);
// Name, mode
if (ret = sd_bus_message_append(msg, "ss", service_name.c_str(), mode); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
// Properties
{
container a(msg, 'a', "(sv)");
if (ret = sd_bus_message_append(msg, "(sv)", "Description", "s", "Application spawned by WiVRn"); ret < 0)
throw std::system_error(-ret, std::system_category(), "failed to set description");
container r(msg, 'r', "sv");
if (ret = sd_bus_message_append(msg, "s", "ExecStart"); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
container v(msg, 'v', "a(sasb)");
container a1(msg, 'a', "(sasb)");
container r1(msg, 'r', "sasb");
if (ret = sd_bus_message_append(msg, "s", args[0].c_str()); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
{
container a(msg, 'a', "s");
for (const auto & arg: args)
{
if (ret = sd_bus_message_append(msg, "s", arg.c_str()); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
}
}
if (ret = sd_bus_message_append(msg, "b", false); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
}
// aux (empty)
if (ret = sd_bus_message_append(msg, "a(sa(sv))", 0); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_append failed");
sd_bus_message * reply = nullptr;
if (ret = sd_bus_call(bus, msg, 0, &error, &reply); ret < 0)
throw std::system_error(-ret, std::system_category(), std::format("sd_bus_call failed: {}", error.data.message));
sd_msg_ptr raii_reply(reply);
char * object;
if (ret = sd_bus_message_read(reply, "o", &object); ret < 0)
throw std::system_error(-ret, std::system_category(), "sd_bus_message_read failed");
return object;
}
bool is_service_active(sd_bus * bus, const std::string & service_name)
{
sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message * msg = nullptr;
const char * destination = "org.freedesktop.systemd1";
const char * path = "/org/freedesktop/systemd1";
const char * interface = "org.freedesktop.systemd1.Manager";
const char * member = "GetUnit";
bool is_active = false;
const char * object_path;
// Call the method
int ret = sd_bus_call_method(bus, destination, path, interface, member, &error, &msg, "s", service_name.c_str());
if (ret < 0)
{
std::cerr << "Failed to issue method call: " << error.message << std::endl;
goto finish;
}
// Parse the response message
ret = sd_bus_message_read(msg, "o", &object_path);
if (ret < 0)
{
std::cerr << "Failed to parse response message: " << strerror(-ret) << std::endl;
goto finish;
}
// Check the service's ActiveState property
char * active_state;
ret = sd_bus_get_property_string(bus, destination, object_path, "org.freedesktop.systemd1.Unit", "ActiveState", &error, &active_state);
if (ret < 0)
{
std::cerr << "Failed to get ActiveState: " << error.message << std::endl;
goto finish;
}
is_active = (std::string_view(active_state) == "active");
finish:
sd_bus_error_free(&error);
sd_bus_message_unref(msg);
return is_active;
}
pid_t wivrn::start_unit_file(const std::vector<std::string> & args)
void forked_children::start_application(const std::vector<std::string> & args)
{
if (args.empty())
return 0;
return;
std::string service_name = std::format("wivrn-application-{}.service", std::chrono::steady_clock::now().time_since_epoch().count());
pid_t pid;
auto bus = get_user_bus();
int ret = get_service_pid(bus.get(), service_name, pid);
pid_t application_pid = fork();
if (ret < 0 || pid == 0)
if (application_pid < 0)
throw std::system_error(errno, std::system_category(), "fork");
if (application_pid > 0)
{
auto obj = start_service(bus.get(), service_name, args);
std::cout << "started service: " << obj << std::endl;
guint app_watch = g_child_watch_add(
application_pid,
[](pid_t pid, int status, void * self_) {
auto self = (forked_children *)self_;
bool empty = self->children.empty();
auto node = self->children.extract(pid);
if (not node)
{
std::cerr << "Failed to update child application information" << std::endl;
}
display_child_status(status, "Application");
const auto & watches = node.mapped();
g_source_remove(watches.child);
if (watches.kill)
g_source_remove(watches.kill);
// Wait until the service is active
while (!is_service_active(bus.get(), service_name))
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
// Try to get the PID again
ret = get_service_pid(bus.get(), service_name, pid);
if (ret < 0)
throw std::system_error(-ret, std::system_category(), "failed to get application PID");
if (self->state_changed_cb and self->children.empty() and not empty)
self->state_changed_cb();
},
this);
children.emplace(application_pid, watches{.child = app_watch});
return;
}
return pid;
}
#endif
static int exec_application(std::vector<std::string> args)
{
if (args.empty())
return 0;
// Start a new process group so that all processes started by the
// application can be signaled
setpgrp();
std::vector<std::string> tmp;
std::vector<char *> argv;
@@ -300,11 +83,10 @@ static int exec_application(std::vector<std::string> args)
{
tmp.push_back("flatpak-spawn");
tmp.push_back("--host");
for (auto & arg: tmp)
argv.push_back(arg.data());
}
for (auto & arg: args)
tmp.insert(tmp.end(), args.begin(), args.end());
for (auto & arg: tmp)
argv.push_back(arg.data());
argv.push_back(nullptr);
@@ -319,28 +101,59 @@ static int exec_application(std::vector<std::string> args)
}
execvp(executable.c_str(), argv.data());
perror("Cannot start application");
perror("Failed to start application");
exit(EXIT_FAILURE);
}
pid_t wivrn::fork_application(const std::vector<std::string> & args)
forked_children::~forked_children()
{
if (args.empty())
return 0;
pid_t application_pid = fork();
if (application_pid < 0)
throw std::system_error(errno, std::system_category(), "fork");
if (application_pid == 0)
for (auto & [pid, watches]: children)
{
// Start a new process group so that all processes started by the
// application can be signaled
setpgrp();
return exec_application(args);
g_source_remove(watches.child);
if (watches.kill)
g_source_remove(watches.kill);
}
return application_pid;
}
bool forked_children::running() const
{
return not children.empty();
}
void forked_children::stop()
{
for (auto & [pid, watches]: children)
{
kill(-pid, SIGTERM);
intptr_t pid_ptr = pid;
// Send SIGKILL after 1s if it is still running
static_assert(sizeof(pid_t) < sizeof(intptr_t));
watches.kill = g_timeout_add(
1000,
[](void * pid_) {
auto pid = (intptr_t)pid_;
assert(pid > 0);
kill(-pid, SIGKILL);
return G_SOURCE_REMOVE;
},
(void *)pid_ptr);
}
}
void display_child_status(int wstatus, const std::string & name)
{
std::cerr << name << " exited, exit status " << WEXITSTATUS(wstatus);
if (WIFSIGNALED(wstatus))
{
std::cerr << ", received signal " << sigabbrev_np(WTERMSIG(wstatus)) << " ("
<< strsignal(WTERMSIG(wstatus)) << ")"
<< (WCOREDUMP(wstatus) ? ", core dumped" : "") << std::endl;
}
else
{
std::cerr << std::endl;
}
}
} // namespace wivrn
+55 -6
View File
@@ -1,17 +1,66 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "wivrn_config.h"
#include <functional>
#include <glib.h>
#include <string>
#include <sys/types.h>
#include <unordered_map>
#include <vector>
namespace wivrn
{
pid_t fork_application(const std::vector<std::string> & args);
class children_manager
{
public:
virtual ~children_manager();
#if WIVRN_USE_SYSTEMD
pid_t start_unit_file(const std::vector<std::string> & args);
#endif
virtual void start_application(const std::vector<std::string> &) = 0;
virtual bool running() const = 0;
virtual void stop() = 0;
};
// Start applications using fork+exec
class forked_children : public children_manager
{
struct watches
{
guint child = 0;
guint kill = 0;
};
std::unordered_map<pid_t, watches> children;
std::function<void()> state_changed_cb;
public:
forked_children(std::function<void()> state_changed_cb);
virtual ~forked_children();
void start_application(const std::vector<std::string> &) override;
// true if any unit started by this object is still running
bool running() const override;
void stop() override;
};
void display_child_status(int wstatus, const std::string & name);
} // namespace wivrn
+248
View File
@@ -0,0 +1,248 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "start_systemd_unit.h"
#include "systemd_manager.h"
#include "systemd_unit.h"
#include <gio/gio.h>
#include <glib-object.h>
#include <iostream>
#include <chrono>
#include <format>
namespace wivrn
{
void systemd_units_manager::deleter::operator()(systemdManager * obj)
{
g_object_unref(obj);
}
void systemd_units_manager::deleter::operator()(unitUnit * obj)
{
g_object_unref(obj);
}
systemd_units_manager::systemd_units_manager(GDBusConnection * connection, std::function<void()> state_changed_cb) :
connection(connection), state_changed_cb(state_changed_cb)
{
GError * error = nullptr;
proxy.reset(systemd_manager_proxy_new_sync(
connection,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
nullptr,
&error));
if (error)
{
std::runtime_error e(std::string("Failed to connect to systemd user session: ") + error->message);
g_error_free(error);
throw e;
}
systemd_manager_call_subscribe_sync(
proxy.get(),
nullptr,
&error);
if (error)
{
std::runtime_error e(std::string("Failed to subscribe to systemd messages: ") + error->message);
g_error_free(error);
throw e;
}
g_signal_connect(proxy.get(),
"job-removed",
G_CALLBACK(&on_job_removed),
this);
}
bool systemd_units_manager::running() const
{
return not(jobs.empty() and units.empty());
}
void systemd_units_manager::stop()
{
for (auto & unit: units)
{
unit_unit_call_stop(unit.get(),
"replace",
nullptr,
nullptr,
nullptr);
}
}
void systemd_units_manager::on_job_removed(
systemdManagerProxy * connection,
guint32 id,
gchar * job,
gchar * unit,
gchar * result,
void * self_)
{
auto self = (systemd_units_manager *)(self_);
auto node = self->jobs.extract(job);
if (node.empty())
return;
if (strcmp(result, "done"))
{
std::cerr << "Failed to start application " << node.mapped() << ": " << result << std::endl;
return;
}
std::string object = "/org/freedesktop/systemd1/unit/";
for (char * c = unit; *c != '\0'; ++c)
{
if (std::isalnum(*c))
object += *c;
else
object += std::format("_{:02x}", *c);
}
unit_unit_proxy_new(
self->connection,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.systemd1",
object.c_str(),
nullptr,
[](GObject * source_object, GAsyncResult * res, void * self_) {
auto self = (systemd_units_manager *)(self_);
GError * error = nullptr;
std::unique_ptr<unitUnit, deleter> unit(unit_unit_proxy_new_finish(res, &error));
if (error)
{
std::cerr << "failed to create unit proxy: " << error->message << std::endl;
g_error_free(error);
return;
}
g_signal_connect(unit.get(),
"notify::active-state",
G_CALLBACK(on_unit_result),
self);
bool changed = self->units.empty();
self->units.emplace(std::move(unit));
if (changed and self->state_changed_cb)
self->state_changed_cb();
},
self);
}
void systemd_units_manager::on_unit_result(
unitUnit * unit,
const GParamSpec * pspec,
void * self_)
{
auto self = (systemd_units_manager *)(self_);
std::string_view state = unit_unit_get_active_state(unit);
bool empty = self->units.empty();
if (state == "inactive" or state == "failed")
std::erase_if(self->units, [&](auto & o) { return o.get() == unit; });
if (self->state_changed_cb and self->units.empty() and not empty)
self->state_changed_cb();
}
namespace
{
struct variant_builder
{
GVariantBuilder builder;
variant_builder(const GVariantType * type)
{
g_variant_builder_init(&builder, type);
}
~variant_builder()
{
g_variant_builder_clear(&builder);
}
auto operator&()
{
return &builder;
}
GVariant * end()
{
return g_variant_builder_end(&builder);
}
};
}; // namespace
void systemd_units_manager::start_application(const std::vector<std::string> & args)
{
if (args.empty())
return;
std::string service_name = std::format("wivrn-application-{}.service", std::chrono::steady_clock::now().time_since_epoch().count());
variant_builder b(G_VARIANT_TYPE("a(sv)"));
g_variant_builder_add(&b,
"(sv)",
"Description",
g_variant_new("s", "Application spawned by WiVRn"));
variant_builder argv(G_VARIANT_TYPE("as"));
for (const auto & arg: args)
g_variant_builder_add(&argv, "s", arg.c_str());
auto exec_start =
g_variant_new("(s@asb)",
args.front().c_str(),
g_variant_new("as", &argv),
false);
g_variant_builder_add(&b,
"(sv)",
"ExecStart",
g_variant_new_array(
nullptr,
&exec_start,
1));
auto properties = b.end();
auto aux = g_variant_new_array(G_VARIANT_TYPE("(sa(sv))"), nullptr, 0);
gchar * job = nullptr;
GError * error = nullptr;
systemd_manager_call_start_transient_unit_sync(
proxy.get(), service_name.c_str(), "replace", properties, aux, &job, nullptr, &error);
if (job)
{
jobs.emplace(job, std::move(service_name));
g_free(job);
}
if (error)
{
std::runtime_error e(std::format("start transient unit failed: {}", error->message));
g_error_free(error);
throw e;
}
}
} // namespace wivrn
+78
View File
@@ -0,0 +1,78 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "start_application.h"
#include <gio/gio.h>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "systemd_manager.h"
#include "systemd_unit.h"
namespace wivrn
{
// Start applications in transient units
class systemd_units_manager : public children_manager
{
struct deleter
{
void operator()(systemdManager *);
void operator()(unitUnit *);
};
GDBusConnection * connection;
std::unique_ptr<systemdManager, deleter> proxy;
std::unordered_map<std::string, std::string> jobs;
std::unordered_set<std::unique_ptr<unitUnit, deleter>> units;
std::function<void()> state_changed_cb;
public:
systemd_units_manager(GDBusConnection * connection, std::function<void()> state_changed_cb);
// create and start the transient unit
void start_application(const std::vector<std::string> &) override;
// true if any unit started by this object is still running
bool running() const override;
void stop() override;
private:
static void on_job_removed(
systemdManagerProxy * proxy,
guint32 id,
gchar * job,
gchar * unit,
gchar * result,
void * self);
static void on_unit_result(
unitUnit * proxy,
const GParamSpec * pspec,
void * self);
};
} // namespace wivrn