Skip to content

Commit 5cd0e68

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 5baa588 commit 5cd0e68

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::Deref;
55
use std::sync::Arc;
66
use std::time::Duration;
77

8-
use log::{error, info, warn};
8+
use log::{debug, error, info, warn};
99
use serde::{Deserialize, Serialize};
1010
use utils::time::TimerFd;
1111
use vmm_sys_util::eventfd::EventFd;
@@ -226,9 +226,7 @@ impl BalloonStats {
226226
VIRTIO_BALLOON_S_DIRECT_SCAN => self.direct_scan = val,
227227
VIRTIO_BALLOON_S_ASYNC_RECLAIM => self.async_reclaim = val,
228228
VIRTIO_BALLOON_S_DIRECT_RECLAIM => self.direct_reclaim = val,
229-
_ => {
230-
return Err(BalloonError::MalformedPayload);
231-
}
229+
tag => debug!("balloon: unknown stats update tag: {tag}"),
232230
}
233231

234232
Ok(())

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)