Skip to content

Commit 110e330

Browse files
committed
tests: save metadata on snapshot
There is some information in the Microvm class that we don't save in the snapshot. Some tests do depend on those, so to make the booted/restored case homogenous, make room in the snapshot to save metadata that we can then restore. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 81bae9f commit 110e330

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/framework/microvm.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Snapshot:
7575
disks: dict
7676
ssh_key: Path
7777
snapshot_type: SnapshotType
78+
meta: dict
7879

7980
@property
8081
def is_diff(self) -> bool:
@@ -110,6 +111,7 @@ def copy_to_chroot(self, chroot) -> "Snapshot":
110111
disks=self.disks,
111112
ssh_key=self.ssh_key,
112113
snapshot_type=self.snapshot_type,
114+
meta=self.meta,
113115
)
114116

115117
@classmethod
@@ -125,6 +127,7 @@ def load_from(cls, src: Path) -> "Snapshot":
125127
disks={dsk: src / p for dsk, p in obj["disks"].items()},
126128
ssh_key=src / obj["ssh_key"],
127129
snapshot_type=SnapshotType(obj["snapshot_type"]),
130+
meta=obj["meta"],
128131
)
129132

130133
def save_to(self, dst: Path):
@@ -917,6 +920,9 @@ def make_snapshot(
917920
net_ifaces=[x["iface"] for ifname, x in self.iface.items()],
918921
ssh_key=self.ssh_key,
919922
snapshot_type=snapshot_type,
923+
meta={
924+
"kernel_file": self.kernel_file,
925+
},
920926
)
921927

922928
def snapshot_diff(self, *, mem_path: str = "mem", vmstate_path="vmstate"):
@@ -954,6 +960,9 @@ def restore_from_snapshot(
954960
if uffd_path is not None:
955961
mem_backend = {"backend_type": "Uffd", "backend_path": str(uffd_path)}
956962

963+
for key, value in snapshot.meta.items():
964+
setattr(self, key, value)
965+
957966
self.api.snapshot_load.put(
958967
mem_backend=mem_backend,
959968
snapshot_path=str(jailed_vmstate),

0 commit comments

Comments
 (0)