Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def compute_device_name(index: int) -> str:
def enable_drive(self, drive_path: Path, read_only: bool = True) -> Drive:
"""Make a volume available to the VM.

Creates a symlink to the volume file if jailer is in use.
Creates a hardlink or a copy to the volume file if jailer is in use.
"""
index = len(self.drives)
device_name = self.compute_device_name(index)
Expand All @@ -376,6 +376,11 @@ def enable_drive(self, drive_path: Path, read_only: bool = True) -> Drive:

try:
Path(f"{self.jailer_path}/{jailer_path_on_host}").hardlink_to(drive_path)
except OSError as err:
if err.errno == errno.EXDEV:
# Invalid cross-device link: cannot make hard link between partition.
# In this case, copy the file instead:
shutil.copyfile(drive_path, f"{self.jailer_path}/{jailer_path_on_host}")
except FileExistsError:
logger.debug(f"File {jailer_path_on_host} already exists")
drive_path = Path(jailer_path_on_host)
Expand Down