258 Commits

Author SHA1 Message Date
Dmitry Vyukov
e503f048b0 docs: don't duplicate manager config parameters
Currently we have them duplicated in docs/configuration.md
and the actual source in pkg/mgrconfig/config.go.
Documentation is missing in one place or another,
some is outdated, some is phrased slightly differently.
Move all docs to pkg/mgrconfig/config.go and reference it
from docs/configuration.md instead.
2019-05-21 11:47:51 +02:00
Dmitry Vyukov
32ebe81cf3 pkg/repro: fix no output timeout
We duplicated the no output timeout in the repro package,
and it got out of sync. It's not 3 mins now, but 5 mins.
Remove the duplication and fix this.
2019-05-20 19:40:20 +02:00
Mark Johnston
658d756383 vm/bhyve: ensure the VM is destroyed after closing 2019-05-13 20:23:56 -04:00
Mark Johnston
0637a7f088 Add a bhyve VM backend (#1150)
* vm: add bhyve support

bhyve is FreeBSD's native hypervisor.  Because it is missing snapshot
support and user networking, some additional configuration on the host
is required.  However, unlike QEMU on FreeBSD, bhyve can make use of
hardware virtualization features and is thus faster.

* docs/freebsd: document bhyve support
2019-05-11 19:38:53 +02:00
Dmitry Vyukov
8095117313 all: fix some static analysis warnings
Fix warnings produced by golangci-lint.

Update #977
2019-04-23 17:58:54 +03:00
Dmitry Vyukov
4a9fce1952 all: fix warnings pointed to by golangci-lint
Update #977
2019-03-28 15:30:18 +01:00
Dmitry Vyukov
742f448304 vm/gce: allow non-preemptible VMs
We are seeing some flakes during bisection and image testing.
Hard to tell what's the root cause because they are episodic.
But using non-preemptible VMs for bisection and image testing
looks good on all fronts.

Update #501
2019-03-28 13:22:37 +01:00
Dmitry Vyukov
c298c98302 vm/qemu: detect boot errors faster
Currently we try to ssh into the machine for 10 minutes
even if it crashed right away. Make qemu exit on kernel panic
and stop ssh'ing when qemu exits.
Handling bad kernels fast is actually important for bisection.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
d31d239855 vm/qemu: s/Boot/boot/
Make Boot lower-case to not confuse readers that it's somehow exported.
It is not. Pure implementation detail.
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
b198b1edef vm/vmimpl: don't pass ssh key twice 2019-02-22 18:39:54 +01:00
Siddharth M
7fa29a5895 pkg/build: added feature to copy kernel image for netbsd
* Modified pkg/build/netbsd.go
1. Made kernel build incremental
2. Added code to copy kernel to disk image

* Fix formating issues

* Fixed basic issues

* Fixed copy kernel to disk
1. Added CPU option to default
2. Added snapshot option to vm/qemu/qemu.go
3. Hacky solution to get the build working

* Fixed issues and added vm.MonitorExecution

* Added sync instead of poweroff
2019-02-22 13:18:44 +01:00
Dmitry Vyukov
f16dce862b vm/qemu: fix default flags for arm/arm64
The console and root that we use are specific for 386/amd64.
arm/arm64 usually use a different console and root device.
Use separate settings for 386/amd64 and arm/arm64.
2019-02-13 15:58:42 +01:00
Anton Lindqvist
c69659e352 openbsd: remove shorten report logic (#986)
A line length of 79 in the ddb output does not necessarily imply that the
following line is a continuation of the current line. Since there's no way
to distinguish between ordinary and continuation lines, it could end up
corrupting the report by joining two lines that are disjoint[1].

Instead, disable line wrapping in ddb. If we want some kind of wrapping in
the future it's easier done by pkg/report.

[1] https://syzkaller.appspot.com/bug?extid=03f7377a9848d7d008c9
2019-02-09 08:23:53 -08:00
Anton Lindqvist
66ff894ef5 openbsd: more witness handling
* pkg/report: symbolize witness trace on OpenBSD

* vm/vmimpl: show witness locks on panic

* vm/vmimpl: show memory stats on panic

* fixup! pkg/report: symbolize witness trace on OpenBSD
2019-01-26 09:09:31 +01:00
Dmitry Vyukov
b5d78bce08 vm/vmimpl: fix vet warning about unkeyed struct 2019-01-25 07:29:31 +01:00
Dmitry Vyukov
fea4b504d8 vm/vmimpl: produce better error in WaitForSSH
Currently we squash VerboseError which leads to too lengthy build error titles.
Handle verbose error more carefully.
2019-01-24 18:56:19 +01:00
Andrew Donnellan
4cdc0f5f6b vm/qemu: Disable VGA on ppc64le
Disable qemu VGA output on ppc64le. The current pseries console code in
the kernel has a bunch of bugs, and if you don't disable VGA syzkaller
won't see console output.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-01-15 16:45:20 +01:00
Andrew Donnellan
c7d8a8c07b vm/qemu: Enable KVM on ppc64le
ppc64le supports KVM, let's use it.

This obviously won't work on an x86 host, but at present there are issues
using syzkaller on ppc64le with qemu in TCG mode anyway.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-01-15 16:45:20 +01:00
Dmitry Vyukov
88f5934633 vm: allow fine-grained control over program exit conditions
Currently we only support canExit flag.
However there are actually 3 separate conditions:
 - program can exit normally
 - program can timeout (e.g. fuzzer test or runtest can't)
 - program can exit with error (e.g. C test can)
Allow to specify these 3 conditions separately.
2018-12-24 09:59:56 +01:00
Michael Pratt
603b512405 vm/gvisor: use runsc debug --stacks to diagnose
This feature has been around longer than -trace-signal. It returns the
stacks directly, which we then append to the kernel log.
2018-12-21 18:08:49 +01:00
Michael Pratt
2fc01104d0 vm: allow Diagnose to directly return diagnosis
Rather than writing the diagnosis to the kernel console, Diagnose can
now directly return the extra debugging info, which will be appended ot
the kernel console log.
2018-12-21 18:08:49 +01:00
Dmitry Vyukov
a9cc88c19f pkg/osutil: provide better Rename
os.Rename fails for cross-device renaming (e.g. to/from tmpfs).
This is quite unpleasant. Provide own version that falls back to copying.
2018-12-17 19:09:10 +01:00
Dmitry Vyukov
527230f1d9 vm: fix string duplication
gometalinter says:

vm/vm.go:295:1⚠️ fuzzerPreemptedStr is unused (deadcode)
2018-12-17 10:46:08 +01:00
Dmitry Vyukov
c7e64e2b4f vm: don't call Diagnose when VM hasn't crashed
Fixes #875
2018-12-16 13:54:07 +01:00
Dmitry Vyukov
4bc415c230 vm: add tests for MonitorExecution
This gives almost 100% coverage for MonitorExecution.
Test all corner cases like lost connection, no output,
diagnose, exiting/non-exiting programs, etc.

Update #875
2018-12-16 13:54:03 +01:00
Michael Pratt
d5cf08b04e vm/gvisor: don't close conn on error
If net.Dial returns an error, conn is nil and closing it will panic.
2018-12-13 09:38:49 +01:00
Michael Pratt
c9d6aae44b Merge pull request #872 from prattmic/patch-2
vm/gvisor: support forwarding on IPv6
2018-12-13 09:38:36 +01:00
Dmitry Vyukov
7ed11ab916 vm: respect Shutdown signal in waitForOutput 2018-12-12 13:05:51 +01:00
Michael Pratt
c3b10a5d6a vm/gvisor: replace signal panic with log
Diagnose currently sends the panic signal to generate a traceback for
additional context.

However, Diagnose is also called in otherwise successful scenarios
(vm.Instance.MonitorExecution -> vm.monitor.extractError). Triggering a
panic will make this successful scenario look like a failure.

We could simply suppress this panic, but 1) that means we never shutdown
cleanly (not important, but ugly), and 2) we're less likely to detect
delayed crashes since we kill the sandbox immediately (that's what
MonitorExecution is checking for).

Instead, switch from -panic-signal to -trace-signal, which simply logs a
traceback without exiting. This option was added to runsc in
24c1158b9c.

The other uses of Diagnose will always generate a report regardless of
an additional panic, so we're not losing any reports.
2018-12-12 10:12:35 +01:00
Dmitry Vyukov
7dcaeaf322 vm/gce: close old consolew in Run
Run can be executed several times on a VM.
2018-12-02 13:23:51 +00:00
Greg Steuck
7a0edfbe7c vm/gce: use openbsd console diagnostic code for both vmm and gce
* openbsd: use console diagnostic code for both vmm and gce.

* gometalinter wants less indentation and more stuff in scope

* Comment no longer applies
2018-12-02 13:22:10 +00:00
Michael Tüxen
271b354c51 vm/qemu: improve debug output
* 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.
2018-11-30 17:12:03 +00:00
Michael Tuexen
ade12e9162 vm/qemu: Allow empty qemu-args.
Allow setting qemu_args to "" in the config file. This is needed
when running qemu from the qemu-devel package on FreeBSD, which
does not support the -enable-kvm option.
Without this patch, an entry "" is added to the list of command
line parameters, which breaks the starting of the qemu instances.
2018-11-30 13:12:57 +00:00
Greg Steuck
6419afbb77 openbsd: run on gce
* build/openbsd: minor cleanup (use tuples instead of maps)

* Grammar nits in comments.

* Simplify openbsd.Create, will defer when there's more than one error exit.

* pkg/build: Support copying kernel into GCE image

* Simple test for openbsd image copy build.

* Cleanup in case something failed before.

* Support multi-processor VMs on GCE.

* More debug

* Reformat

* OpenBSD gce image needs to be raw.

* GC

* Force format to GNU directly on Go 1.10 or newer.

* Use vmType passed as a parameter inside openbsd.go

* gofmt

* more fmt

* Can't use GENERIC.mp just yet.

* capitalize

* Copyright
2018-11-27 13:14:06 +01:00
Greg Steuck
5bb36a9ef8 openbsd: include process information into crashes 2018-11-21 05:52:48 +01:00
Anton Lindqvist
f5e275d1d9 vm/vmm: make sure to always end ddb commands with a newline
Missed one in my previous commit.
2018-11-15 14:28:30 -08:00
Anton Lindqvist
74dbb80644 vm/vmm: disable pagination and show panic in Diagnose()
The ddb(4) debugger defaults to showing 24 lines at a time, the next chunk of
lines will be displayed only after receiving keyboard input. Setting maxlines to
0 disables pagination completely.
2018-11-12 12:03:13 -08:00
Dmitry Vyukov
6d8b3311b9 vm/qemu: don't use e1000 on arm64
arm64 uses virtio net by default and does not support e1000.
So don't override the default and use e1000 only for 386/amd64.
2018-10-28 19:07:22 +01:00
Dmitry Vyukov
75f4f60336 vm/qemu: use -cpu host,migratable=off
This exposes the maximum amount of features to the guest.
migratable=off exposes features that qemu does not know about too.
2018-10-28 19:07:22 +01:00
Nicolas Lacasse
d257b2d2d8 Pass -debug flag to runsc.
As of commit 3f053259, gVisor sentry panics are no longer sent to the
stderr for "runsc run" by default, as that stderr belongs exclusively to
the application.

As a result, syzbot never sees the gVisor panic stack trace, and is only
reporting errors that occur when waiting for a dead sandbox.

Passing the "-debug" flag to runsc will make the sentry panics visible
to syzbot again.
2018-10-17 21:43:37 +02:00
Anton Lindqvist
4b94574dd4 vm/vmm: use derived disks for VMs
As a result, the boot time is significantly improved since there's no longer any
need to copy the complete disk.

This feature was recently committed to OpenBSD-current. Any existing base image
used must be recreated, this time using the qcow2 disk format.
2018-10-11 19:47:20 +02:00
Dmitry Vyukov
2d41b5d964 vm/vmm: recover from vmctl errors faster
vmctl start periodically fails with:
	vmctl: start vm command failed: Operation already in progress

So try to sleep for a bit after vmctl stop.
And detect when vmctl start terminates prematurely
to avoid 10 minute timeout for ip extraction.
2018-09-20 19:44:50 +02:00
Dmitry Vyukov
565a5452a1 vm/vmm: don't start separate process for console
vmctl console fails from time to time with:

vmctl: console not found

Probably there is some race (most of these things assume
that there is a human typing commands with delays).

Also, vmctl start can connect to console itself with -c flag.
So use that because it both solves the console race and
also makes code much more similar to other VM implementations (qemu, gvisor).
This also eliminates 3 additional goroutines per VM.
2018-09-20 14:54:07 +02:00
Dmitry Vyukov
23db2ea6f9 vm/vmm: fix fd leaks
Close pipe fd's on failure paths.
Don't close outr because OutputMerger closes all passed in fd's.
2018-09-20 14:54:03 +02:00
Dmitry Vyukov
88f20b7bcc vm/vmm: increase timeouts
A dozen of vmm's running on a GCE machine can be really slow to boot.
Timeouts have only single goal: preventing complete system stalls
when/if external commands episodically hang. There is no value
in keeping them as close as possible to expected durations.
This can only lead to various flakes. Increase timeouts by an
order of magnitude.
2018-09-20 14:53:59 +02:00
Dmitry Vyukov
d1086008f6 vm/vmm: properly shutdown output reading goroutine
The goroutine sends on bootOutputStop to notify about its completion,
but the main goroutine is not receiving from the chan on success
and since the chan in unbuffered, the output reading goroutine
hangs on the send forever.
2018-09-20 14:53:56 +02:00
Dmitry Vyukov
3af0330c9e vm/vmm: make more robust after restarts
Instances from the previous run can still be running,
so always stop the previous instances before starting new ones.
2018-09-20 14:53:52 +02:00
Dmitry Vyukov
1c10e8337a vm/vmm: don't prefix vm name with syzkaller
I am getting:
failed to run vmctl -name syzkaller-ci-openbsd-main-test-0
vmctl: name too long

The name is auto-generated from parts which ensure that it is unique.
We can't easily name it shorter. So strip the syzkaller prefix,
which is not strictly necessary.
2018-09-20 14:53:48 +02:00
Dmitry Vyukov
845e8c5895 vm/vmm: remove cpu parameter, make template optional
CPU is not used. Remove it.
Template is not strictly necessary. Make it optional.
2018-09-20 14:53:44 +02:00
Dmitry Vyukov
a6a09fb2a0 vm/vmm: increase maximum number of VMs
8 is way too low. A modern beefy machine can host a hundred of VMs freely.
Make the limit consistent for all of qemu/kvm/gvisor/vmm and set it to 128.
2018-09-20 14:53:40 +02:00