-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for configuring memory of the VM and also increases the default memory.
- Loading branch information
1 parent
3042801
commit 4dba297
Showing
12 changed files
with
200 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import FreeBsd from '../../../src/operating_systems/freebsd/freebsd' | ||
import * as hostModule from '../../../src/host' | ||
import * as arch from '../../../src/architecture' | ||
import * as os from '../../../src/operating_systems/kind' | ||
import {Accelerator} from '../../../src/vm' | ||
import HostQemu from '../../../src/host_qemu' | ||
import * as hypervisor from '../../../src/hypervisor' | ||
import * as qemu from '../../../src/qemu_vm' | ||
import * as xhyve from '../../../src/xhyve_vm' | ||
|
||
describe('FreeBSD OperatingSystem', () => { | ||
class MockHost extends hostModule.Host { | ||
get workDirectory(): string { | ||
return '/home/runner/work' | ||
} | ||
|
||
get vmModule(): typeof xhyve | typeof qemu { | ||
return qemu | ||
} | ||
|
||
override get qemu(): HostQemu { | ||
return new HostQemu.LinuxHostQemu() | ||
} | ||
|
||
override get hypervisor(): hypervisor.Hypervisor { | ||
return new hypervisor.Qemu() | ||
} | ||
|
||
override get efiHypervisor(): hypervisor.Hypervisor { | ||
return new hypervisor.QemuEfi() | ||
} | ||
|
||
override get defaultMemory(): string { | ||
return '6G' | ||
} | ||
} | ||
|
||
let host = new MockHost() | ||
let osKind = os.Kind.for('freebsd') | ||
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind) | ||
let freebsd = new FreeBsd(architecture, '0.0.0') | ||
let hypervisorDirectory = 'hypervisor/directory' | ||
let resourcesDirectory = 'resources/directory' | ||
let firmwareDirectory = 'firmware/directory' | ||
|
||
let config = { | ||
memory: '4G', | ||
cpuCount: 0, | ||
diskImage: '', | ||
resourcesDiskImage: '', | ||
userboot: '' | ||
} | ||
|
||
describe('createVirtualMachine', () => { | ||
let vmModule = jasmine.createSpy('vmModule') | ||
|
||
beforeEach(() => { | ||
spyOn(hostModule, 'getHost').and.returnValue(host) | ||
spyOn(host.vmModule, 'resolve').and.returnValue(vmModule) | ||
}) | ||
|
||
it('creates a virtual machine with the correct configuration', () => { | ||
freebsd.createVirtualMachine( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
firmwareDirectory, | ||
config | ||
) | ||
|
||
expect(vmModule).toHaveBeenCalledOnceWith( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
architecture, | ||
{ | ||
...config, | ||
ssHostPort: 2847, | ||
cpu: 'qemu64', | ||
accelerator: Accelerator.tcg, | ||
machineType: 'pc', | ||
uuid: '864ED7F0-7876-4AA7-8511-816FABCFA87F', | ||
firmware: `${firmwareDirectory}/share/qemu/bios-256k.bin` | ||
} | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {QemuVm} from '../../../src/operating_systems/freebsd/qemu_vm' | ||
import * as arch from '../../../src/architecture' | ||
import {host} from '../../../src/host' | ||
import * as os from '../../../src/operating_systems/kind' | ||
import {Accelerator} from '../../../src/vm' | ||
import '../../../src/operating_systems/freebsd/freebsd' | ||
|
||
describe('FreeBSD QemuVm', () => { | ||
let memory = '5G' | ||
|
||
let osKind = os.Kind.for('freebsd') | ||
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind) | ||
let config = { | ||
memory: memory, | ||
cpuCount: 0, | ||
diskImage: '', | ||
ssHostPort: 0, | ||
cpu: '', | ||
accelerator: Accelerator.tcg, | ||
machineType: '', | ||
uuid: '', | ||
resourcesDiskImage: '', | ||
userboot: '', | ||
firmware: '' | ||
} | ||
let vm = new QemuVm('', '', architecture, config) | ||
|
||
let getFlagValue = (flag: string) => vm.command[vm.command.indexOf(flag) + 1] | ||
let actualMemory = () => getFlagValue('-m') | ||
|
||
describe('command', () => { | ||
it('constucts a command with the correct memory configuration', () => { | ||
expect(actualMemory()).toEqual(memory) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters