mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-27 05:10:43 +00:00
syz-manager: cosmetic refactoring
1. Don't duplicate VM name generation. 2. Always "shutdown" fuzzers to not keep stale machine info.
This commit is contained in:
parent
01622de2d0
commit
ad54dc7a6d
@ -536,7 +536,9 @@ func (mgr *Manager) runInstance(index int) (*Crash, error) {
|
||||
mgr.checkUsedFiles()
|
||||
instanceName := fmt.Sprintf("vm-%d", index)
|
||||
|
||||
rep, err := mgr.runInstanceInner(index)
|
||||
rep, err := mgr.runInstanceInner(index, instanceName)
|
||||
|
||||
machineInfo := mgr.serv.shutdownInstance(instanceName)
|
||||
|
||||
// Error that is not a VM crash.
|
||||
if err != nil {
|
||||
@ -546,8 +548,6 @@ func (mgr *Manager) runInstance(index int) (*Crash, error) {
|
||||
if rep == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
machineInfo := mgr.serv.getMachineInfo(instanceName)
|
||||
crash := &Crash{
|
||||
vmIndex: index,
|
||||
hub: false,
|
||||
@ -557,7 +557,7 @@ func (mgr *Manager) runInstance(index int) (*Crash, error) {
|
||||
return crash, nil
|
||||
}
|
||||
|
||||
func (mgr *Manager) runInstanceInner(index int) (*report.Report, error) {
|
||||
func (mgr *Manager) runInstanceInner(index int, instanceName string) (*report.Report, error) {
|
||||
inst, err := mgr.vmPool.Create(index)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create instance: %v", err)
|
||||
@ -596,7 +596,6 @@ func (mgr *Manager) runInstanceInner(index int) (*report.Report, error) {
|
||||
atomic.AddUint32(&mgr.numFuzzing, 1)
|
||||
defer atomic.AddUint32(&mgr.numFuzzing, ^uint32(0))
|
||||
|
||||
instanceName := fmt.Sprintf("vm-%d", index)
|
||||
cmd := instance.FuzzerCmd(fuzzerBin, executorCmd, instanceName,
|
||||
mgr.cfg.TargetOS, mgr.cfg.TargetArch, fwdAddr, mgr.cfg.Sandbox, procs, fuzzerV,
|
||||
mgr.cfg.Cover, *flagDebug, false, false)
|
||||
|
@ -310,15 +310,14 @@ func (serv *RPCServer) Poll(a *rpctype.PollArgs, r *rpctype.PollRes) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (serv *RPCServer) getMachineInfo(name string) []byte {
|
||||
func (serv *RPCServer) shutdownInstance(name string) []byte {
|
||||
serv.mu.Lock()
|
||||
defer serv.mu.Unlock()
|
||||
|
||||
fuzzer, ok := serv.fuzzers[name]
|
||||
if !ok {
|
||||
fuzzer := serv.fuzzers[name]
|
||||
if fuzzer == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
serv.fuzzers[name] = nil
|
||||
return fuzzer.machineInfo
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user