Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import errno
import json
import logging
import os.path
Expand Down Expand Up @@ -318,7 +319,8 @@ def enable_rootfs(self, path_on_host: Path) -> Path:
def enable_file_rootfs(self, path_on_host: Path) -> Path:
"""Make a rootfs available to the VM.

Creates a symlink to the rootfs file if jailer is in use.
If jailer is in use, try to create a hardlink
If it is not possible to create a link because the dir are in separate device made a copy.
"""
if self.use_jailer:
rootfs_filename = Path(path_on_host).name
Expand All @@ -327,6 +329,13 @@ def enable_file_rootfs(self, path_on_host: Path) -> Path:
os.link(path_on_host, f"{self.jailer_path}/{jailer_path_on_host}")
except FileExistsError:
logger.debug(f"File {jailer_path_on_host} already exists")
except OSError as err:
if err.errno == errno.EXDEV:
# Invalid cross-device link:
# cannot make hard link between partition. Make a copy instead
shutil.copyfile(path_on_host, f"{self.jailer_path}/{jailer_path_on_host}")
else:
raise
return Path(jailer_path_on_host)
else:
return path_on_host
Expand Down