Fix freezing on VM shutdown
This commit is contained in:
@@ -55,6 +55,10 @@ export default class QEMUVM extends EventEmitter {
|
|||||||
this.processRestartErrorLevel = 0;
|
this.processRestartErrorLevel = 0;
|
||||||
this.expectedExit = false;
|
this.expectedExit = false;
|
||||||
this.qmpClient = new QMPClient(this.qmpSock, this.qmpType);
|
this.qmpClient = new QMPClient(this.qmpSock, this.qmpType);
|
||||||
|
this.qmpClient.on('qmpshutdown', () => {
|
||||||
|
console.log("[INFO] QEMU requested shutdown, restarting...");
|
||||||
|
this.Restore();
|
||||||
|
});
|
||||||
this.qmpClient.on('connected', () => this.qmpConnected());
|
this.qmpClient.on('connected', () => this.qmpConnected());
|
||||||
this.qmpClient.on('close', () => this.qmpClosed());
|
this.qmpClient.on('close', () => this.qmpClosed());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,20 @@ export default class QMPClient extends EventEmitter {
|
|||||||
}
|
}
|
||||||
if (msg.return !== undefined)
|
if (msg.return !== undefined)
|
||||||
this.emit("qmpreturn", msg.return);
|
this.emit("qmpreturn", msg.return);
|
||||||
else
|
else if(msg.event !== undefined) {
|
||||||
|
switch(msg.event) {
|
||||||
|
case "POWERDOWN":
|
||||||
|
case "STOP":
|
||||||
|
{
|
||||||
|
this.emit("qmpshutdown");
|
||||||
|
break
|
||||||
|
};
|
||||||
|
default: {
|
||||||
|
this.emit("qmpreturn", '');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else
|
||||||
// for now just return an empty string.
|
// for now just return an empty string.
|
||||||
// This is a giant hack but avoids a deadlock
|
// This is a giant hack but avoids a deadlock
|
||||||
this.emit("qmpreturn", '');
|
this.emit("qmpreturn", '');
|
||||||
|
|||||||
Reference in New Issue
Block a user