File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -856,6 +856,36 @@ def pause_to_snapshot(
856
856
response .status_code
857
857
), response .text
858
858
859
+ def restore_from_snapshot (
860
+ self ,
861
+ * ,
862
+ snapshot_mem : Path ,
863
+ snapshot_vmstate : Path ,
864
+ snapshot_disks : list [Path ],
865
+ snapshot_is_diff : bool = False ,
866
+ ):
867
+ """
868
+ Restores a snapshot, and resumes the microvm
869
+ """
870
+
871
+ # Hardlink all the snapshot files into the microvm jail.
872
+ jailed_mem = self .create_jailed_resource (snapshot_mem )
873
+ jailed_vmstate = self .create_jailed_resource (snapshot_vmstate )
874
+
875
+ assert len (snapshot_disks ) > 0 , "Snapshot requires at least one disk."
876
+ jailed_disks = []
877
+ for disk in snapshot_disks :
878
+ jailed_disks .append (self .create_jailed_resource (disk ))
879
+
880
+ response = self .snapshot .load (
881
+ mem_file_path = jailed_mem ,
882
+ snapshot_path = jailed_vmstate ,
883
+ diff = snapshot_is_diff ,
884
+ resume = True ,
885
+ )
886
+ assert response .ok
887
+ return True
888
+
859
889
def start_console_logger (self , log_fifo ):
860
890
"""
861
891
Start a thread that monitors the microVM console.
You can’t perform that action at this time.
0 commit comments