Skip to content

Commit

Permalink
Allow propolis-standalone to use VMM reservoir
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney committed Jun 27, 2023
1 parent 8aab28b commit ee11fcf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
27 changes: 25 additions & 2 deletions bin/propolis-standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,15 @@ fn build_instance(
max_cpu: u8,
lowmem: usize,
highmem: usize,
use_reservoir: bool,
) -> Result<propolis::Instance> {
let mut builder = Builder::new(
name,
propolis::vmm::CreateOpts { force: true, ..Default::default() },
propolis::vmm::CreateOpts {
force: true,
use_reservoir,
..Default::default()
},
)?
.max_cpus(max_cpu)?
.add_mem_region(0, lowmem, "lowmem")?
Expand Down Expand Up @@ -729,9 +734,27 @@ fn setup_instance(
let lowmem = memsize.min(3 * GB);
let highmem = memsize.saturating_sub(3 * GB);

let use_reservoir = config.main.use_reservoir.unwrap_or(false);
if use_reservoir {
// Do a quick check of the reservoir size if asked to use it
//
// The actual VM create can TOCTOU race, but we can at least raise the
// issue nicely if things are way off.
let ctl = propolis::bhyve_api::VmmCtlFd::open()?;
let resv_info = ctl.reservoir_query()?;
if resv_info.vrq_free_sz < memsize {
slog::warn!(
log,
"Reservoir lacks free capacity ({}MiB < {}MiB)",
resv_info.vrq_free_sz / MB,
memsize / MB
);
}
}

slog::info!(log, "Creating VM with {} vCPUs, {} lowmem, {} highmem",
cpus, lowmem, highmem;);
let pinst = build_instance(vm_name, cpus, lowmem, highmem)
let pinst = build_instance(vm_name, cpus, lowmem, highmem, use_reservoir)
.context("Failed to create VM Instance")?;
let inst = Instance::new(pinst, config.clone(), from_restore, log.clone());
slog::info!(log, "VM created"; "name" => vm_name);
Expand Down
1 change: 1 addition & 0 deletions crates/propolis-standalone-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct Main {
pub cpus: u8,
pub bootrom: String,
pub memory: usize,
pub use_reservoir: Option<bool>,
}

/// A hard-coded device, either enabled by default or accessible locally
Expand Down

0 comments on commit ee11fcf

Please sign in to comment.