Skip to content

Commit

Permalink
remove network var + add symlink for dns in initfile
Browse files Browse the repository at this point in the history
Signed-off-by: sylvain-pierrot <sylvain.pierrot@etu.umontpellier.fr>
  • Loading branch information
sylvain-pierrot committed May 2, 2024
1 parent 4a60c7a commit f6fe499
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ run:
sudo -E capsh --keep=1 --user=$USER --inh=cap_net_admin --addamb=cap_net_admin -- -c \
'RUST_BACKTRACE=1 '$CARGO_PATH' run --bin vmm -- cli --memory 512 --cpus 1 \
--kernel tools/kernel/linux-cloud-hypervisor/arch/x86/boot/compressed/vmlinux.bin \
--iface-host-addr 172.29.0.1 --netmask 255.255.0.0 --network 172.29.0.0 --iface-guest-addr 172.29.0.2 \
--initramfs=tools/rootfs/initramfs.img'
--iface-host-addr 172.29.0.1 --netmask 255.255.0.0 --iface-guest-addr 172.29.0.2 \
--initramfs=../virt-do/initramfs.img'

build-kernel:
#!/bin/bash
Expand Down
2 changes: 2 additions & 0 deletions src/fs-gen/resources/initfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export RUST_VERSION='1.77.2'

export PATH=$CARGO_HOME/bin:$PATH

ln -s /proc/net/pnp /etc/resolv.conf

/agent

reboot
4 changes: 0 additions & 4 deletions src/vmm/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ pub struct CliArguments {
#[clap(long, env, required = true)]
pub iface_host_addr: Ipv4Addr,

/// Network.
#[clap(long, env, required = true)]
pub network: Ipv4Addr,

/// Subnet mask for network.
#[clap(long, env, required = true)]
pub netmask: Ipv4Addr,
Expand Down
5 changes: 2 additions & 3 deletions src/vmm/src/core/devices/virtio/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl Net {
device_mgr: Arc<Mutex<IoManager>>,
mmio_cfg: MmioConfig,
iface_host_addr: Ipv4Addr,
network: Ipv4Addr,
netmask: Ipv4Addr,
iface_guest_addr: Ipv4Addr,
irq: u32,
Expand Down Expand Up @@ -92,7 +91,7 @@ impl Net {
bridge.set_up();

// Get internet access
iptables_ip_masq(network, netmask, bridge_name);
iptables_ip_masq(iface_host_addr & netmask, netmask, bridge_name);

let net = Arc::new(Mutex::new(Net {
mem,
Expand All @@ -104,7 +103,7 @@ impl Net {
let vmmio_param = register_mmio_device(mmio_cfg, device_mgr, irq, None, net.clone())
.map_err(Error::Virtio)?;
let ip_pnp_param: String = format!(
"ip={}::{}:{}::eth0:off",
"ip={}::{}:{}::eth0:off:1.1.1.1",
iface_guest_addr, iface_host_addr, netmask
);

Expand Down
4 changes: 0 additions & 4 deletions src/vmm/src/core/vmm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub struct VMM {
vcpus: Vec<Vcpu>,

iface_host_addr: Ipv4Addr,
network: Ipv4Addr,
netmask: Ipv4Addr,
iface_guest_addr: Ipv4Addr,
net_devices: Vec<Arc<Mutex<Net>>>,
Expand All @@ -72,7 +71,6 @@ impl VMM {
/// Create a new VMM.
pub fn new(
iface_host_addr: Ipv4Addr,
network: Ipv4Addr,
netmask: Ipv4Addr,
iface_guest_addr: Ipv4Addr,
) -> Result<Self> {
Expand Down Expand Up @@ -118,7 +116,6 @@ impl VMM {
slip_pty: Arc::new(Mutex::new(slip_pty)),
epoll,
iface_host_addr,
network,
netmask,
iface_guest_addr,
net_devices: Vec::new(),
Expand Down Expand Up @@ -390,7 +387,6 @@ impl VMM {
self.device_mgr.clone(),
mmio_cfg,
self.iface_host_addr,
self.network,
self.netmask,
self.iface_guest_addr,
irq,
Expand Down
4 changes: 1 addition & 3 deletions src/vmm/src/grpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl VmmServiceTrait for VmmService {

const HOST_IP: Ipv4Addr = Ipv4Addr::new(172, 29, 0, 1);
const HOST_NETMASK: Ipv4Addr = Ipv4Addr::new(255, 255, 0, 0);
const NETWORK: Ipv4Addr = Ipv4Addr::new(172, 29, 0, 0);
const GUEST_IP: Ipv4Addr = Ipv4Addr::new(172, 29, 0, 2);

// get current directory
Expand Down Expand Up @@ -158,8 +157,7 @@ impl VmmServiceTrait for VmmService {
}
let initramfs_path = PathBuf::from(&initramfs_entire_file_path);

let mut vmm =
VMM::new(HOST_IP, NETWORK, HOST_NETMASK, GUEST_IP).map_err(VmmErrors::VmmNew)?;
let mut vmm = VMM::new(HOST_IP, HOST_NETMASK, GUEST_IP).map_err(VmmErrors::VmmNew)?;

// Configure the VMM parameters might need to be calculated rather than hardcoded
vmm.configure(1, 4000, kernel_path, &Some(initramfs_path))
Expand Down
1 change: 0 additions & 1 deletion src/vmm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new VMM
let mut vmm = VMM::new(
cli_args.iface_host_addr,
cli_args.network,
cli_args.netmask,
cli_args.iface_guest_addr,
)
Expand Down

0 comments on commit f6fe499

Please sign in to comment.