summary refs log tree commit diff
path: root/disk
Commit message (Collapse)AuthorAge
* Fix VolatileSlice calls in all modulesDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | The VolatileSlice API changed, but some callers were not updated to match. Fix them up so that builds with additional features enabled (e.g. kokoro) pass again. BUG=None TEST=cargo test -p disk --features=composite-disk TEST=docker/wrapped_smoke_test.sh Change-Id: I97b3cd04549af30b7dc1515245f025d9439669bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216399 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* Make VolatileSlice ABI-compatible with iovecChirantan Ekbote2020-05-25
| | | | | | | | | | | | | | | | | | | | | | Change VolatileSlice so that it is ABI-compatible with iovec. This allows us to directly pass in a VolatileSlice for a C function that expects an iovec without having to create temporaries that convert from one to the other. Also change all the parameters from u64 to usize. It's not possible to address more memory than fits into a usize so having u64 here didn't really provide much benefit and led to a lot of tedious casting back and forth all over the place. BUG=none TEST=unit tests Cq-Depend: chromium:2206621 Change-Id: I258f9123c603d9a4c6c5e2d4d10eb4aedf74466d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203998 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* Remove redundant single-component importsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | Fix clippy 1.43.0 clippy::single-component-path-imports warnings. BUG=None TEST=bin/clippy Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* disk: resolve iter_nth_zero clippy warningDaniel Verkamp2020-04-18
| | | | | | | | | | | | | | | Replace .nth(0) with .next() to resolve this: error: called `.nth(0)` on a `std::iter::Iterator` BUG=None TEST=bin/clippy Change-Id: I103e8b44b1564708d92d096aaf044db7f67d1ba8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151147 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
* Fix performance problem on Android Sparse imagesA. Cody Schuffelen2020-04-07
| | | | | | | | | | | | | This was adding ~11 minutes to the boot time with sparse images. BUG=b:151981838 TEST=launch cuttlefish with sparse images. Change-Id: I707258566aee338f742a3a5fe94d0bad8302c447 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2111117 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Better errors on missing composite disk components.A. Cody Schuffelen2020-02-26
| | | | | | | | | | | | | | | | | When there is an error opening one of the composite disk components now, it gives the message `failed to open component file: "No such file or directory (os error 2)"` without specifying the file path it tried to use. Exposing the file path will make it faster to act on errors, rather than trying to examine the composite disk file for paths. TEST=n/a BUG=b:150150052 Change-Id: I9341b330e7e6dcd517d5bfb5262b1657a2da46fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2072738 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Support the Android Sparse disk formatA. Cody Schuffelen2020-02-25
| | | | | | | | | | | | | | | | | | | | | Android defines its own "sparse disk" format, which its images are usually published in. Cuttlefish has special-cased this to build raw images in the android build system, but it still causes a performance hit when downloading and extracting the image zip files. Experimentally, running bsdtar on the zip file of raw images is about 50 seconds slower than bsdtar on the equivalent zip file of android sparse images. These disks can only be opened as read-only, as the Android Sparse format is designed around writing once then interpreting the contents while flashing a physical device through e.g. fastboot. TEST=Run with aosp/1184800 on cuttlefish, unit tests BUG=b:145841395 Change-Id: I13337b042e92841bd3cba88dc8b231fde88c091e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1956487 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Initialize qcow clusters off the backing file when presentA. Cody Schuffelen2020-02-25
| | | | | | | | | | | | | | | This preserves any data that the backing file had on a cluster when doing a write to a subset of that cluster. These writes cause a performance penalty on creating new clusters if a backing file is present. TEST=unit tests BUG=b:140069322 Change-Id: I724990225617c05e5f2dea39e39ce84c940328fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982832 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Read from the backing file if present on read missA. Cody Schuffelen2020-02-21
| | | | | | | | | | | | | | Reads to qcow files with backing files will fall through to the backing file if there is no allocated cluster. As of this change, a write will still trash the cluster and hide any data already present. TEST=unit tests BUG=b:140069322 Change-Id: Iba353fa1e7c25bb6267eb96b30b8f5a6ac61d423 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982831 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Support generating and opening backing filesA. Cody Schuffelen2020-02-21
| | | | | | | | | | | | | | | | | | | | | | The new functionality can be invoked through "crosvm create_qcow2 --backing_file=backing new_file". The old behavior of creating a qcow image with a particular size is still available with its original syntax. This is relevant to implement as by default something like qemu-img will create a new image that assumes the backing file is raw or qcow, while crosvm can use its knowledge of other formats (such as composite disk, and later android sparse) to determine the true size of the backing file. TEST=unit tests BUG=b:140069322 Change-Id: I22de6a79c6d8566a9fcb0bc8124e2d74fea9ca55 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982833 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* sys_util: add FileAllocate traitDaniel Verkamp2020-01-24
| | | | | | | | | | | | | | | This trait provides a generic interface for allocating space on the filesystem within a given file. It is equivalent to the fallocate(2) system call with the default mode (mode = 0). BUG=chromium:858815 TEST=cargo build --features=composite-disk Change-Id: I2f4e8aceb4878790e8dec2e3d539071915efd205 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2015828 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* Use DiskFile in read_cbA. Cody Schuffelen2020-01-22
| | | | | | | | | | | | | This will allow passing in other data sources for the qcow read methods, without adding extra copies. TEST=Unit tests BUG=b:140069322 Change-Id: I2815fa6e416b554968b97959e4b6cd4c93a722f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982829 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Make DiskFile, CompositeDisk DebugA. Cody Schuffelen2020-01-22
| | | | | | | | | | | | Making DiskFile Debug allows placing it inside the QcowFile. TEST=Compiles BUG=b:140069322 Change-Id: Idf20b7909146b0c2a60d864da386e362e8be97a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982828 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* disk: use seek to determine file lengthDaniel Verkamp2020-01-13
| | | | | | | | | | | | | | | | Add a new disk-specific DiskGetLen trait which uses io::Seek instead of File::metadata() to determine the length so that it works on raw block devices (e.g. /dev/sda) as well as regular files. BUG=b:146811529 TEST=`crosvm run --disk /dev/sda` and verify block device length Change-Id: I6936863490efaa479a3c8745c75c373748c800a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1990855 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* disk: move qcow into disk crateDaniel Verkamp2020-01-06
| | | | | | | | | | | | | | | | | | | Move qcow from being its own crate into a module of the disk crate, similar to the composite disk module. This will allow use of qcow from disk and vice versa without introducing a circular crate dependency. BUG=None TEST=./build_test.py TEST=USE='asan fuzzer' emerge-nami crosvm Change-Id: I77512bbe4b94faff1b5460f9796ee56505135580 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1972477 Reviewed-by: Cody Schuffelen <schuffelen@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* disk: add get_len() to eliminate need for SeekDaniel Verkamp2019-11-27
| | | | | | | | | | | | | | | This new trait allows DiskFile implementors to provide the length of the file directly rather than using SeekFrom::End with seek(). BUG=None TEST=./build_test TEST=Boot Termina in crosvm Change-Id: I9447ebb43dbd5fbb32a3a6b6d2fc969b9406cdbc Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913961 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* disk: switch from WriteZeroes to WriteZeroesAtDaniel Verkamp2019-11-27
| | | | | | | | | | | | | | | | This eliminates an extra seek per guest write zeroes request. Additionally, it allows us to stop depending on the file cursor and pass the offset directly, making multi-queue implementation easier. BUG=chromium:858815 TEST=Boot Termina in crosvm Change-Id: I8b15a39752a1b68597a2b1e1fd72382a484a3cb2 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913521 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* disk: fix composite unit test buildDaniel Verkamp2019-11-25
| | | | | | | | | | | | | | | | This was unintentionally broken when changing ReadWriteVolatile to ReadWriteVolatileAt (the composite unit tests aren't built or run by default since they are behind a feature flag). BUG=None TEST=cargo test --features=composite-disk -p disk Change-Id: I864d7063bd27a401c3d878fcd22b52e2357fde8d Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913960 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Cody Schuffelen <schuffelen@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* disk: replace into_iter() with equivalent iter()Daniel Verkamp2019-11-08
| | | | | | | | | | | | | | | | Fixes clippy warning: warning: this .into_iter() call is equivalent to .iter() and will not move the slice BUG=None TEST=bin/clippy Change-Id: I5361495f02609dd5e5313b7bc792e663841212ad Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1896091 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: virtio: block: use FileReadWriteAtVolatileDaniel Verkamp2019-10-29
| | | | | | | | | | | | | | | | | | | Use the "at" variants of the read/write functions in the block device. This reduces the number of syscalls on the host per I/O to one (pread64/pwrite64) rather than two (lseek + read/write). The CompositeDiskFile implementation is also updated in this commit, since it's both a producer and consumer of DiskFile, and it isn't trivial to update it in a separate commit without breaking compilation. BUG=None TEST=Start Crostini on kevin, banon, and nami Change-Id: I031e7e87cd6c99504db8c56b1725ea51c1e27a53 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1845948 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Support composite disks.Cody Schuffelen2019-10-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new disk file type next to raw files and qcow images that represent an indirection to further raw disk files. The disk file itself is a proto file with references to file paths for other disks to open and their virtual offsets and lengths. The intention is to make it easy to assemble a single virtual hard disk out of several distinct partition files. In the particular case of Cuttlefish running Android in a VM, this is relevant as the Android build system distributes partitions as separate raw files. While the simple solution is to pass each partition as a separate raw disk, some functionality (like the bootloader) assumes there is a partition table with multiple distinct partitions on a single disk. Implementing composite disk support in the VMM bridges this gap through supporting the general-purpose case of a disk built out of multiple component files. If desired, this can be extended to support qcow files to support unusual configurations like a mixed qcow/raw disk. Enabled with the "composite-disk" feature. Bug: b/133432409 Change-Id: I2b0c47d92fab13b5dc0ca5a960c7cfd2b7145b87 Signed-off-by: Cody Schuffelen <schuffelen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1667767 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Replace "AsRawFd" with "AsRawFds" for disks.Cody Schuffelen2019-08-30
| | | | | | | | | | | | This supports virtio disks that depend on multiple file descriptors. All of the file descriptors are passed to the jail when relevant. Bug: b/133432409 Change-Id: Idf2e24cd2984c0d12a47a523c13d24c1ba8d173e Signed-off-by: Cody Schuffelen <schuffelen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691761 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Extract disk creation logic out of qcow and src.Cody Schuffelen2019-08-28
Bug: b/133432409 Change-Id: Iba25d5f6bb5f60619bb2f5a3d72ddfd3a81650b4 Signed-off-by: Cody Schuffelen <schuffelen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691460 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>