Prepare, configure, and manage Firecracker microVMs in seconds!
virtualization linux microvm firecracker

fix: update MQTT subscription QoS and enhance IP pinging logic

+14 -8
+13 -7
crates/firecracker-vm/src/mqttc.rs
··· 11 11 mqttoptions.set_keep_alive(Duration::from_secs(5)); 12 12 13 13 let (client, mut eventloop) = AsyncClient::new(mqttoptions, 10); 14 - client.subscribe("/dhcp/#", QoS::AtMostOnce).await?; 14 + client.subscribe("/dhcp/#", QoS::AtLeastOnce).await?; 15 15 16 16 while let Ok(notification) = eventloop.poll().await { 17 17 if let rumqttc::Event::Incoming(rumqttc::Packet::Publish(publish)) = notification { ··· 23 23 })?; 24 24 25 25 if !ip_addr.is_empty() { 26 - println!("[+] Pinging IP address: {}", ip_addr); 27 - if run_command("sh", &["-c", &format!("ping -c 1 {}", ip_addr)], false).is_ok() 28 - { 29 - println!("[+] IP address {} is reachable.", ip_addr); 30 - return Ok(payload_str); 26 + let mut attempts = 0; 27 + while attempts < 3 { 28 + println!("[+] Pinging IP address: {}", ip_addr); 29 + if run_command("sh", &["-c", &format!("ping -c 1 {}", ip_addr)], false) 30 + .is_ok() 31 + { 32 + println!("[+] IP address {} is reachable.", ip_addr); 33 + return Ok(payload_str); 34 + } 35 + println!("[-] IP address {} is not reachable yet.", ip_addr); 36 + attempts += 1; 37 + tokio::time::sleep(Duration::from_millis(500)).await; 31 38 } 32 - println!("[-] IP address {} is not reachable yet.", ip_addr); 33 39 } 34 40 } 35 41 }
+1 -1
crates/firecracker-vm/src/nextdhcp.rs
··· 17 17 18 18 let nextdhcp_config: &str = r#" 19 19 172.16.0.1/24 { 20 - lease 1h 20 + lease 5m 21 21 22 22 range 172.16.0.2 172.16.0.150 23 23