Support for launchd socket activation
Goal
I would like to be able to start libvirtd automatically via socket on macOS in a similar way it can be done on Linux via systemd.
Given a launchd plist file, for example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin</string>
</dict>
<key>Label</key>
<string>org.libvirt.libvirtd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/libvirt/sbin/libvirtd</string>
<string>-f</string>
<string>/usr/local/etc/libvirt/libvirtd.conf</string>
</array>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>Sockets</key>
<dict>
<key>std</key>
<dict>
<key>SockFamily</key>
<string>unix</string>
<key>SockPathMode</key>
<integer>448</integer>
<key>SockPathName</key>
<string>/usr/local/var/run/libvirt/libvirt-sock</string>
<key>SockType</key>
<string>stream</string>
</dict>
</dict>
</dict>
</plist>
once loaded
launchctl load ~/Library/LaunchAgents/org.libvirt.libvirtd.plist
- libvirtd should launch automatically upon first socket connection
- and obtain any necessary details via the launchd API
Technical details
(1) already essentially works, but once the libvirtd
process is launched
the client is left hanging.
$ launchctl list | grep libvirt
- 0 org.libvirt.libvirtd
$ virsh --debug 0 -c qemu:///session?socket=/usr/local/var/run/libvirt/libvirt-sock list --all
list: all(bool): (none)
# and then it's hanging
$ launchctl list | grep libvirt
39173 0 org.libvirt.libvirtd
$ launchctl unload ~/Library/LaunchAgents/org.libvirt.libvirtd.plist
# and errors out once the daemon shuts down
error: failed to connect to the hypervisor
error: End of file while reading data: Input/output error
Edited by Radek Simko