From ab6fb07138553b8c9a98f65dcb963f10929b3844 Mon Sep 17 00:00:00 2001 From: MDMCK10 <21245760+MDMCK10@users.noreply.github.com> Date: Sat, 11 Feb 2023 19:50:23 +0100 Subject: [PATCH] Change shutdown behavior When a VM is shut down, execution will be continued instead of being restored. --- src/QEMUVM.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/QEMUVM.ts b/src/QEMUVM.ts index 6d36697..f68cf01 100644 --- a/src/QEMUVM.ts +++ b/src/QEMUVM.ts @@ -57,7 +57,7 @@ export default class QEMUVM extends EventEmitter { this.qmpClient = new QMPClient(this.qmpSock, this.qmpType); this.qmpClient.on('qmpshutdown', () => { console.log("[INFO] QEMU requested shutdown, restarting..."); - this.Restore(); + this.Resume(); }); this.qmpClient.on('connected', () => this.qmpConnected()); this.qmpClient.on('close', () => this.qmpClosed()); @@ -217,6 +217,15 @@ export default class QEMUVM extends EventEmitter { this.Start(); } + Resume() : Promise { + return new Promise(async (res, rej) => { + if (this.expectedExit) return; + await this.qmpClient.reboot(); + await this.qmpClient.execute({ "execute": "cont" }); + res(); + }); + } + Stop() : Promise { return new Promise(async (res, rej) => { if (this.expectedExit) {res(); return;}