WIP: automating VM deployment

This commit is contained in:
Maxime Van Hees
2025-08-26 16:50:59 +02:00
parent 1bb731711b
commit 4b4f3371b0
10 changed files with 1213 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ use sal_os;
use sal_process;
use crate::qcow2;
pub mod builder;
/// Error type for Cloud Hypervisor operations
#[derive(Debug)]
pub enum CloudHvError {
@@ -316,6 +318,10 @@ pub fn vm_start(id: &str) -> Result<(), CloudHvError> {
i += 1;
continue;
}
} else if tok == "--no-default-net" {
// sentinel: suppress default networking; do not pass to CH CLI
i += 1;
continue;
} else if let Some(rest) = tok.strip_prefix("--disk=") {
if !rest.is_empty() {
extra_disk_vals.push(rest.to_string());
@@ -385,7 +391,7 @@ pub fn vm_start(id: &str) -> Result<(), CloudHvError> {
.spec
.extra_args
.as_ref()
.map(|v| v.iter().any(|tok| tok == "--net"))
.map(|v| v.iter().any(|tok| tok == "--net" || tok == "--no-default-net"))
.unwrap_or(false);
if !has_user_net {
@@ -718,6 +724,10 @@ ip link show \"$BR\" >/dev/null 2>&1 || ip link add name \"$BR\" type bridge
ip addr replace \"$BR_ADDR\" dev \"$BR\"
ip link set \"$BR\" up
# IPv6 placeholder address + forward (temporary)
ip -6 addr add 400::1/64 dev \"$BR\" 2>/dev/null || true
sysctl -w net.ipv6.conf.all.forwarding=1 >/dev/null || true
# IPv4 forwarding
sysctl -w net.ipv4.ip_forward=1 >/dev/null