Skip to content

Commit 903fd8b

Browse files
committed
feat(balloon): add logging for malformed balloon-stats tag
Added warn logging to the decode of BalloonStats if unknown tag is introduced. Additionally, updated integration test of BalloonStats to fail if this warn occurs. Signed-off-by: Aaron Lo <[email protected]>
1 parent b40982a commit 903fd8b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/vmm/src/devices/virtio/balloon/device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ impl BalloonStats {
227227
VIRTIO_BALLOON_S_ASYNC_RECLAIM => self.async_reclaim = val,
228228
VIRTIO_BALLOON_S_DIRECT_RECLAIM => self.direct_reclaim = val,
229229
_ => {
230-
return Err(BalloonError::MalformedPayload);
230+
let tag = stat.tag;
231+
warn!("balloon: unknown stats update tag: {}", tag);
231232
}
232233
}
233234

tests/integration_tests/functional/test_balloon.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ def test_stats(uvm_plain_any):
320320
# Get another reading of the stats after the polling interval has passed.
321321
deflated_stats = test_microvm.api.balloon_stats.get().json()
322322

323+
# Ensure that stats don't have unknown balloon stats fields
324+
assert "balloon: unknown stats update tag:" not in test_microvm.log_data
325+
323326
# Ensure the stats reflect deflating the balloon.
324327
assert inflated_stats["free_memory"] < deflated_stats["free_memory"]
325328
assert inflated_stats["available_memory"] < deflated_stats["available_memory"]
@@ -372,6 +375,9 @@ def test_stats_update(uvm_plain_any):
372375
final_stats = test_microvm.api.balloon_stats.get().json()
373376
assert next_stats["available_memory"] != final_stats["available_memory"]
374377

378+
# Ensure that stats don't have unknown balloon stats fields
379+
assert "balloon: unknown stats update tag:" not in test_microvm.log_data
380+
375381

376382
def test_balloon_snapshot(uvm_plain_any, microvm_factory):
377383
"""

0 commit comments

Comments
 (0)