cvmts/qemu: support snapshots properly
This commit is contained in:
@@ -60,7 +60,8 @@ async function start() {
|
|||||||
// Fire up the VM
|
// Fire up the VM
|
||||||
let def: QemuVmDefinition = {
|
let def: QemuVmDefinition = {
|
||||||
id: Config.collabvm.node,
|
id: Config.collabvm.node,
|
||||||
command: Config.qemu.qemuArgs
|
command: Config.qemu.qemuArgs,
|
||||||
|
snapshot: Config.qemu.snapshots
|
||||||
};
|
};
|
||||||
|
|
||||||
VM = new QemuVM(def);
|
VM = new QemuVM(def);
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ export enum VMState {
|
|||||||
// TODO: Add bits to this to allow usage (optionally)
|
// TODO: Add bits to this to allow usage (optionally)
|
||||||
// of VNC/QMP port. This will be needed to fix up Windows support.
|
// of VNC/QMP port. This will be needed to fix up Windows support.
|
||||||
export type QemuVmDefinition = {
|
export type QemuVmDefinition = {
|
||||||
id: string;
|
id: string,
|
||||||
command: string;
|
command: string,
|
||||||
|
snapshot: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Temporary path base (for UNIX sockets/etc.)
|
/// Temporary path base (for UNIX sockets/etc.)
|
||||||
@@ -27,12 +28,6 @@ const kVmTmpPathBase = `/tmp`;
|
|||||||
/// the VM is forcefully stopped.
|
/// the VM is forcefully stopped.
|
||||||
const kMaxFailCount = 5;
|
const kMaxFailCount = 5;
|
||||||
|
|
||||||
// TODO: This should be added to QemuVmDefinition and the below export removed
|
|
||||||
let gVMShouldSnapshot = true;
|
|
||||||
|
|
||||||
export function setSnapshot(val: boolean) {
|
|
||||||
gVMShouldSnapshot = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class QemuVM extends EventEmitter {
|
export class QemuVM extends EventEmitter {
|
||||||
private state = VMState.Stopped;
|
private state = VMState.Stopped;
|
||||||
@@ -68,7 +63,7 @@ export class QemuVM extends EventEmitter {
|
|||||||
// FIXME: Still use TCP if on Windows.
|
// FIXME: Still use TCP if on Windows.
|
||||||
if (!this.addedAdditionalArguments) {
|
if (!this.addedAdditionalArguments) {
|
||||||
cmd += ' -no-shutdown';
|
cmd += ' -no-shutdown';
|
||||||
if (gVMShouldSnapshot) cmd += ' -snapshot';
|
if (this.definition.snapshot) cmd += ' -snapshot';
|
||||||
cmd += ` -qmp unix:${this.GetQmpPath()},server,wait -vnc unix:${this.GetVncPath()}`;
|
cmd += ` -qmp unix:${this.GetQmpPath()},server,wait -vnc unix:${this.GetVncPath()}`;
|
||||||
this.definition.command = cmd;
|
this.definition.command = cmd;
|
||||||
this.addedAdditionalArguments = true;
|
this.addedAdditionalArguments = true;
|
||||||
@@ -79,7 +74,7 @@ export class QemuVM extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SnapshotsSupported() : boolean {
|
SnapshotsSupported() : boolean {
|
||||||
return gVMShouldSnapshot;
|
return this.definition.snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
async Reboot() : Promise<void> {
|
async Reboot() : Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user