Commit graph

901 commits

Author SHA1 Message Date
Zach Reizner
8fb5211c3b crosvm: refactor linux vm running sequence
The old sequence used tail cails to foward resources to the next stage
of the process, making it cumbersome to add new resources to earlier
stages. Certain tasks, such as IO port bus creation or irqfd
registration, were delayed to late stages for no good reason, causing
the stage names to have no correspondence with their contents.

The new sequence organizes setup into logical functions that only receive
and return resources that make sense for their operations.

BUG=None
TEST=./build_test; cargo run

Change-Id: Idaf1488da515e2473125333bf997638da60fa992
Reviewed-on: https://chromium-review.googlesource.com/822927
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-04 19:17:54 -08:00
Zach Reizner
d3a7a1f63e crosvm: have DeviceManager make direct VM changes
The old DeviceManager made changes to VM indirectly using VM control
messages. This change gives the DeviceManager a VM reference to make
changes directly. This simplifies things by removing the need for an
extra loop to pending VM control messages.

BUG=None
TEST=./build_test

Change-Id: I6866015ddf3216a1f03d6ac0431548e3b827b750
Reviewed-on: https://chromium-review.googlesource.com/823263
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-01-04 19:17:54 -08:00
Zach Reizner
855ac29cf2 kvm: add dirty log support
This add safe support for KVM's KVM_GET_DIRTY_LOG ioctl.

TEST=./build_test
BUG=None

Change-Id: I3d0f996927844a33addd072f2bfc62361f8b7fe0
Reviewed-on: https://chromium-review.googlesource.com/848019
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-03 16:54:34 -08:00
Zach Reizner
20c3c2af2f sys_util: allow empty GuestMemory
This is needed for plugin process style executions because they don't
register guest memory though the GuestMemory interface. Their memory is
more dynamic and ill-suited to the GuestMemory abstraction.

TEST=./build_test
BUG=None

Change-Id: I250b0b874ef6a0e342fd6e659301f389d01a4cda
Reviewed-on: https://chromium-review.googlesource.com/848018
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Zach Reizner
df59500364 kvm: add KVM_SET_IDENTITY_MAP_ADDR ioctl
BUG=None
TEST=./build_test

Change-Id: Ic5b479487f45949fd0888af6d670293931a6a0a7
Reviewed-on: https://chromium-review.googlesource.com/848017
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Zach Reizner
d60bb1616c kvm: add KVM_GET_FPU ioctl
BUG=None
TEST=./build_test

Change-Id: I38ee166d9c7a0340d58fb3fd7f51895ca158f8b3
Reviewed-on: https://chromium-review.googlesource.com/848016
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Zach Reizner
ce4611cde2 kvm: open /dev/kvm with close on exec
Without this, the KVM FD may leak to child processes.

BUG=None
TEST=./build_test

Change-Id: Ic2f6db6c787d99865c2eefb40ad8993471ee82b2
Reviewed-on: https://chromium-review.googlesource.com/848015
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Dylan Reid
d44320488f main: Add inflate/deflate interface for balloon
Change-Id: I0fc63abbed8db303c7d283ce392fd47777b60d19
Reviewed-on: https://chromium-review.googlesource.com/818207
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-02 23:36:26 -08:00
Sonny Rao
4aa86930ed kvm_sys: update bindings and add aarch64 bindings
Re-generated the bindings for x86_64 and arm which now use union types
so a little bit of code in the library also changed, and adds bindings
for aarch64 which are required to run an aarch64 guest.

Also, I manually fixed the zero-length array cases where rust bindgen
doesn't properly align the structs.  See rust bindgen bug 684.

BUG=chromium:797868
TEST=run crosvm on x86_64, ensure networking works
TEST=./build_test passes on x86

Change-Id: Iab2193a8f1d4c68bd3346ae683c74bbf16fe45d4
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845519
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-02 21:32:18 -08:00
Dylan Reid
295ccac1f3 devices: Add balloon
The balloon device is used to take regions of unused memory from the
guest and allow other host processes to use that memory.

Change-Id: I06c821365a58672d605fc7555beaec599cae1b15
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/759306
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-12-18 17:54:57 -08:00
Zach Reizner
39aa26b168 crosvm: move run_config to its own module
This is to clearly separate the Linux VM setup code from main's argument
parsing logic. This will also make it easier to add other kinds of VM
setup code without littering main or the Linux setup sequence.

BUG=None
TEST=./build_test; cargo run

Change-Id: I8e28720df760357cf00c9711ca5f1f8d6c077844
Reviewed-on: https://chromium-review.googlesource.com/823610
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-12-14 18:11:53 -08:00
Dylan Reid
5649a04426 main: Use /var/empty for jailed roots
/var/empty always exists on cros devices and is commonly used by recent
minijail configs throughout the system. Using it here saves several
variables and removes some error paths.

Leave the wayland root as it needs to be owned by the wayland group.

Change-Id: I261915f4419cadb3f121e9c423c79e467b014700
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/816536
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-12-11 22:44:27 -08:00
Dylan Reid
2415ef6988 sys_util: Add ability to madvise a region
Add functions to let the kernel know a given range of memory isn't
needed currently. This function will result in `madvise(DONTNEED)`.

The ability to signal memory as not needed will be used by the balloon
driver to allow system memory to be redistributed away from the VM.

Change-Id: I4ca56e09010eec33989824f5738db4a4be0ec428
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/759305
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-12-08 00:37:01 -08:00
Dylan Reid
fedb675ed5 x85: mptable: Move the mptable to the end of base RAM
Recent Linux kernel's fail to start if the mptable is at the start of
RAM (address 0x00). Avoid putting the mptable there so that crosvm can
boot 4.14+ kernels. The kernel scans the last kilobyte of RAM after the
first, move the mptable there.

Change-Id: Ia00f49e7a4cbd0fb3719c21b757e8fdca65584e8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/780045
2017-11-21 15:58:40 -08:00
Dylan Reid
939d58827e Make the main crosvm project a workspace
Making the project a workspace allows running all local libs unit tests
from the main build.

Change-Id: Ib531dd10c21f324c7d25af69ad12b95c7bc8f3bc
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/759597
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-11-20 18:13:46 -08:00
Dylan Reid
5327d059a2 mptable: Fix range check and unit tests
The table grew with the addition of the 16 mpc_intsrc structures.
Correct the `compute_mp_size` function, the end check, and add a unit
test for the not having enough memory.

Change-Id: I1ff268629a47a422f50aefef9d6aa95121b94d59
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/777710
Reviewed-by: Slava Malyugin <slavamn@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-11-17 20:18:24 -08:00
Dylan Reid
bd035c780b io_jail: Fix doc tests and docs
There were remnants of using `minijail_enter`, switch them to
`minijail_fork`.

Change-Id: I5c695cbc3bfd6868f25f46f785a2f96391744d90
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/759598
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-11-17 20:18:24 -08:00
Dylan Reid
f31455e966 sys_util/vm_control: Don't test shm if memfd_create doesn't exist
On older kernels, the memfd_create syscall isn't available. Skip shm
tests if that is the case.

Change-Id: I39c1f1779f1f02e90df727c6ca18b5bdae52e855
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/768102
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-11-16 21:07:43 -08:00
Slava Malyugin
15ac873218 crosvm: fix MPTable, enable apic
The mptable inherited from kvmtool had some missing pieces. On top of that,
crosvm does not use KVM_SET_GSI_ROUTING. The addresses makes mptable match
the default routing in host kernel and removes "noapic".

TEST=cargo build (--release). tatl boot tested on 4.4.0 and 4.4.9

Change-Id: Ibc55abf245cd9d8fca601da204d5a189321c09c7
Reviewed-on: https://chromium-review.googlesource.com/772820
Commit-Ready: Slava Malyugin <slavamn@google.com>
Tested-by: Slava Malyugin <slavamn@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-11-15 20:21:05 -08:00
Zach Reizner
4e7feeec3e wl: increase max FDs to send/recv
This change is to support a related kernel change but is backwards
compatible with kernels without that change.

BUG=chromium:782474
TEST=None

Change-Id: Ic1224b65ed9685f246002f946cfc6bfa2dbb2856
Reviewed-on: https://chromium-review.googlesource.com/770593
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-11-15 16:07:28 -08:00
Stephen Barber
8b0d12cb0a crosvm: don't die on suspend/resume
Suspend/resume can cause syscall restarts and will cause KVM_RUN ioctls
to return with EINTR. Handle these so the VM doesn't shut down.

BUG=none
TEST=vm survives suspend/resume

Change-Id: I1fab624cb8fe0949d341408f0c962c859a034205
Reviewed-on: https://chromium-review.googlesource.com/750054
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-11-02 11:07:13 -07:00
Zach Reizner
ad98452a14 io_jail: correct io_jail tests that used Minijail::enter()
This also updates the `build_test.py` to use the command line option to
run certain certain test modules serially.

TEST=./build_test
BUG=None

Change-Id: I8a498514cb6b89fab01f02d0ef8faf39629f717c
Reviewed-on: https://chromium-review.googlesource.com/748824
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-11-01 14:06:30 -07:00
Stephen Barber
082aecec87 crosvm: remove stdin from pollables at EOF/error
If reading from stdin returns EOF or an error, remove it from the list
of pollables.

BUG=none
TEST=`vm_launcher start` and check that crosvm no longer pegs CPU

Change-Id: I7971058701e6145884de9c52a8dd5b829373637b
Reviewed-on: https://chromium-review.googlesource.com/745961
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-31 19:50:44 -07:00
Stephen Barber
ce374793bf crosvm/devices: set thread names
crosvm spawns a lot of processes/threads, and having these all use the same
name as the original process can be confusing. So at least in the instances
where Rust threads are spawned (vs. minijail_fork()), use a thread::Builder
to allow setting the thread name.

BUG=none
TEST=start crosvm, check thread names with top

Change-Id: I6e55ff5fd60f258880bda8e656ab7f9da82c656e
Reviewed-on: https://chromium-review.googlesource.com/742394
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-10-30 23:21:37 -07:00
Zach Reizner
d657af628a kvm: reuse memory region slots
There is a low limit on the maximum memory slot number imposed by the
kernel. On x86_64, that limit is 509. In order to delay hitting that
limit, we attempt to use the lowest unused slot number. As memory
regions are removed from the VM, the slot for that region is stored in a
heap so that that slot number can quickly be reused next time a memory
region is added.

BUG=None
TEST=finish a game of gnome-mahjong using virtio-wayland

Change-Id: I786c2e2b8ff239c19b3c8a18bd0f6e8f8dc2acbf
Reviewed-on: https://chromium-review.googlesource.com/740102
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-10-30 01:31:35 -07:00
Stephen Barber
28a5a61616 crosvm: allow specifying wayland path and group
Add a wayland-sock argument for specifying the path to the
wayland socket. Also add a wayland-group argument for specifying
the group that has access to that socket.

BUG=none
TEST=crosvm starts with wayland

Change-Id: I3e53eb697951200340613663dc3e4ed28d8ed7f8
Reviewed-on: https://chromium-review.googlesource.com/733732
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-10-26 04:17:52 -07:00
Stephen Barber
f70a9d46e7 sys_util: add chown wrapper
BUG=none
TEST=compile

Change-Id: I3ae66955b48c8cd7ae2f468da8780c85fce539d2
Reviewed-on: https://chromium-review.googlesource.com/733731
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-10-26 04:17:52 -07:00
Stephen Barber
5bf651c0e4 sys_util: add get_user_id and get_group_id functions
Add safe wrappers for getpwnam_r and getgrnam_r.

BUG=none
TEST=./build_test

Change-Id: I737b4d264334ed788884a7320f5649cfc2266709
Reviewed-on: https://chromium-review.googlesource.com/733730
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-10-26 04:17:52 -07:00
Stephen Barber
7a2fec4596 crosvm: bump libc version to 0.2.32
Uprev to 0.2.32 for getgrnam_r.

BUG=none
TEST=./build_test
CQ-DEPEND=CL:734622

Change-Id: I4bc924633b179258c815eaf38f25e7e53d3f0fa5
Reviewed-on: https://chromium-review.googlesource.com/733729
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-25 19:30:15 -07:00
Dylan Reid
b3bfbde1db Use minijail_fork
Using minijail_fork removes the need to manage user and pid namespace
explicitly in crosvm and removes some parent/child synchonization
requirements too.

Change-Id: I47f9d39527d0a3ccf625600e9bfc2cccc3cb27ca
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/719443
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-10-25 05:52:43 -07:00
Dylan Reid
d37aa9fab5 Add ability to minijail_fork
Change-Id: I0c774816067449cbb838dcf29c6fa947ae5916e1
Reviewed-on: https://chromium-review.googlesource.com/719442
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-25 05:52:42 -07:00
Mike Frysinger
77ec85ea3b README: use /run paths
Since /var/run is a symlink to /run, and we want to avoid going
through the stateful /var whenever possible, use the direct path.

BUG=chromium:699880
TEST=precq passes

Change-Id: I5d95f5358c1fb0cb2ca73f9c4b145d8e36b4a361
Reviewed-on: https://chromium-review.googlesource.com/734225
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-23 18:22:24 -07:00
Dylan Reid
70a8290514 Fix new warning with rust 1.21
Mutable references being declared mutable themselves is unnecessary and
now generates a warning.

Change-Id: I29c7652fb86e17a8eda21efc728dd09b726c304f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/717733
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-13 14:45:07 -07:00
Dylan Reid
d169a8d9ed Move crosvm/hw to a new devices module
Moving the devices to their own module makes it easier to add tests that
use them.

Change-Id: I61bfef4037d16b20145b5fddce604835cdc4f67b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/706559
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-09 17:39:05 -07:00
Dylan Reid
94bf1bf6b4 Move vm_control to a top-level crate
Break out vm_control to a crate that will be able to used by more
modules. Having vm_control usable from outside crosvm makes it possible
to move the devices out of crosvm in a later commit.

Change-Id: I1f060700ed49b5d77519d55efa2430490d521256
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/706558
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-09 17:39:04 -07:00
Dylan Reid
d0c9adc642 main: Default to sandboxed devices
Change the default option to use a sanboxxed process for each device.
The old behavior can be re-enabled with the `--disable-sandbox` flag.

Change-Id: I65762a6cb52afac210fc0e683d999f20fe67a57e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/696715
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-03 17:28:26 -07:00
Dylan Reid
e026ef0918 main: use - instead of _ for seccomp policy argument
The other options all user hyphens.

Change-Id: I7f0ab307fd5e50deea8c276bc7a73e43cf692195
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/696714
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-10-03 17:28:26 -07:00
Chirantan Ekbote
6eb67123f9 Load seccomp files from standard location
All seccomp policy files get installed in /usr/share/policy on chrome
os.  Load the virtio device seccomp policy files from there as well.

BUG=none
TEST=run crosvm under strace -e trace=open and verify that it is loading
     the policy files from /usr/share/policy

Change-Id: I87fa3c57babfd256fb1ac1a827337a95e9c003ad
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/630059
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-02 17:27:21 -07:00
Zach Reizner
bb493dd02b convert println logs to logging macros
TEST=build_test
BUG=None

Change-Id: Ia184e994e996eef427e1b50ce019403f4521f008
Reviewed-on: https://chromium-review.googlesource.com/693138
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-29 23:25:36 -07:00
Zach Reizner
26e1aef84f add usage information to README
TEST=None
BUG=None

Change-Id: Iab070c5788e19e63140643115af6e48421989f9b
Reviewed-on: https://chromium-review.googlesource.com/683798
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-09-27 12:57:59 -07:00
Zach Reizner
5e4ab46105 build_test: use command line arguments instead of enviroment variables
This change also includes bikeshed style fixes and adds doc strings.

TEST=build_test
BUG=None

Change-Id: I2fec9a3f4488ccf3629e70e5c507695c49389e0d
Reviewed-on: https://chromium-review.googlesource.com/679574
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-22 22:25:38 -07:00
Zach Reizner
ab839e293d fix dependency versions and add Cargo.lock
To ensure dependencies don't accidentally get updated, their versions are
fixed using the equals constraint. The Cargo.lock file is also checked in
so that the registry won't need to be downloaded by cargo.

These changes are needed so that the crosvm ebuild will not need to
download anything outside of its list of source packages.

TEST=./build_test
BUG=None

Change-Id: Iae8472de77e3589a453685717b26fb1ceb44e257
Reviewed-on: https://chromium-review.googlesource.com/674092
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-09-20 03:39:24 -07:00
Chirantan Ekbote
42b3e8da55 net_util: Remove unused import
The compiler was complaining about std::fmt::Debug being an unused
import.  Remove the import.

BUG=none
TEST=build_test and see no warnings about unused imports

Change-Id: I5e606982dffee575b3048b6c45cb5222e63ae3dc
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/669305
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-09-18 16:48:43 -07:00
Chirantan Ekbote
88f9cba448 Implement virtio-vsock
Implement the virtual sockets device using vhost subsystem of the host
kernel to handle data transfer.

BUG=chromium:708267
TEST=build and run maitred in guest VM without issue

Change-Id: I35b542c0fc7e0fd9296f7ba3e1dfce60bf524d15
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/638838
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-09-18 16:48:43 -07:00
Dylan Reid
270f7b6a16 Improve guest memory error handling
Pass better errors from mmap and guest_memory. These modules were
written before I understood errors. Now the errors passed back to block
can be propagated.

Change-Id: I1842808a4114a715321c555281aacc211f23511c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/656837
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-09-11 22:47:10 -07:00
Jason D. Clinton
6f366b5460 vhost: Fix-up failing tests and add a little more coverage
This fakes out the underlying Net implementation with FakeNet to try
and get some of the code a little further along before it
explodes. Then, we test for known failures when running without a real
vhost file descriptors.

This allows us to pass without running as root as we would expect
running on Paladins.

This is also the final module that was failing at ToT.

Also adds vhost to the build_test test targets.

BUG=none
TEST=Run unit tests:
cargo test -p crosvm -p data_model -p syscall_defines -p kernel_loader -p net_util -p x86_64 -p virtio_sys -p kvm_sys -p vhost -p io_jail -p net_sys -p sys_util -p kvm
Also ran ./build_test

Change-Id: Ie12d05c044634a660a234483532cf783e2a7fe84
Reviewed-on: https://chromium-review.googlesource.com/656278
Commit-Ready: Jason Clinton <jclinton@chromium.org>
Tested-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
2017-09-09 13:48:49 -07:00
Zach Reizner
2bcf05b2af crosvm: add virtio wayland device
This adds the virtio wayland device which is activated by default. The wayland
device needs the XDG_RUNTIME_DIR env variable to be set and a running wayland
compositor to connect to in that directory.

TEST=crosvm run <other args>
BUG=chromium:738638

Change-Id: Iaa417c6bb74739896042318451b4befcac0c1d0e
Reviewed-on: https://chromium-review.googlesource.com/559860
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-09-08 17:35:58 -07:00
Zach Reizner
22175fe368 crosvm: add uid_map/gid_map support to jailed devices
This CL includes a small tweak to sys_util so that cloned processes PIDs
are returned.

The proxy device CHILD_SIGNATURE check was removed because it would
deadlock with the synchronization that DeviceManager's post clone
callback uses to wait for the id maps to be set. The check wasn't that
useful to begin with.

This also bumps the libc version.

TEST=None
BUG=None

Change-Id: I881e08c9626e035044b0be1dd2e9fff3e7e61ec1
Reviewed-on: https://chromium-review.googlesource.com/634270
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-09-08 17:35:58 -07:00
Jason D. Clinton
d7f036281d net_util: Fix-up failing tests and add a little more coverage
We can't really mock out the underlying TAP ioctls unless we introduce
another layer of abstraction. Instead, this CL allows a test to pass
if the reason that it failed was a permission denial as we would
expect running on Paladins as non-root.

Also adds net_util to the build_test test targets.

BUG=none
TEST=Run unit tests:
cargo test -p crosvm -p data_model -p syscall_defines -p kernel_loader -p net_util -p x86_64 -p virtio_sys -p kvm_sys -p vhost -p io_jail -p net_sys -p sys_util -p kvm
Also ran ./build_test

Change-Id: I5c761bd75d3a6d5829f4dd07fb8031612944e912
Reviewed-on: https://chromium-review.googlesource.com/649958
Commit-Ready: Jason Clinton <jclinton@chromium.org>
Tested-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
2017-09-08 15:05:11 -07:00
Zach Reizner
1ea2f8ec34 crosvm: bump libc version to 0.2.29
This is so future changes can use getresuid/setresuid and similar
syscalls.

BUG=chromium:738638
TEST=./build_test

Change-Id: I47765fa1f45c549d8e148d02655dd61993a10f58
Reviewed-on: https://chromium-review.googlesource.com/655143
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-09-07 21:21:25 -07:00