Skip to content

Commit

Permalink
Merge pull request #12552 from simondeziel/lxd-agent-setup-script
Browse files Browse the repository at this point in the history
Few small changes to `lxd-agent-setup` script
  • Loading branch information
tomponline authored Nov 27, 2023
2 parents 2d0d062 + 037fc16 commit 2a5b66d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2529,12 +2529,12 @@ PREFIX="/run/lxd_agent"
# Functions.
mount_virtiofs() {
mount -t virtiofs config "${PREFIX}/.mnt" >/dev/null 2>&1
mount -t virtiofs config "${PREFIX}/.mnt" -o ro >/dev/null 2>&1
}
mount_9p() {
/sbin/modprobe 9pnet_virtio >/dev/null 2>&1 || true
/bin/mount -t 9p config "${PREFIX}/.mnt" -o access=0,trans=virtio,size=1048576 >/dev/null 2>&1
modprobe 9pnet_virtio >/dev/null 2>&1 || true
mount -t 9p config "${PREFIX}/.mnt" -o ro,access=0,trans=virtio,size=1048576 >/dev/null 2>&1
}
fail() {
Expand All @@ -2547,21 +2547,18 @@ fail() {
# Setup the mount target.
umount -l "${PREFIX}" >/dev/null 2>&1 || true
mkdir -p "${PREFIX}"
mount -t tmpfs tmpfs "${PREFIX}" -o mode=0700,size=50M
mount -t tmpfs tmpfs "${PREFIX}" -o mode=0700,nodev,nosuid,noatime,size=25M
mkdir -p "${PREFIX}/.mnt"
# Try virtiofs first.
mount_virtiofs || mount_9p || fail "Couldn't mount virtiofs or 9p, failing."
# Copy the data.
cp -Ra "${PREFIX}/.mnt/"* "${PREFIX}"
cp -Ra --no-preserve=ownership "${PREFIX}/.mnt/"* "${PREFIX}"
# Unmount the temporary mount.
umount "${PREFIX}/.mnt"
rmdir "${PREFIX}/.mnt"
# Fix up permissions.
chown -R root:root "${PREFIX}"
`

err = os.WriteFile(filepath.Join(configDrivePath, "systemd", "lxd-agent-setup"), []byte(lxdAgentSetupScript), 0500)
Expand Down

0 comments on commit 2a5b66d

Please sign in to comment.