1
0
Fork 0

feat: make qemu cpu model/flags configurable

timestamps
dump_stack() 2023-05-31 16:14:58 +00:00
parent c7bc206ad8
commit 6d6ee135cd
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
3 changed files with 29 additions and 2 deletions

View File

@ -1,5 +1,7 @@
package distro
import "code.dumpstack.io/tools/out-of-tree/qemu"
// ByRootFS is sorting by .RootFS lexicographically
type ByRootFS []KernelInfo
@ -25,6 +27,8 @@ type KernelInfo struct {
InitrdPath string
ModulesPath string
CPU qemu.CPU
RootFS string
// Debug symbols

8
pew.go
View File

@ -695,6 +695,14 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
q.SetSMAP(!ka.Mitigations.DisableSmap)
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 {
q.Timeout = 0
}

View File

@ -44,6 +44,11 @@ type Kernel struct {
InitrdPath string
}
type CPU struct {
Model string
Flags []string
}
// System describe qemu parameters and executed process
type System struct {
arch arch
@ -55,6 +60,8 @@ type System struct {
Cpus int
Memory int
CPU CPU
debug bool
gdb string // tcp::1234
@ -247,15 +254,23 @@ func (q *System) Args() (qemuArgs []string) {
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 kvmExists() {
qemuArgs = append(qemuArgs, "-enable-kvm")
}
qemuArgs = append(qemuArgs, "-cpu", "max")
}
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())