Change shutdown behavior
When a VM is shut down, execution will be continued instead of being restored.
This commit is contained in:
@@ -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<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> {
|
||||
return new Promise<void>(async (res, rej) => {
|
||||
if (this.expectedExit) {res(); return;}
|
||||
|
||||
Reference in New Issue
Block a user