1
0
Fork 0

Allow to force some qemu settings from .out-of-tree.toml

timestamps
dump_stack() 2019-08-19 18:34:13 +00:00
parent 338300eeec
commit 282d99f511
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
3 changed files with 44 additions and 0 deletions

View File

@ -47,6 +47,11 @@
- New command `pack` that perform tests in subdirectories.
- Added ability to disable kaslr/smep/smap for in artifact definition.
- Added ability to change amount of memory/CPUs and set qemu timeout
in artifact definition (`.out-of-tree.toml`).
### Changed
- Now if there's no base image found — out-of-tree will try to use

View File

@ -12,6 +12,7 @@ import (
"regexp"
"strconv"
"strings"
"time"
"github.com/naoina/toml"
)
@ -83,12 +84,36 @@ func (at ArtifactType) MarshalTOML() (data []byte, err error) {
return
}
// Duration type with toml unmarshalling support
type Duration struct {
time.Duration
}
// UnmarshalTOML for Duration
func (d *Duration) UnmarshalTOML(data []byte) (err error) {
duration := strings.Replace(string(data), "\"", "", -1)
d.Duration, err = time.ParseDuration(duration)
return
}
// Artifact is for .out-of-tree.toml
type Artifact struct {
Name string
Type ArtifactType
SourcePath string
SupportedKernels []KernelMask
Qemu struct {
CPUs int
Memory int
Timeout Duration
}
Mitigations struct {
DisableSMEP bool
DisableSMAP bool
DisableKASLR bool
}
}
func (ka Artifact) checkSupport(ki KernelInfo, km KernelMask) (

14
pew.go
View File

@ -304,6 +304,20 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka config.Artifact,
}
q.Timeout = qemuTimeout
if ka.Qemu.Timeout.Duration != 0 {
q.Timeout = ka.Qemu.Timeout.Duration
}
if ka.Qemu.CPUs != 0 {
q.Cpus = ka.Qemu.CPUs
}
if ka.Qemu.Memory != 0 {
q.Memory = ka.Qemu.Memory
}
q.SetKASLR(!ka.Mitigations.DisableKASLR)
q.SetSMEP(!ka.Mitigations.DisableSMEP)
q.SetSMAP(!ka.Mitigations.DisableSMAP)
err = q.Start()
if err != nil {
log.Println("Qemu start error:", err)