Commit graph

162 commits

Author SHA1 Message Date
Zach Reizner
8266b87e0e src_util: add terminal module
The terminal module is for configuring pseudo-terminals in raw mode.

TEST=None
BUG=None

Change-Id: Ic724309e0a0f338fb3b35974643c5ab281eb525e
Reviewed-on: https://chromium-review.googlesource.com/514414
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
a053a28685 src_util: add poll module
The poll module adds the Poller object for waiting on mutliple file
descriptors at once. The Pollable trait is introduced so rust objects
can expose a file descriptor useful for polling. An impl for EventFd is
included with this change for testing.

TEST=cargo test
BUG=None

Change-Id: I94fd15a17fe0527c0d29c623badb90668d708689
Reviewed-on: https://chromium-review.googlesource.com/514413
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
79b2a73272 sys_util: move handle_eintr!() to sys_util so it can be reused
This CL takes the handle_intr!() macro, changes its name to
handle_eintr!(), and overloads it so it can handle EINTR embedded in
other kinds of Result types.

BUG=None
TEST=cargo test

Change-Id: I920ea7d9f156137f42e9e8ea44a3e6946d06b746
Reviewed-on: https://chromium-review.googlesource.com/556348
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
b3fba4535c sys_util: implement VolatileMemory for Mmap and GuestMemory
Mmap and GuestMemory are the intended targets for the VolatileMemory
trait.

TEST=cargo test
BUG=None

Change-Id: Ie228b5daef691a6dcb80841be1c3dddb4b19ffc4
Reviewed-on: https://chromium-review.googlesource.com/547335
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 10:55:46 -07:00
Zach Reizner
0d4f8dff72 crosvm: add virtio block device
This device is useful for exposing a block device, for example a rootfs
image, to the guest.

TEST=None
BUG=None

Change-Id: Ida0d24ed57602f25352563893a1c85b171771c7a
Reviewed-on: https://chromium-review.googlesource.com/514688
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-27 06:39:56 -07:00
Dylan Reid
0584fe9fb2 Limit types that can be read from guest memory
Not all types are safe to read from guest memory.  Any type with a
reference or pointer will be initialized to random bits that don't refer
to a valid address.  This can cause dangling pointer and general
unsafe behavior.

To fix this, limit types that can be read with read_obj to those that
implement the unsafe trait `DataInit`.  Provide implementations of
`DataInit` for intrinsic types that are obviously safe to initialize
with random data.

Implement the needed traits for bootparam types as they are read from
the kernel image directly.

Change-Id: I1040f5bc1b2fc4c58c87d8a2ce3f618edcf6f9b1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/540750
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 00:20:33 -07:00
Dylan Reid
71501e0937 sys_util: Add TempDir class
This will be used to create temporary directories that are lifetime
managed for running jails.

Change-Id: I35dfeae76a211c820db090b65baf72277d9e2d8a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520706
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-09 21:44:04 -07:00
Dylan Reid
d4eaa4056f sys_util: Add guest_memory
Add a module for accessing guest memory.
This module will replace all the slices that are used to access it
currently as those slices aren't valid because the memory is volatile
and a volatile slice doesn't exist in rust.

Modify the existing users so they no longer depend on the deprecated slice
access.

Change-Id: Ic0e86dacf66f68bd88ed9cc197cb14e45ada891d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/509919
2017-05-25 22:51:14 -07:00
Zach Reizner
37285dc09d sys_util: Add conversion from errno io::Error.
Change-Id: Ia49aa8eac1dedbc4e3f6277120bf332404e8b818
Reviewed-on: https://chromium-review.googlesource.com/509918
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-25 17:16:02 -07:00
Dylan Reid
5d084600e9 sys_util: Add struct utils
These utilities are used for reading structs from u8 slices.
Often the kernel returns pointers to void pointers that represent a struct.
This helps convert back to the struct.

Change-Id: I6e59fb772f3ba75f006c9370412267ff565dfe4c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/497768
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-10 20:58:06 -07:00
Zach Reizner
48faad1bc6 sys_util: add eventfd module
In KVM, eventfd's are essential for sending and receiving signals to the
VM. This CL adds a safe wrapper around their usage.

TEST=cargo test
BUG=None

Change-Id: I04cd9036db156bfa8b9bd49281347a2460fbff2c
Reviewed-on: https://chromium-review.googlesource.com/496988
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:51 -07:00
Zach Reizner
00f90a4bba sys_util: add sys_util crate for misc system modules
This initial commit includes an mmap wrapper.

TEST=cargo test
BUG=None

Change-Id: I9625bd446fcd4801b2e16188897e84714b4e4ce0
Reviewed-on: https://chromium-review.googlesource.com/496987
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:50 -07:00