-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
incusd/instance/qemu: Add new agent share
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
- Loading branch information
Showing
2 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
PREFIX="/run/incus_agent" | ||
mkdir -p "${PREFIX}/.mnt" | ||
|
||
# Functions. | ||
mount_virtiofs() { | ||
mount -t virtiofs agent "${PREFIX}/.mnt" -o ro >/dev/null 2>&1 | ||
} | ||
|
||
mount_9p() { | ||
modprobe 9pnet_virtio >/dev/null 2>&1 || true | ||
mount -t 9p agent "${PREFIX}/.mnt" -o ro,access=0,trans=virtio,size=1048576 >/dev/null 2>&1 | ||
} | ||
|
||
# Mount the agent share. | ||
mount_virtiofs || mount_9p || fail "Couldn't mount virtiofs or 9p, failing." | ||
|
||
# Transfer the agent binary. | ||
rm -f "${PREFIX}/incus-agent" | ||
cp -a --no-preserve=ownership "${PREFIX}/.mnt/incus-agent.linux.$(uname -m)" "${PREFIX}/incus-agent" | ||
|
||
# Unmount the temporary mount. | ||
umount "${PREFIX}/.mnt" | ||
rmdir "${PREFIX}/.mnt" | ||
|
||
# Re-exec the agent. | ||
exec "${PREFIX}/incus-agent" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters