Skip to content

Commit

Permalink
Make virtual disk size configurable via the CLI (#6450)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickryand authored Aug 28, 2024
1 parent 57c3c75 commit 1c99b1a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dev-tools/xtask/src/virtual_hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ enum Commands {

#[clap(long, default_value = PXA_MAC_DEFAULT)]
pxa_mac: String,

/// Size in bytes for created vdevs
#[clap(long, default_value_t = 20 * GB)]
vdev_size: u64,
},
/// Destroy virtual hardware which was initialized with "Create"
Destroy,
Expand Down Expand Up @@ -96,7 +100,6 @@ pub struct Args {

static NO_INSTALL_MARKER: &'static str = "/etc/opt/oxide/NO_INSTALL";
const GB: u64 = 1 << 30;
const VDEV_SIZE: u64 = 20 * GB;

const ARP: &'static str = "/usr/sbin/arp";
const DLADM: &'static str = "/usr/sbin/dladm";
Expand Down Expand Up @@ -163,6 +166,7 @@ pub fn run_cmd(args: Args) -> Result<()> {
gateway_mac,
pxa,
pxa_mac,
vdev_size,
} => {
let physical_link = if let Some(l) = physical_link {
l
Expand All @@ -172,7 +176,7 @@ pub fn run_cmd(args: Args) -> Result<()> {

println!("creating virtual hardware");
if matches!(args.scope, Scope::All | Scope::Disks) {
ensure_vdevs(&sled_agent_config, &args.vdev_dir)?;
ensure_vdevs(&sled_agent_config, &args.vdev_dir, vdev_size)?;
}
if matches!(args.scope, Scope::All | Scope::Network)
&& softnpu_mode == "zone"
Expand Down Expand Up @@ -503,6 +507,7 @@ impl SledAgentConfig {
fn ensure_vdevs(
sled_agent_config: &Utf8Path,
vdev_dir: &Utf8Path,
vdev_size: u64,
) -> Result<()> {
let config = SledAgentConfig::read(sled_agent_config)?;

Expand All @@ -522,7 +527,7 @@ fn ensure_vdevs(
} else {
println!("creating {vdev_path}");
let file = std::fs::File::create(&vdev_path)?;
file.set_len(VDEV_SIZE)?;
file.set_len(vdev_size)?;
}
}
Ok(())
Expand Down

0 comments on commit 1c99b1a

Please sign in to comment.