Skip to content

Commit 46433f1

Browse files
kalyazinroypat
authored andcommitted
test(uffd/valid_handler): do not use balloon if secret free
Do not add a balloon device to a Secret Free VM as it is not currently supported. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent 1f5fa62 commit 46433f1

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

tests/integration_tests/functional/test_uffd.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ def snapshot_fxt(microvm_factory, guest_kernel_linux_5_10, rootfs, secret_free):
2121
basevm.add_net_iface()
2222

2323
# Add a memory balloon.
24-
basevm.api.balloon.put(
25-
amount_mib=0, deflate_on_oom=True, stats_polling_interval_s=0
26-
)
24+
# Note: Secret Free VMs do not support ballooning as of now.
25+
if not secret_free:
26+
basevm.api.balloon.put(
27+
amount_mib=0, deflate_on_oom=True, stats_polling_interval_s=0
28+
)
2729

2830
basevm.start()
2931

@@ -82,6 +84,15 @@ def test_unbinded_socket(uvm_plain, snapshot):
8284
vm.mark_killed()
8385

8486

87+
def has_balloon_device(microvm):
88+
"""
89+
Check if a balloon device is present in the Firecracker microVM.
90+
"""
91+
response = microvm.api.vm_config.get()
92+
config = response.json()
93+
return config.get("balloon")
94+
95+
8596
def test_valid_handler(uvm_plain, snapshot):
8697
"""
8798
Test valid uffd handler scenario.
@@ -91,14 +102,16 @@ def test_valid_handler(uvm_plain, snapshot):
91102
vm.spawn()
92103
vm.restore_from_snapshot(snapshot, resume=True, uffd_handler_name="on_demand")
93104

94-
# Inflate balloon.
95-
vm.api.balloon.patch(amount_mib=200)
105+
# Secret Free VMs do not support ballooning so the balloon device is not added to them.
106+
if has_balloon_device(vm):
107+
# Inflate balloon.
108+
vm.api.balloon.patch(amount_mib=200)
96109

97-
# Verify if the restored guest works.
98-
vm.ssh.check_output("true")
110+
# Verify if the restored guest works.
111+
vm.ssh.check_output("true")
99112

100-
# Deflate balloon.
101-
vm.api.balloon.patch(amount_mib=0)
113+
# Deflate balloon.
114+
vm.api.balloon.patch(amount_mib=0)
102115

103116
# Verify if the restored guest works.
104117
vm.ssh.check_output("true")

0 commit comments

Comments
 (0)