Skip to content

Commit

Permalink
fixup! Fix #73: OpenBSD VM fails during "Initializing VM" with QEMU o…
Browse files Browse the repository at this point in the history
…n macOS
  • Loading branch information
jacob-carlborg committed Jan 10, 2024
1 parent 2e2e4a9 commit 6c96e98
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
21 changes: 17 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/operating_systems/openbsd/openbsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as core from '@actions/core'
import * as architecture from '../../architecture'
import {operatingSystem} from '../factory'
import * as vmModule from '../../vm'
import {QemuVm} from './qemu_vm'
import {QemuVm, QemuVmX86_64} from './qemu_vm'
import * as os from '../../operating_system'
import versions from '../../version'
import {XhyveVm} from './xhyve_vm'
Expand Down Expand Up @@ -65,7 +65,9 @@ export default class OpenBsd extends os.OperatingSystem {
uuid: this.uuid
}

const cls = this.hypervisor.resolve({qemu: QemuVm, xhyve: XhyveVm})
let cls = this.hypervisor.resolve({qemu: QemuVm, xhyve: XhyveVm})
cls = this.architecture.resolve({x86_64: QemuVmX86_64, default: cls})

return new cls(
hypervisorDirectory,
resourcesDirectory,
Expand Down
7 changes: 7 additions & 0 deletions src/operating_systems/openbsd/qemu_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ export class QemuVm extends Vm {
return this.architecture.networkDevice
}
}

export class QemuVmX86_64 extends QemuVm {
protected override get cpuidFlags(): string[] {
// disable huge pages, otherwise OpenBSD will not boot: https://gitlab.com/qemu-project/qemu/-/issues/1091
return ['-pdpe1gb']
}
}
11 changes: 9 additions & 2 deletions src/qemu_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export abstract class Vm extends vm.Vm {
this.hypervisorPath.toString(),
'-daemonize',
'-machine', `type=${this.configuration.machineType},accel=${accel}`,
// "-pdpe1gb" == disable huge pages, otherwise OpenBSD will not boot: https://gitlab.com/qemu-project/qemu/-/issues/1091
'-cpu', `${this.configuration.cpu},-pdpe1gb`,
'-cpu', this.cpuFlagValue,
'-smp', this.configuration.cpuCount.toString(),
'-m', this.configuration.memory,

Expand Down Expand Up @@ -78,6 +77,10 @@ export abstract class Vm extends vm.Vm {
return ''
}

protected get cpuidFlags(): string[] {
return []
}

private get netdev(): string {
return [
'user',
Expand All @@ -88,6 +91,10 @@ export abstract class Vm extends vm.Vm {
.filter(e => e !== '')
.join(',')
}

private get cpuFlagValue(): string {
return [this.configuration.cpu, ...this.cpuidFlags].join(',')
}
}

export function resolve<T>(implementation: Record<string, T>): T {
Expand Down

0 comments on commit 6c96e98

Please sign in to comment.