diff --git a/doc/guest-os-compatibility.md b/doc/guest-os-compatibility.md index ca044597f0a0..5b19dd2d6a4f 100644 --- a/doc/guest-os-compatibility.md +++ b/doc/guest-os-compatibility.md @@ -38,17 +38,19 @@ Windows | 11 23H2 [^5] | Supported | ➖ | ✅ [^8]: This Linux version does not use `systemd` which the LXD agent requires. [^9]: Requires the HWE kernel (`4.15`) for proper `vsock` support which is required by the LXD agent. -Legend: -✅ : recommended -🟢 : supported -➖ : not applicable -❌ : not supported +Legend | Icon +:--- | :--- +recommended | ✅ +supported | 🟢 +not applicable | ➖ +not supported | ❌ ## Notes ### LXD agent The LXD agent provides the ability to execute commands inside of the virtual machine guest without relying on traditional access solution like secure shell (SSH) or Remote Desktop Protocol (RDP). This agent is only supported on Linux guests using `systemd`. +See {ref}`instances-create-iso` for instructions on how to install the LXD agent manually. ### CSM/BIOS boot diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go index c96630458e8d..2e54f1cb0812 100644 --- a/lxd/instance/drivers/driver_qemu.go +++ b/lxd/instance/drivers/driver_qemu.go @@ -2860,22 +2860,50 @@ if [ ! -e "systemd" ] || [ ! -e "lxd-agent" ]; then exit 1 fi -if [ ! -e "/lib/systemd/system" ]; then +# systemd systems always have /run/systemd/system/ created on boot. +if [ ! -d "/run/systemd/system/" ]; then echo "This script only works on systemd systems" exit 1 fi +for path in "/lib/systemd" "/usr/lib/systemd"; do + [ -d "${path}/system" ] || continue + LIB_SYSTEMD="${path}" + break +done + +if [ ! -d "${LIB_SYSTEMD:-}" ]; then + echo "Could not find path to systemd" + exit 1 +fi + +for path in "/lib/udev" "/usr/lib/udev"; do + [ -d "${path}/rules.d/" ] || continue + LIB_UDEV="${path}" + break +done + +if [ ! -d "${LIB_UDEV:-}" ]; then + echo "Could not find path to udev" + exit 1 +fi + # Cleanup former units. -rm -f /lib/systemd/system/lxd-agent-9p.service \ - /lib/systemd/system/lxd-agent-virtiofs.service \ +rm -f "${LIB_SYSTEMD}/system/lxd-agent-9p.service" \ + "${LIB_SYSTEMD}/system/lxd-agent-virtiofs.service" \ /etc/systemd/system/multi-user.target.wants/lxd-agent-9p.service \ /etc/systemd/system/multi-user.target.wants/lxd-agent-virtiofs.service \ /etc/systemd/system/multi-user.target.wants/lxd-agent.service # Install the units. -cp udev/99-lxd-agent.rules /lib/udev/rules.d/ -cp systemd/lxd-agent.service /lib/systemd/system/ -cp systemd/lxd-agent-setup /lib/systemd/ +cp udev/99-lxd-agent.rules "${LIB_UDEV}/rules.d/" +cp systemd/lxd-agent-setup "${LIB_SYSTEMD}/" +if [ "/lib/systemd" = "${LIB_SYSTEMD}" ]; then + cp systemd/lxd-agent.service "${LIB_SYSTEMD}/system/" +else + # Adapt paths for systemd's lib location + sed "/=\/lib\/systemd/ s|=/lib/systemd|=${LIB_SYSTEMD}|" systemd/lxd-agent.service > "${LIB_SYSTEMD}/system/lxd-agent.service" +fi systemctl daemon-reload # SELinux handling.