Skip to content

Commit

Permalink
[vmm]:Fix the division by zero bug when calculating CPU quota
Browse files Browse the repository at this point in the history
Signed-off-by: wabct <wabct_yx@hotmail.com>
  • Loading branch information
Wabct committed Sep 4, 2023
1 parent ed5fd07 commit f8eacf5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vmm/sandbox/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ fn merge_resources(

LinuxContainerResources {
cpu_period: resource1.cpu_period,
cpu_quota: resource1.cpu_quota
+ resource2.cpu_quota * resource1.cpu_period / resource2.cpu_period,
cpu_quota: if resource2.cpu_period != 0 {
resource1.cpu_quota
+ resource2.cpu_quota * resource1.cpu_period / resource2.cpu_period,
} else {
resource1.cpu_quota
},
cpu_shares: resource1.cpu_shares + resource2.cpu_shares,
memory_limit_in_bytes: resource1.memory_limit_in_bytes + resource2.memory_limit_in_bytes,
oom_score_adj,
Expand Down

0 comments on commit f8eacf5

Please sign in to comment.