@@ -450,15 +450,12 @@ def flush_metrics(self):
450450 # get the latest metrics
451451 return self .get_all_metrics ()[- 1 ]
452452
453- def create_jailed_resource (self , path ):
454- """Create a hard link to some resource inside this microvm."""
455- return self .jailer .jailed_path (path , create = True )
456-
457453 def jail_path (self , path ):
458- """Get the relative jailed path to a resource.
454+ """Return a path relative to the chroot
459455
460- Also fix permissions if needed"""
461- return self .jailer .jailed_path (path , create = False )
456+ Copies/hardlinks and fixes permissions as needed.
457+ """
458+ return self .jailer .jailed_path (path )
462459
463460 @property
464461 def chroot (self ):
@@ -562,7 +559,7 @@ def spawn(
562559 if self .metadata_file :
563560 if os .path .exists (self .metadata_file ):
564561 LOG .debug ("metadata file exists, adding as a jailed resource" )
565- self .create_jailed_resource (self .metadata_file )
562+ self .jail_path (self .metadata_file )
566563 self .jailer .extra_args .update (
567564 {"metadata" : os .path .basename (self .metadata_file )}
568565 )
@@ -676,14 +673,12 @@ def basic_config(
676673 if boot_args is not None :
677674 self .boot_args = boot_args
678675 boot_source_args = {
679- "kernel_image_path" : self .create_jailed_resource (self .kernel_file ),
676+ "kernel_image_path" : self .jail_path (self .kernel_file ),
680677 "boot_args" : self .boot_args ,
681678 }
682679
683680 if use_initrd and self .initrd_file is not None :
684- boot_source_args .update (
685- initrd_path = self .create_jailed_resource (self .initrd_file )
686- )
681+ boot_source_args .update (initrd_path = self .jail_path (self .initrd_file ))
687682
688683 self .api .boot .put (** boot_source_args )
689684
@@ -727,10 +722,9 @@ def add_drive(
727722 ):
728723 """Add a block device."""
729724
730- path_on_jail = self .create_jailed_resource (path_on_host )
731725 self .api .drive .put (
732726 drive_id = drive_id ,
733- path_on_host = path_on_jail ,
727+ path_on_host = self . jail_path ( path_on_host ) ,
734728 is_root_device = is_root_device ,
735729 is_read_only = is_read_only ,
736730 partuuid = partuuid ,
@@ -779,7 +773,7 @@ def patch_drive(self, drive_id, file=None):
779773 if file :
780774 self .api .drive .patch (
781775 drive_id = drive_id ,
782- path_on_host = self .create_jailed_resource (file ),
776+ path_on_host = self .jail_path (file ),
783777 )
784778 self .disks [drive_id ] = Path (file )
785779 else :
@@ -891,7 +885,7 @@ def restore_from_snapshot(
891885 assert len (snapshot_disks ) > 0 , "Snapshot requires at least one disk."
892886 jailed_disks = []
893887 for disk in snapshot_disks :
894- jailed_disks .append (self .create_jailed_resource (disk ))
888+ jailed_disks .append (self .jail_path (disk ))
895889 self .disks = snapshot .disks
896890 self .ssh_key = snapshot .ssh_key
897891
0 commit comments