feat: make qemu cpu model/flags configurable
This commit is contained in:
parent
c7bc206ad8
commit
6d6ee135cd
@ -1,5 +1,7 @@
|
|||||||
package distro
|
package distro
|
||||||
|
|
||||||
|
import "code.dumpstack.io/tools/out-of-tree/qemu"
|
||||||
|
|
||||||
// ByRootFS is sorting by .RootFS lexicographically
|
// ByRootFS is sorting by .RootFS lexicographically
|
||||||
type ByRootFS []KernelInfo
|
type ByRootFS []KernelInfo
|
||||||
|
|
||||||
@ -25,6 +27,8 @@ type KernelInfo struct {
|
|||||||
InitrdPath string
|
InitrdPath string
|
||||||
ModulesPath string
|
ModulesPath string
|
||||||
|
|
||||||
|
CPU qemu.CPU
|
||||||
|
|
||||||
RootFS string
|
RootFS string
|
||||||
|
|
||||||
// Debug symbols
|
// Debug symbols
|
||||||
|
8
pew.go
8
pew.go
@ -695,6 +695,14 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
|
|||||||
q.SetSMAP(!ka.Mitigations.DisableSmap)
|
q.SetSMAP(!ka.Mitigations.DisableSmap)
|
||||||
q.SetKPTI(!ka.Mitigations.DisableKpti)
|
q.SetKPTI(!ka.Mitigations.DisableKpti)
|
||||||
|
|
||||||
|
if ki.CPU.Model != "" {
|
||||||
|
q.CPU.Model = ki.CPU.Model
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ki.CPU.Flags) != 0 {
|
||||||
|
q.CPU.Flags = ki.CPU.Flags
|
||||||
|
}
|
||||||
|
|
||||||
if cmd.Endless {
|
if cmd.Endless {
|
||||||
q.Timeout = 0
|
q.Timeout = 0
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,11 @@ type Kernel struct {
|
|||||||
InitrdPath string
|
InitrdPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CPU struct {
|
||||||
|
Model string
|
||||||
|
Flags []string
|
||||||
|
}
|
||||||
|
|
||||||
// System describe qemu parameters and executed process
|
// System describe qemu parameters and executed process
|
||||||
type System struct {
|
type System struct {
|
||||||
arch arch
|
arch arch
|
||||||
@ -55,6 +60,8 @@ type System struct {
|
|||||||
Cpus int
|
Cpus int
|
||||||
Memory int
|
Memory int
|
||||||
|
|
||||||
|
CPU CPU
|
||||||
|
|
||||||
debug bool
|
debug bool
|
||||||
gdb string // tcp::1234
|
gdb string // tcp::1234
|
||||||
|
|
||||||
@ -247,15 +254,23 @@ func (q *System) Args() (qemuArgs []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-initrd", q.kernel.InitrdPath)
|
qemuArgs = append(qemuArgs, "-initrd", q.kernel.InitrdPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpu := "max"
|
||||||
|
if q.CPU.Model != "" {
|
||||||
|
cpu = q.CPU.Model
|
||||||
|
}
|
||||||
|
for _, flag := range q.CPU.Flags {
|
||||||
|
cpu += "," + flag
|
||||||
|
}
|
||||||
|
qemuArgs = append(qemuArgs, "-cpu", cpu)
|
||||||
|
|
||||||
if q.arch == X86x64 || q.arch == X86x32 {
|
if q.arch == X86x64 || q.arch == X86x32 {
|
||||||
if kvmExists() {
|
if kvmExists() {
|
||||||
qemuArgs = append(qemuArgs, "-enable-kvm")
|
qemuArgs = append(qemuArgs, "-enable-kvm")
|
||||||
}
|
}
|
||||||
qemuArgs = append(qemuArgs, "-cpu", "max")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if q.arch == X86x64 && runtime.GOOS == "darwin" {
|
if q.arch == X86x64 && runtime.GOOS == "darwin" {
|
||||||
qemuArgs = append(qemuArgs, "-accel", "hvf", "-cpu", "max")
|
qemuArgs = append(qemuArgs, "-accel", "hvf")
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuArgs = append(qemuArgs, "-append", q.cmdline())
|
qemuArgs = append(qemuArgs, "-append", q.cmdline())
|
||||||
|
Loading…
Reference in New Issue
Block a user