Skip to content

Commit

Permalink
Make lxd-agent install script compatible with SUSE (#14003)
Browse files Browse the repository at this point in the history
Fixes #13991
  • Loading branch information
tomponline authored Sep 3, 2024
2 parents b073776 + 6d41293 commit e219ff7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
12 changes: 7 additions & 5 deletions doc/guest-os-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 34 additions & 6 deletions lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e219ff7

Please sign in to comment.