Skip to content

Commit

Permalink
context: Add max vCPU check
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Fanelli <[email protected]>
  • Loading branch information
tylerfanelli committed Jul 17, 2024
1 parent 2d3599d commit cfe1de2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ impl TryFrom<Args> for KrunContext {
let id = u32::try_from(id).unwrap();

// Set the krun VM's number of vCPUs and amount of memory allocated.
//
// libkrun has a max of 8 vCPUs allowed.
if args.cpus == 0 {
return Err(anyhow!("zero vcpus inputted (invalid)"));
} else if args.cpus > 8 {
return Err(anyhow!("too many vCPUs configured (max 8)"));
}

if args.memory == 0 {
Expand Down

0 comments on commit cfe1de2

Please sign in to comment.