diff --git a/backend/src/SocketComputerServer.ts b/backend/src/SocketComputerServer.ts index a4cf0c6..91feb44 100644 --- a/backend/src/SocketComputerServer.ts +++ b/backend/src/SocketComputerServer.ts @@ -57,7 +57,7 @@ export class SocketComputerServer { async InitVM() { // Create the VM definition let diskpath = '/srv/collabvm/vms/socket1/winxp.qcow2'; - let slotDef: QemuVmDefinition = Slot_PCDef('2G', '-netdev tap,ifname=ktsocket1,script=no,downscript=no,id=vm.wan', 'rtl8139', 'c0:11:ab:69:44:02', true, diskpath, 'qcow2'); + let slotDef: QemuVmDefinition = Slot_PCDef('2G', '-netdev vde,id=vm.wan,sock=/srv/collabvm/socket_vde2_switch.ctl', 'rtl8139', 'c0:11:ab:69:44:02', true, diskpath, 'qcow2'); // Create the VM this.vm = new SocketVM(new QemuVMShim(slotDef, { diff --git a/backend/src/SocketVM.ts b/backend/src/SocketVM.ts index 6fda9aa..216ef44 100644 --- a/backend/src/SocketVM.ts +++ b/backend/src/SocketVM.ts @@ -13,6 +13,8 @@ import pino from 'pino'; import { JPEGEncoder } from './JPEGEncoder.js'; import { Rect, Size, VMDisplay } from './display/types.js'; +let sleep = (ms: number) => new Promise((r, rj) => setTimeout(() => r(), ms)); + export class SocketVM extends EventEmitter { private vm; private display: VMDisplay | null = null; @@ -282,6 +284,8 @@ export class SocketVM extends EventEmitter { } private async VMStopped() { + // magic sleep. Makes it work. + await sleep(50); await this.vm.Start(); } } diff --git a/backend/src/qemu/qemu_cgroup_launcher.ts b/backend/src/qemu/qemu_cgroup_launcher.ts index a58d52d..d50881b 100644 --- a/backend/src/qemu/qemu_cgroup_launcher.ts +++ b/backend/src/qemu/qemu_cgroup_launcher.ts @@ -72,12 +72,13 @@ class CGroupLimitedProcess extends EventEmitter implements IProcess { this.process = execaCommand(command, opts); - this.stdin = this.process.stdin; - this.stdout = this.process.stdout; - this.stderr = this.process.stderr; - let self = this; this.process.on('spawn', () => { + // asshole + self.stdin = self.process.stdin; + self.stdout = self.process.stdout; + self.stderr = self.process.stderr; + self.initCgroup(); if(self.limits.limitProcess) {