@@ -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,16 @@ 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+
94+ return "balloon" in config and config ["balloon" ] is not None
95+
96+
8597def test_valid_handler (uvm_plain , snapshot ):
8698 """
8799 Test valid uffd handler scenario.
@@ -91,14 +103,16 @@ def test_valid_handler(uvm_plain, snapshot):
91103 vm .spawn ()
92104 vm .restore_from_snapshot (snapshot , resume = True , uffd_handler_name = "on_demand" )
93105
94- # Inflate balloon.
95- vm .api .balloon .patch (amount_mib = 200 )
106+ # Secret Free VMs do not support ballooning so the balloon device is not added to them.
107+ if has_balloon_device (vm ):
108+ # Inflate balloon.
109+ vm .api .balloon .patch (amount_mib = 200 )
96110
97- # Verify if the restored guest works.
98- vm .ssh .check_output ("true" )
111+ # Verify if the restored guest works.
112+ vm .ssh .check_output ("true" )
99113
100- # Deflate balloon.
101- vm .api .balloon .patch (amount_mib = 0 )
114+ # Deflate balloon.
115+ vm .api .balloon .patch (amount_mib = 0 )
102116
103117 # Verify if the restored guest works.
104118 vm .ssh .check_output ("true" )
0 commit comments