Skip to content

Commit

Permalink
vm/qemu: improve debug output
Browse files Browse the repository at this point in the history
* vm/qemu: Improve debug output.

When running in debug mode, the number of VMs is reduced to 1.
State this in the debug output.

* vm/qemu: Don't start debug output with a capital letter.

As requested by Dimitry.

* vm: Provide debug message when reduing number of VMs.

Apply this change to all affected platforms for consistency.
Suggested by Dmitry.

* Add myself to AUTHORS/CONTRIBUTORS files.

* vm: Fix compilation issues missed in earlier commit.

* vm: Use logging to write debug message.
  • Loading branch information
tuexen authored and dvyukov committed Nov 30, 2018
1 parent bc6b598 commit 271b354
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Chi Pham
Anton Lindqvist
Greg Steuck
Shankara Pailoor
Michael Tuexen
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Joey Jiao
Anton Lindqvist
Tobin Harding
Shankara Pailoor
Michael Tuexen
3 changes: 2 additions & 1 deletion vm/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Count < 1 || cfg.Count > 1000 {
return nil, fmt.Errorf("invalid config param count: %v, want [1, 1000]", cfg.Count)
}
if env.Debug {
if env.Debug && cfg.Count > 1 {
log.Logf(0, "limiting number of VMs from %v to 1 in debug mode", cfg.Count)
cfg.Count = 1
}
if cfg.MachineType == "" {
Expand Down
4 changes: 3 additions & 1 deletion vm/gvisor/gvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"github.com/google/syzkaller/pkg/config"
"github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/vm/vmimpl"
)
Expand Down Expand Up @@ -58,7 +59,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Count < 1 || cfg.Count > 128 {
return nil, fmt.Errorf("invalid config param count: %v, want [1, 128]", cfg.Count)
}
if env.Debug {
if env.Debug && cfg.Count > 1 {
log.Logf(0, "limiting number of VMs from %v to 1 in debug mode", cfg.Count)
cfg.Count = 1
}
if !osutil.IsExist(env.Image) {
Expand Down
3 changes: 2 additions & 1 deletion vm/isolated/isolated.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
return nil, fmt.Errorf("bad target %q: %v", target, err)
}
}
if env.Debug {
if env.Debug && len(cfg.Targets) > 1 {
log.Logf(0, "limiting number of targets from %v to 1 in debug mode", len(cfg.Targets))
cfg.Targets = cfg.Targets[:1]
}
pool := &Pool{
Expand Down
4 changes: 3 additions & 1 deletion vm/kvm/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"github.com/google/syzkaller/pkg/config"
"github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/vm/vmimpl"
)
Expand Down Expand Up @@ -67,7 +68,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Count < 1 || cfg.Count > 128 {
return nil, fmt.Errorf("invalid config param count: %v, want [1, 128]", cfg.Count)
}
if env.Debug {
if env.Debug && cfg.Count > 1 {
log.Logf(0, "limiting number of VMs from %v to 1 in debug mode", cfg.Count)
cfg.Count = 1
}
if env.Image != "" {
Expand Down
3 changes: 2 additions & 1 deletion vm/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Count < 1 || cfg.Count > 128 {
return nil, fmt.Errorf("invalid config param count: %v, want [1, 128]", cfg.Count)
}
if env.Debug {
if env.Debug && cfg.Count > 1 {
log.Logf(0, "limiting number of VMs from %v to 1 in debug mode", cfg.Count)
cfg.Count = 1
}
if _, err := exec.LookPath(cfg.Qemu); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion vm/vmm/vmm.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Count < 1 || cfg.Count > 128 {
return nil, fmt.Errorf("invalid config param count: %v, want [1-128]", cfg.Count)
}
if env.Debug {
if env.Debug && cfg.Count > 1 {
log.Logf(0, "limiting number of VMs from %v to 1 in debug mode", cfg.Count)
cfg.Count = 1
}
if cfg.Mem < 128 || cfg.Mem > 1048576 {
Expand Down

0 comments on commit 271b354

Please sign in to comment.