1
0

Move out dmesg cleaning from run

This commit is contained in:
dump_stack() 2018-10-07 14:29:31 +00:00
parent e1ffda19d2
commit 0f569c88cc

16
main.go
View File

@ -157,10 +157,10 @@ func build(tmp string, ka artifact, ki kernelInfo) (outPath string, err error) {
return return
} }
func run(q *qemu.QemuSystem, ka artifact, ki kernelInfo, file string) (output string, err error) { func cleanDmesg(q *qemu.QemuSystem) (err error) {
start := time.Now() start := time.Now()
for { for {
output, err = q.Command("root", "dmesg -c") _, err = q.Command("root", "dmesg -c")
if err == nil { if err == nil {
break break
} }
@ -168,10 +168,13 @@ func run(q *qemu.QemuSystem, ka artifact, ki kernelInfo, file string) (output st
if time.Now().After(start.Add(time.Minute)) { if time.Now().After(start.Add(time.Minute)) {
err = errors.New("Can't connect to qemu") err = errors.New("Can't connect to qemu")
break
}
}
return return
} }
}
func run(q *qemu.QemuSystem, ka artifact, ki kernelInfo, file string) (output string, err error) {
switch ka.Type { switch ka.Type {
case KernelModule: case KernelModule:
output, err = q.CopyAndInsmod(file) output, err = q.CopyAndInsmod(file)
@ -257,6 +260,11 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka artifact, ki kernelInfo) {
} }
build_ok = true build_ok = true
err = cleanDmesg(q)
if err != nil {
return
}
// TODO Write run log to file or database // TODO Write run log to file or database
_, err = run(q, ka, ki, outFile) _, err = run(q, ka, ki, outFile)
if err != nil { if err != nil {