From 7423c6295759551dd972498b49a1553330a148c5 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Thu, 11 Jul 2024 03:33:19 -0400 Subject: [PATCH] re-add magic timeouts also remove a problematic line that broke more than it helped --- qemu/src/QemuVM.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qemu/src/QemuVM.ts b/qemu/src/QemuVM.ts index bcdf79e..d0553fb 100644 --- a/qemu/src/QemuVM.ts +++ b/qemu/src/QemuVM.ts @@ -214,7 +214,7 @@ export class QemuVM extends EventEmitter { this.qemuProcess.on('spawn', async () => { self.VMLog().Info('QEMU started'); - await Shared.Sleep(250); + await Shared.Sleep(500); await self.ConnectQmp(); }); @@ -237,7 +237,7 @@ export class QemuVM extends EventEmitter { if (self.state != VMState.Stopping) { if (code == 0) { // Wait a bit and restart QEMU. - await Shared.Sleep(250); + await Shared.Sleep(500); await self.StartQemu(split); } else { self.VMLog().Error('QEMU exited with a non-zero exit code. This usually means an error in the command line. Stopping VM.'); @@ -267,11 +267,10 @@ export class QemuVM extends EventEmitter { return; } + await Shared.Sleep(500); this.qmpSocket = connect(this.GetQmpPath()); this.qmpSocket.on('close', async () => { - self.qmpSocket?.removeAllListeners(); - if (self.qmpConnected) { await self.DisconnectQmp(); @@ -279,7 +278,7 @@ export class QemuVM extends EventEmitter { if (self.state != VMState.Stopping) { if (self.qmpFailCount++ < kMaxFailCount) { self.VMLog().Error(`Failed to connect to QMP ${self.qmpFailCount} times.`); - await Shared.Sleep(250); + await Shared.Sleep(500); await self.ConnectQmp(); } else { self.VMLog().Error(`Reached max retries, giving up.`);