Skip to content

Commit

Permalink
FirecrackerVM drive not working if /var/lib and /var/cache on two sep… (
Browse files Browse the repository at this point in the history
#711)

FirecrackerVM drive not working if /var/lib and /var/cache on two separate partions

Jira Ticket ALEPH-238

Similar issue to #682
That was merged inside #686

We have fixed a variation of this alread but this one triggered for additional volumes only

Explanation:
The prepare step for jailer is failing because it attempt create a hardlink to a file between the CACHE and EXECUTION dir which is not allowed between separate partition

Solution: Make a hardlink
Similiarly to the previous resolution, we cannot make a symlink as it
is not accessible inside the jailer enclave
  • Loading branch information
olethanh authored Oct 17, 2024
1 parent 2dfb42b commit 123a4d8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
@@ -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)
@@ -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)

0 comments on commit 123a4d8

Please sign in to comment.