From 1f8b29f57831a5ed076aa2a6f287d8b6900fc318 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 26 Jan 2022 16:08:19 +0100 Subject: [PATCH] file restore: scale per-round delay up dynamically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids latency for restore-VMs that are finished fast but not ready yet the first round while not checking to often for slower ones, iow, we assume that the start up distribution is looking like a chi-square Χ² with k=3. With 25*round we get at max 45 rounds totalling to 25.875 s delay and 1.125 max between-round delay, which still provides an ok reaction time. Signed-off-by: Thomas Lamprecht --- proxmox-file-restore/src/qemu_helper.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxmox-file-restore/src/qemu_helper.rs b/proxmox-file-restore/src/qemu_helper.rs index 9af3ab469..99c45859c 100644 --- a/proxmox-file-restore/src/qemu_helper.rs +++ b/proxmox-file-restore/src/qemu_helper.rs @@ -305,6 +305,7 @@ pub async fn start_vm( let pid_t = Pid::from_raw(pid); let start_poll = Instant::now(); + let mut round = 1; loop { let client = VsockClient::new(cid as i32, DEFAULT_VSOCK_PORT, Some(ticket.to_owned())); if let Ok(Ok(_)) = @@ -324,7 +325,8 @@ pub async fn start_vm( if Instant::now().duration_since(start_poll) > Duration::from_secs(25) { break; } - time::sleep(Duration::from_millis(200)).await; + time::sleep(Duration::from_millis(round * 25)).await; + round += 1; } // start failed