@@ -126,24 +126,29 @@ def _test_rss_memory_lower(test_microvm):
126
126
ssh_connection = net_tools .SSHConnection (test_microvm .ssh_config )
127
127
128
128
# Using deflate_on_oom, get the RSS as low as possible
129
- response = test_microvm .balloon .patch (amount_mb = 200 )
130
- assert test_microvm .api_session .is_status_no_content (response .status_code )
129
+ response = test_microvm .balloon .patch (amount_mib = 200 )
130
+ assert test_microvm .api_session .is_status_no_content (
131
+ response .status_code
132
+ )
131
133
132
134
# Get initial rss consumption.
133
135
init_rss = get_stable_rss_mem_by_pid (firecracker_pid )
134
136
135
137
# Get the balloon back to 0.
136
- response = test_microvm .balloon .patch (amount_mb = 0 )
137
- assert test_microvm .api_session .is_status_no_content (response .status_code )
138
+ response = test_microvm .balloon .patch (amount_mib = 0 )
139
+ assert test_microvm .api_session .is_status_no_content (
140
+ response .status_code
141
+ )
138
142
# This call will internally wait for rss to become stable.
139
143
_ = get_stable_rss_mem_by_pid (firecracker_pid )
140
144
141
145
# Dirty memory, then inflate balloon and get ballooned rss consumption.
142
146
make_guest_dirty_memory (ssh_connection )
143
147
144
- response = test_microvm .balloon .patch (amount_mb = 200 )
145
-
146
- assert test_microvm .api_session .is_status_no_content (response .status_code )
148
+ response = test_microvm .balloon .patch (amount_mib = 200 )
149
+ assert test_microvm .api_session .is_status_no_content (
150
+ response .status_code
151
+ )
147
152
balloon_rss = get_stable_rss_mem_by_pid (firecracker_pid )
148
153
149
154
# Check that the ballooning reclaimed the memory.
@@ -164,7 +169,7 @@ def test_rss_memory_lower(test_microvm_with_ssh_and_balloon, network_config):
164
169
165
170
# Add a memory balloon.
166
171
response = test_microvm .balloon .put (
167
- amount_mb = 0 ,
172
+ amount_mib = 0 ,
168
173
deflate_on_oom = True ,
169
174
stats_polling_interval_s = 0
170
175
)
@@ -191,7 +196,7 @@ def test_inflate_reduces_free(test_microvm_with_ssh_and_balloon,
191
196
192
197
# Install deflated balloon.
193
198
response = test_microvm .balloon .put (
194
- amount_mb = 0 ,
199
+ amount_mib = 0 ,
195
200
deflate_on_oom = False ,
196
201
stats_polling_interval_s = 1
197
202
)
@@ -208,7 +213,7 @@ def test_inflate_reduces_free(test_microvm_with_ssh_and_balloon,
208
213
available_mem_deflated = get_free_mem_ssh (ssh_connection )
209
214
210
215
# Inflate 64 MB == 16384 page balloon.
211
- response = test_microvm .balloon .patch (amount_mb = 64 )
216
+ response = test_microvm .balloon .patch (amount_mib = 64 )
212
217
assert test_microvm .api_session .is_status_no_content (response .status_code )
213
218
# This call will internally wait for rss to become stable.
214
219
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -235,7 +240,7 @@ def test_deflate_on_oom_true(test_microvm_with_ssh_and_balloon,
235
240
236
241
# Add a deflated memory balloon.
237
242
response = test_microvm .balloon .put (
238
- amount_mb = 0 ,
243
+ amount_mib = 0 ,
239
244
deflate_on_oom = True ,
240
245
stats_polling_interval_s = 0
241
246
)
@@ -249,7 +254,7 @@ def test_deflate_on_oom_true(test_microvm_with_ssh_and_balloon,
249
254
ssh_connection = net_tools .SSHConnection (test_microvm .ssh_config )
250
255
251
256
# Inflate the balloon
252
- response = test_microvm .balloon .patch (amount_mb = 172 )
257
+ response = test_microvm .balloon .patch (amount_mib = 172 )
253
258
assert test_microvm .api_session .is_status_no_content (response .status_code )
254
259
# This call will internally wait for rss to become stable.
255
260
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -276,7 +281,7 @@ def test_deflate_on_oom_false(test_microvm_with_ssh_and_balloon,
276
281
277
282
# Add a memory balloon.
278
283
response = test_microvm .balloon .put (
279
- amount_mb = 0 ,
284
+ amount_mib = 0 ,
280
285
deflate_on_oom = False ,
281
286
stats_polling_interval_s = 0
282
287
)
@@ -290,7 +295,7 @@ def test_deflate_on_oom_false(test_microvm_with_ssh_and_balloon,
290
295
ssh_connection = net_tools .SSHConnection (test_microvm .ssh_config )
291
296
292
297
# Inflate the balloon.
293
- response = test_microvm .balloon .patch (amount_mb = 172 )
298
+ response = test_microvm .balloon .patch (amount_mib = 172 )
294
299
assert test_microvm .api_session .is_status_no_content (response .status_code )
295
300
# This call will internally wait for rss to become stable.
296
301
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -313,7 +318,7 @@ def test_reinflate_balloon(test_microvm_with_ssh_and_balloon, network_config):
313
318
314
319
# Add a deflated memory balloon.
315
320
response = test_microvm .balloon .put (
316
- amount_mb = 0 ,
321
+ amount_mib = 0 ,
317
322
deflate_on_oom = True ,
318
323
stats_polling_interval_s = 0
319
324
)
@@ -329,12 +334,12 @@ def test_reinflate_balloon(test_microvm_with_ssh_and_balloon, network_config):
329
334
# First inflate the balloon to free up the uncertain amount of memory
330
335
# used by the kernel at boot and establish a baseline, then give back
331
336
# the memory.
332
- response = test_microvm .balloon .patch (amount_mb = 200 )
337
+ response = test_microvm .balloon .patch (amount_mib = 200 )
333
338
assert test_microvm .api_session .is_status_no_content (response .status_code )
334
339
# This call will internally wait for rss to become stable.
335
340
_ = get_stable_rss_mem_by_pid (firecracker_pid )
336
341
337
- response = test_microvm .balloon .patch (amount_mb = 0 )
342
+ response = test_microvm .balloon .patch (amount_mib = 0 )
338
343
assert test_microvm .api_session .is_status_no_content (response .status_code )
339
344
# This call will internally wait for rss to become stable.
340
345
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -344,12 +349,12 @@ def test_reinflate_balloon(test_microvm_with_ssh_and_balloon, network_config):
344
349
first_reading = get_stable_rss_mem_by_pid (firecracker_pid )
345
350
346
351
# Now inflate the balloon.
347
- response = test_microvm .balloon .patch (amount_mb = 200 )
352
+ response = test_microvm .balloon .patch (amount_mib = 200 )
348
353
assert test_microvm .api_session .is_status_no_content (response .status_code )
349
354
second_reading = get_stable_rss_mem_by_pid (firecracker_pid )
350
355
351
356
# Now deflate the balloon.
352
- response = test_microvm .balloon .patch (amount_mb = 0 )
357
+ response = test_microvm .balloon .patch (amount_mib = 0 )
353
358
assert test_microvm .api_session .is_status_no_content (response .status_code )
354
359
# This call will internally wait for rss to become stable.
355
360
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -359,7 +364,7 @@ def test_reinflate_balloon(test_microvm_with_ssh_and_balloon, network_config):
359
364
third_reading = get_stable_rss_mem_by_pid (firecracker_pid )
360
365
361
366
# Now inflate the balloon again.
362
- response = test_microvm .balloon .patch (amount_mb = 200 )
367
+ response = test_microvm .balloon .patch (amount_mib = 200 )
363
368
assert test_microvm .api_session .is_status_no_content (response .status_code )
364
369
fourth_reading = get_stable_rss_mem_by_pid (firecracker_pid )
365
370
@@ -385,7 +390,7 @@ def test_size_reduction(test_microvm_with_ssh_and_balloon, network_config):
385
390
386
391
# Add a memory balloon.
387
392
response = test_microvm .balloon .put (
388
- amount_mb = 0 ,
393
+ amount_mib = 0 ,
389
394
deflate_on_oom = True ,
390
395
stats_polling_interval_s = 0
391
396
)
@@ -406,7 +411,7 @@ def test_size_reduction(test_microvm_with_ssh_and_balloon, network_config):
406
411
time .sleep (5 )
407
412
408
413
# Now inflate the balloon.
409
- response = test_microvm .balloon .patch (amount_mb = 40 )
414
+ response = test_microvm .balloon .patch (amount_mib = 40 )
410
415
assert test_microvm .api_session .is_status_no_content (response .status_code )
411
416
412
417
# Check memory usage again.
@@ -430,7 +435,7 @@ def test_stats(test_microvm_with_ssh_and_balloon, network_config):
430
435
431
436
# Add a memory balloon with stats enabled.
432
437
response = test_microvm .balloon .put (
433
- amount_mb = 0 ,
438
+ amount_mib = 0 ,
434
439
deflate_on_oom = True ,
435
440
stats_polling_interval_s = 1
436
441
)
@@ -458,7 +463,7 @@ def test_stats(test_microvm_with_ssh_and_balloon, network_config):
458
463
assert initial_stats ['major_faults' ] < after_workload_stats ['major_faults' ]
459
464
460
465
# Now inflate the balloon with 10MB of pages.
461
- response = test_microvm .balloon .patch (amount_mb = 10 )
466
+ response = test_microvm .balloon .patch (amount_mib = 10 )
462
467
assert test_microvm .api_session .is_status_no_content (response .status_code )
463
468
# This call will internally wait for rss to become stable.
464
469
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -478,7 +483,7 @@ def test_stats(test_microvm_with_ssh_and_balloon, network_config):
478
483
479
484
# Deflate the balloon.check that the stats show the increase in
480
485
# available memory.
481
- response = test_microvm .balloon .patch (amount_mb = 0 )
486
+ response = test_microvm .balloon .patch (amount_mib = 0 )
482
487
assert test_microvm .api_session .is_status_no_content (response .status_code )
483
488
# This call will internally wait for rss to become stable.
484
489
_ = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -537,7 +542,7 @@ def _test_balloon_snapshot(context):
537
542
538
543
# Add a memory balloon with stats enabled.
539
544
response = basevm .balloon .put (
540
- amount_mb = 0 ,
545
+ amount_mib = 0 ,
541
546
deflate_on_oom = True ,
542
547
stats_polling_interval_s = 1
543
548
)
@@ -557,7 +562,7 @@ def _test_balloon_snapshot(context):
557
562
first_reading = get_stable_rss_mem_by_pid (firecracker_pid )
558
563
559
564
# Now inflate the balloon with 20MB of pages.
560
- response = basevm .balloon .patch (amount_mb = 20 )
565
+ response = basevm .balloon .patch (amount_mib = 20 )
561
566
assert basevm .api_session .is_status_no_content (response .status_code )
562
567
563
568
# Check memory usage again.
@@ -601,7 +606,7 @@ def _test_balloon_snapshot(context):
601
606
assert fourth_reading > third_reading
602
607
603
608
# Inflate the balloon with another 20MB of pages.
604
- response = microvm .balloon .patch (amount_mb = 40 )
609
+ response = microvm .balloon .patch (amount_mib = 40 )
605
610
assert microvm .api_session .is_status_no_content (response .status_code )
606
611
607
612
fifth_reading = get_stable_rss_mem_by_pid (firecracker_pid )
@@ -653,7 +658,7 @@ def _test_snapshot_compatibility(context):
653
658
654
659
# Add a memory balloon with stats enabled.
655
660
response = microvm .balloon .put (
656
- amount_mb = 0 ,
661
+ amount_mib = 0 ,
657
662
deflate_on_oom = True ,
658
663
stats_polling_interval_s = 1
659
664
)
@@ -731,7 +736,7 @@ def _test_memory_scrub(context):
731
736
732
737
# Add a memory balloon with stats enabled.
733
738
response = microvm .balloon .put (
734
- amount_mb = 0 ,
739
+ amount_mib = 0 ,
735
740
deflate_on_oom = True ,
736
741
stats_polling_interval_s = 1
737
742
)
@@ -745,7 +750,7 @@ def _test_memory_scrub(context):
745
750
make_guest_dirty_memory (ssh_connection , amount = (60 * MB_TO_PAGES ))
746
751
747
752
# Now inflate the balloon with 60MB of pages.
748
- response = microvm .balloon .patch (amount_mb = 60 )
753
+ response = microvm .balloon .patch (amount_mib = 60 )
749
754
assert microvm .api_session .is_status_no_content (response .status_code )
750
755
751
756
# Get the firecracker pid, and open an ssh connection.
@@ -755,7 +760,7 @@ def _test_memory_scrub(context):
755
760
_ = get_stable_rss_mem_by_pid (firecracker_pid )
756
761
757
762
# Deflate the balloon completely.
758
- response = microvm .balloon .patch (amount_mb = 0 )
763
+ response = microvm .balloon .patch (amount_mib = 0 )
759
764
assert microvm .api_session .is_status_no_content (response .status_code )
760
765
761
766
# Wait for the deflate to complete.
0 commit comments