@@ -5,7 +5,7 @@ use std::ops::Deref;
55use std:: sync:: Arc ;
66use std:: time:: Duration ;
77
8- use log:: { error, info, warn} ;
8+ use log:: { debug , error, info, warn} ;
99use serde:: { Deserialize , Serialize } ;
1010use utils:: time:: TimerFd ;
1111use vmm_sys_util:: eventfd:: EventFd ;
@@ -207,7 +207,7 @@ pub struct BalloonStats {
207207}
208208
209209impl BalloonStats {
210- fn update_with_stat ( & mut self , stat : & BalloonStat ) -> Result < ( ) , BalloonError > {
210+ fn update_with_stat ( & mut self , stat : & BalloonStat ) {
211211 let val = Some ( stat. val ) ;
212212 match stat. tag {
213213 VIRTIO_BALLOON_S_SWAP_IN => self . swap_in = val,
@@ -226,12 +226,8 @@ 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 }
233-
234- Ok ( ( ) )
235231 }
236232}
237233
@@ -503,10 +499,7 @@ impl Balloon {
503499 let stat = mem
504500 . read_obj :: < BalloonStat > ( addr)
505501 . map_err ( |_| BalloonError :: MalformedDescriptor ) ?;
506- self . latest_stats . update_with_stat ( & stat) . map_err ( |_| {
507- METRICS . stats_update_fails . inc ( ) ;
508- BalloonError :: MalformedPayload
509- } ) ?;
502+ self . latest_stats . update_with_stat ( & stat) ;
510503 }
511504
512505 self . stats_desc_index = Some ( head. index ) ;
@@ -1067,52 +1060,52 @@ pub(crate) mod tests {
10671060 val : 1 ,
10681061 } ;
10691062
1070- stats. update_with_stat ( & stat) . unwrap ( ) ;
1063+ stats. update_with_stat ( & stat) ;
10711064 assert_eq ! ( stats. swap_in, Some ( 1 ) ) ;
10721065 stat. tag = VIRTIO_BALLOON_S_SWAP_OUT ;
1073- stats. update_with_stat ( & stat) . unwrap ( ) ;
1066+ stats. update_with_stat ( & stat) ;
10741067 assert_eq ! ( stats. swap_out, Some ( 1 ) ) ;
10751068 stat. tag = VIRTIO_BALLOON_S_MAJFLT ;
1076- stats. update_with_stat ( & stat) . unwrap ( ) ;
1069+ stats. update_with_stat ( & stat) ;
10771070 assert_eq ! ( stats. major_faults, Some ( 1 ) ) ;
10781071 stat. tag = VIRTIO_BALLOON_S_MINFLT ;
1079- stats. update_with_stat ( & stat) . unwrap ( ) ;
1072+ stats. update_with_stat ( & stat) ;
10801073 assert_eq ! ( stats. minor_faults, Some ( 1 ) ) ;
10811074 stat. tag = VIRTIO_BALLOON_S_MEMFREE ;
1082- stats. update_with_stat ( & stat) . unwrap ( ) ;
1075+ stats. update_with_stat ( & stat) ;
10831076 assert_eq ! ( stats. free_memory, Some ( 1 ) ) ;
10841077 stat. tag = VIRTIO_BALLOON_S_MEMTOT ;
1085- stats. update_with_stat ( & stat) . unwrap ( ) ;
1078+ stats. update_with_stat ( & stat) ;
10861079 assert_eq ! ( stats. total_memory, Some ( 1 ) ) ;
10871080 stat. tag = VIRTIO_BALLOON_S_AVAIL ;
1088- stats. update_with_stat ( & stat) . unwrap ( ) ;
1081+ stats. update_with_stat ( & stat) ;
10891082 assert_eq ! ( stats. available_memory, Some ( 1 ) ) ;
10901083 stat. tag = VIRTIO_BALLOON_S_CACHES ;
1091- stats. update_with_stat ( & stat) . unwrap ( ) ;
1084+ stats. update_with_stat ( & stat) ;
10921085 assert_eq ! ( stats. disk_caches, Some ( 1 ) ) ;
10931086 stat. tag = VIRTIO_BALLOON_S_HTLB_PGALLOC ;
1094- stats. update_with_stat ( & stat) . unwrap ( ) ;
1087+ stats. update_with_stat ( & stat) ;
10951088 assert_eq ! ( stats. hugetlb_allocations, Some ( 1 ) ) ;
10961089 stat. tag = VIRTIO_BALLOON_S_HTLB_PGFAIL ;
1097- stats. update_with_stat ( & stat) . unwrap ( ) ;
1090+ stats. update_with_stat ( & stat) ;
10981091 assert_eq ! ( stats. hugetlb_failures, Some ( 1 ) ) ;
10991092 stat. tag = VIRTIO_BALLOON_S_OOM_KILL ;
1100- stats. update_with_stat ( & stat) . unwrap ( ) ;
1093+ stats. update_with_stat ( & stat) ;
11011094 assert_eq ! ( stats. oom_kill, Some ( 1 ) ) ;
11021095 stat. tag = VIRTIO_BALLOON_S_ALLOC_STALL ;
1103- stats. update_with_stat ( & stat) . unwrap ( ) ;
1096+ stats. update_with_stat ( & stat) ;
11041097 assert_eq ! ( stats. alloc_stall, Some ( 1 ) ) ;
11051098 stat. tag = VIRTIO_BALLOON_S_ASYNC_SCAN ;
1106- stats. update_with_stat ( & stat) . unwrap ( ) ;
1099+ stats. update_with_stat ( & stat) ;
11071100 assert_eq ! ( stats. async_scan, Some ( 1 ) ) ;
11081101 stat. tag = VIRTIO_BALLOON_S_DIRECT_SCAN ;
1109- stats. update_with_stat ( & stat) . unwrap ( ) ;
1102+ stats. update_with_stat ( & stat) ;
11101103 assert_eq ! ( stats. direct_scan, Some ( 1 ) ) ;
11111104 stat. tag = VIRTIO_BALLOON_S_ASYNC_RECLAIM ;
1112- stats. update_with_stat ( & stat) . unwrap ( ) ;
1105+ stats. update_with_stat ( & stat) ;
11131106 assert_eq ! ( stats. async_reclaim, Some ( 1 ) ) ;
11141107 stat. tag = VIRTIO_BALLOON_S_DIRECT_RECLAIM ;
1115- stats. update_with_stat ( & stat) . unwrap ( ) ;
1108+ stats. update_with_stat ( & stat) ;
11161109 assert_eq ! ( stats. direct_reclaim, Some ( 1 ) ) ;
11171110 }
11181111
0 commit comments