qemu: Completely rewrite QMP client from scratch

It sucked. The new one is using Sans I/O principles, so it does not
directly do I/O or talk to a net.Socket directly (instead, QemuVM implements
the layer to do I/O). This means in the future this library could actually
be tested, but for now, I'm not bothering with that.

There's also some other cleanups that were bothering me.
This commit is contained in:
modeco80 committed 2024-07-10 22:20:12 -04:00
1 parent 048f08b00b
commit 227a171110
9 files changed
+220 -210

No files matched your search

+7 -6
View File
@@ -119,21 +119,22 @@ export default class CollabVMServer {
this.VM = vm;
// hack but whatever (TODO: less rickity)
let self = this;
if (config.vm.type == 'qemu') {
(vm as QemuVM).on('statechange', (newState: VMState) => {
if(newState == VMState.Started) {
this.logger.Info("started!!");
//self.logger.Info("started!!");
// well aware this sucks but whatever
this.VM.GetDisplay().on('resize', (size: Size) => this.OnDisplayResized(size));
this.VM.GetDisplay().on('rect', (rect: Rect) => this.OnDisplayRectangle(rect));
self.VM.GetDisplay().on('resize', (size: Size) => self.OnDisplayResized(size));
self.VM.GetDisplay().on('rect', (rect: Rect) => self.OnDisplayRectangle(rect));
}
if (newState == VMState.Stopped) {
this.logger.Info('stopped ?');
//self.logger.Info('stopped ?');
setTimeout(async () => {
this.logger.Info('restarting VM');
await this.VM.Start();
self.logger.Info('restarting VM');
await self.VM.Start();
}, kRestartTimeout);
}
});