Let's try this again.
This commit is contained in:
@@ -46,7 +46,7 @@ export default class QEMUVM extends VM {
|
|||||||
this.qmpSock = `${Config.vm.qmpSockDir}collab-vm-qmp-${Config.collabvm.node}.sock`;
|
this.qmpSock = `${Config.vm.qmpSockDir}collab-vm-qmp-${Config.collabvm.node}.sock`;
|
||||||
}
|
}
|
||||||
this.vncPort = Config.vm.vncPort;
|
this.vncPort = Config.vm.vncPort;
|
||||||
this.qemuCmd = `${Config.vm.qemuArgs} -no-shutdown -vnc 127.0.0.1:${this.vncPort - 5900} -qmp ${this.qmpType}${this.qmpSock},server`;
|
this.qemuCmd = `${Config.vm.qemuArgs} -no-shutdown -vnc 127.0.0.1:${this.vncPort - 5900} -qmp ${this.qmpType}${this.qmpSock},server,nowait`;
|
||||||
if (Config.vm.snapshots) this.qemuCmd += " -snapshot"
|
if (Config.vm.snapshots) this.qemuCmd += " -snapshot"
|
||||||
this.qmpErrorLevel = 0;
|
this.qmpErrorLevel = 0;
|
||||||
this.vncErrorLevel = 0;
|
this.vncErrorLevel = 0;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import EventEmitter from "events";
|
|||||||
import { Socket } from "net";
|
import { Socket } from "net";
|
||||||
import { Mutex } from "async-mutex";
|
import { Mutex } from "async-mutex";
|
||||||
import log from "./log.js";
|
import log from "./log.js";
|
||||||
|
import { EOL } from "os";
|
||||||
|
|
||||||
export default class QMPClient extends EventEmitter {
|
export default class QMPClient extends EventEmitter {
|
||||||
socketfile : string;
|
socketfile : string;
|
||||||
@@ -34,7 +35,9 @@ export default class QMPClient extends EventEmitter {
|
|||||||
}
|
}
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
this.socket.on('error', () => false); // Disable throwing if QMP errors
|
this.socket.on('error', () => false); // Disable throwing if QMP errors
|
||||||
this.socket.on('data', (data) => this.onData(data));
|
this.socket.on('data', (data) => {
|
||||||
|
data.toString().split(EOL).forEach(instr => this.onData(instr));
|
||||||
|
});
|
||||||
this.socket.on('close', () => this.onClose());
|
this.socket.on('close', () => this.onClose());
|
||||||
this.once('connected', () => {res();});
|
this.once('connected', () => {res();});
|
||||||
})
|
})
|
||||||
@@ -45,12 +48,11 @@ export default class QMPClient extends EventEmitter {
|
|||||||
this.socket.destroy();
|
this.socket.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onData(data : Buffer) {
|
private async onData(data : string) {
|
||||||
let msgraw = data.toString();
|
|
||||||
let msg;
|
let msg;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
msg = JSON.parse(msgraw);
|
msg = JSON.parse(data);
|
||||||
} catch {
|
} catch {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -64,7 +66,7 @@ export default class QMPClient extends EventEmitter {
|
|||||||
this.emit('connected');
|
this.emit('connected');
|
||||||
this.sentConnected = true;
|
this.sentConnected = true;
|
||||||
}
|
}
|
||||||
if (msg.return !== undefined)
|
if (msg.return !== undefined && Object.keys(msg.return).length)
|
||||||
this.emit("qmpreturn", msg.return);
|
this.emit("qmpreturn", msg.return);
|
||||||
else if(msg.event !== undefined) {
|
else if(msg.event !== undefined) {
|
||||||
switch(msg.event) {
|
switch(msg.event) {
|
||||||
@@ -76,14 +78,13 @@ export default class QMPClient extends EventEmitter {
|
|||||||
}
|
}
|
||||||
case "RESET":
|
case "RESET":
|
||||||
{
|
{
|
||||||
|
if(msg.data.reason == "host-qmp-system-reset") {
|
||||||
log("INFO", "QEMU reset event occured");
|
log("INFO", "QEMU reset event occured");
|
||||||
this.resume();
|
this.resume();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
default: {
|
default: break;
|
||||||
this.emit("qmpreturn", '');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
// for now just return an empty string.
|
// for now just return an empty string.
|
||||||
|
|||||||
Reference in New Issue
Block a user