qemu: more refactoring

qmp client is now much more robust (and doesn't fight over itself as much). this should
hopefully completely eliminate the case where display connects but qmp is half connected.

i also forgot QemuDisplay actually emits an event on connection, so we can just use that to
wait for when the display connects. which allows us to set the started state there instead of praying
when the qmp client connects that we are connected to the display roughly at the same time.

i also gated some stuff to require vm state in the server. this is a bit rickity, but does seem to work.
This commit is contained in:
modeco80
2024-07-11 20:33:50 -04:00
parent 7423c62957
commit ddf4d97511
4 changed files with 96 additions and 70 deletions

View File

@@ -4,7 +4,7 @@ import VM from '../VM';
import VMDisplay from '../VMDisplay';
import { Clamp, Logger, Rect, Size, Sleep } from '@cvmts/shared';
import { VncClient } from '@computernewb/nodejs-rfb';
import { BatchRects } from '@cvmts/qemu';
import { BatchRects, VMState } from '@cvmts/qemu';
import { execaCommand } from 'execa';
export default class VNCVM extends EventEmitter implements VM, VMDisplay {
@@ -125,6 +125,11 @@ export default class VNCVM extends EventEmitter implements VM, VMDisplay {
return this;
}
GetState(): VMState {
// for now!
return VMState.Started;
}
SnapshotsSupported(): boolean {
return true;
}