26
26
from enum import Enum
27
27
from functools import lru_cache
28
28
from pathlib import Path
29
- from typing import Optional
29
+ from typing import Optional , Dict
30
30
31
31
from tenacity import retry , stop_after_attempt , wait_fixed
32
32
@@ -919,6 +919,7 @@ def restore_from_snapshot(
919
919
snapshot : Snapshot ,
920
920
resume : bool = False ,
921
921
uffd_path : Path = None ,
922
+ rename_interfaces : Dict [str , str ] = None ,
922
923
):
923
924
"""Restore a snapshot"""
924
925
jailed_snapshot = snapshot .copy_to_chroot (Path (self .chroot ()))
@@ -941,11 +942,16 @@ def restore_from_snapshot(
941
942
if uffd_path is not None :
942
943
mem_backend = {"backend_type" : "Uffd" , "backend_path" : str (uffd_path )}
943
944
945
+ iface_overrides = []
946
+ if rename_interfaces :
947
+ iface_overrides = [{"iface_id" : k , "host_dev_name" : v } for k ,v in rename_interfaces .items ()]
948
+
944
949
self .api .snapshot_load .put (
945
950
mem_backend = mem_backend ,
946
951
snapshot_path = str (jailed_vmstate ),
947
952
enable_diff_snapshots = snapshot .is_diff ,
948
953
resume_vm = resume ,
954
+ network_overrides = iface_overrides ,
949
955
)
950
956
return jailed_snapshot
951
957
@@ -986,13 +992,13 @@ def thread_backtraces(self):
986
992
)
987
993
return "\n " .join (backtraces )
988
994
989
- def wait_for_up (self , timeout = 10 ):
995
+ def wait_for_up (self , timeout = 10 , iface = 0 ):
990
996
"""Wait for guest running inside the microVM to come up and respond.
991
997
992
998
:param timeout: seconds to wait.
993
999
"""
994
1000
try :
995
- rc , stdout , stderr = self .ssh .run ("true" , timeout )
1001
+ rc , stdout , stderr = self .ssh_iface ( iface ) .run ("true" , timeout )
996
1002
except subprocess .TimeoutExpired :
997
1003
print (
998
1004
f"Remote command did not respond within { timeout } s\n \n "
0 commit comments