Change shutdown behavior

When a VM is shut down, execution will be continued instead of being restored.
This commit is contained in:
MDMCK10
2023-02-11 19:50:23 +01:00
parent 87cefdaaba
commit ab6fb07138

View File

@@ -57,7 +57,7 @@ export default class QEMUVM extends EventEmitter {
this.qmpClient = new QMPClient(this.qmpSock, this.qmpType); this.qmpClient = new QMPClient(this.qmpSock, this.qmpType);
this.qmpClient.on('qmpshutdown', () => { this.qmpClient.on('qmpshutdown', () => {
console.log("[INFO] QEMU requested shutdown, restarting..."); console.log("[INFO] QEMU requested shutdown, restarting...");
this.Restore(); this.Resume();
}); });
this.qmpClient.on('connected', () => this.qmpConnected()); this.qmpClient.on('connected', () => this.qmpConnected());
this.qmpClient.on('close', () => this.qmpClosed()); this.qmpClient.on('close', () => this.qmpClosed());
@@ -217,6 +217,15 @@ export default class QEMUVM extends EventEmitter {
this.Start(); this.Start();
} }
Resume() : Promise<void> {
return new Promise(async (res, rej) => {
if (this.expectedExit) return;
await this.qmpClient.reboot();
await this.qmpClient.execute({ "execute": "cont" });
res();
});
}
Stop() : Promise<void> { Stop() : Promise<void> {
return new Promise<void>(async (res, rej) => { return new Promise<void>(async (res, rej) => {
if (this.expectedExit) {res(); return;} if (this.expectedExit) {res(); return;}