diff --git a/Justfile b/Justfile index 7bca018..12b3d68 100644 --- a/Justfile +++ b/Justfile @@ -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 diff --git a/src/fs-gen/resources/initfile b/src/fs-gen/resources/initfile index 4d72bc6..14945cd 100644 --- a/src/fs-gen/resources/initfile +++ b/src/fs-gen/resources/initfile @@ -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 \ No newline at end of file diff --git a/src/vmm/src/args.rs b/src/vmm/src/args.rs index 3759420..3feceef 100644 --- a/src/vmm/src/args.rs +++ b/src/vmm/src/args.rs @@ -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, diff --git a/src/vmm/src/core/devices/virtio/net/device.rs b/src/vmm/src/core/devices/virtio/net/device.rs index 96acde6..5432cce 100644 --- a/src/vmm/src/core/devices/virtio/net/device.rs +++ b/src/vmm/src/core/devices/virtio/net/device.rs @@ -46,7 +46,6 @@ impl Net { device_mgr: Arc>, mmio_cfg: MmioConfig, iface_host_addr: Ipv4Addr, - network: Ipv4Addr, netmask: Ipv4Addr, iface_guest_addr: Ipv4Addr, irq: u32, @@ -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, @@ -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 ); diff --git a/src/vmm/src/core/vmm.rs b/src/vmm/src/core/vmm.rs index c1a2121..4eb2ce6 100644 --- a/src/vmm/src/core/vmm.rs +++ b/src/vmm/src/core/vmm.rs @@ -59,7 +59,6 @@ pub struct VMM { vcpus: Vec, iface_host_addr: Ipv4Addr, - network: Ipv4Addr, netmask: Ipv4Addr, iface_guest_addr: Ipv4Addr, net_devices: Vec>>, @@ -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 { @@ -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(), @@ -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, diff --git a/src/vmm/src/grpc/server.rs b/src/vmm/src/grpc/server.rs index 6383c29..e5c6919 100644 --- a/src/vmm/src/grpc/server.rs +++ b/src/vmm/src/grpc/server.rs @@ -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 @@ -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)) diff --git a/src/vmm/src/main.rs b/src/vmm/src/main.rs index 364a377..7f6a748 100644 --- a/src/vmm/src/main.rs +++ b/src/vmm/src/main.rs @@ -42,7 +42,6 @@ async fn main() -> Result<(), Box> { // 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, )