Skip to content

Commit 123a4d8

Browse files
authored
FirecrackerVM drive not working if /var/lib and /var/cache on two sep… (#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
1 parent 2dfb42b commit 123a4d8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/aleph/vm/hypervisors/firecracker/microvm.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def compute_device_name(index: int) -> str:
365365
def enable_drive(self, drive_path: Path, read_only: bool = True) -> Drive:
366366
"""Make a volume available to the VM.
367367
368-
Creates a symlink to the volume file if jailer is in use.
368+
Creates a hardlink or a copy to the volume file if jailer is in use.
369369
"""
370370
index = len(self.drives)
371371
device_name = self.compute_device_name(index)
@@ -376,6 +376,11 @@ def enable_drive(self, drive_path: Path, read_only: bool = True) -> Drive:
376376

377377
try:
378378
Path(f"{self.jailer_path}/{jailer_path_on_host}").hardlink_to(drive_path)
379+
except OSError as err:
380+
if err.errno == errno.EXDEV:
381+
# Invalid cross-device link: cannot make hard link between partition.
382+
# In this case, copy the file instead:
383+
shutil.copyfile(drive_path, f"{self.jailer_path}/{jailer_path_on_host}")
379384
except FileExistsError:
380385
logger.debug(f"File {jailer_path_on_host} already exists")
381386
drive_path = Path(jailer_path_on_host)

0 commit comments

Comments
 (0)