Wait for the state to become stopped in QemuVM#Stop
This commit is contained in:
parent
82065e2899
commit
d4b316962a
1 changed files with 12 additions and 1 deletions
|
@ -160,14 +160,25 @@ export class QemuVM extends EventEmitter {
|
|||
await this.MonitorCommand('system_reset');
|
||||
}
|
||||
|
||||
async Stop() {
|
||||
async Stop() : Promise<void> {
|
||||
this.AssertState(VMState.Started, 'cannot use QemuVM#Stop on a non-started VM');
|
||||
// I'm not sure this is better, but I'm also not sure it should be an assertion
|
||||
//if(this.state !== VMState.Started)
|
||||
// return;
|
||||
|
||||
// Indicate we're stopping, so we don't erroneously start trying to restart everything we're going to tear down.
|
||||
this.SetState(VMState.Stopping);
|
||||
|
||||
// Stop the QEMU process, which will bring down everything else.
|
||||
await this.StopQemu();
|
||||
|
||||
// Wait for the VM to reach the stopped state.
|
||||
return new Promise((res, rej) => {
|
||||
this.once('statechange', (state) => {
|
||||
if(state == VMState.Stopped)
|
||||
res();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async Reset() {
|
||||
|
|
Loading…
Reference in a new issue