Commit graph

12 commits

Author SHA1 Message Date
David Tolnay
59bb712992 edition: Update qcow and qcow_util to 2018 edition
Separated out of CL:1513058 to make it possible to land parts
individually while the affected crate has no other significant CLs
pending. This avoids repeatedly introducing non-textual conflicts with
new code that adds `use` statements.

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: Ief3fb967df340a99b8263ac185207e30e096105a
Reviewed-on: https://chromium-review.googlesource.com/1519704
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-04-08 22:30:36 -07:00
Dylan Reid
3d00b70eb5 Revert "qcow_utils: Add tests"
This test breaks the asan builders

BUG=945423

This reverts commit fbbcf7ad14.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I4db9720118ea6e3002045fad997774ab84d3b59a
Reviewed-on: https://chromium-review.googlesource.com/1540339
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2019-03-28 02:11:02 -07:00
Dylan Reid
fbbcf7ad14 qcow_utils: Add tests
Add basic tests that qcow_utils compiles.

Change-Id: I433dc7cb55d42997ba060f9bd989ca3b5c8b0045
Reviewed-on: https://chromium-review.googlesource.com/895189
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-16 18:05:03 -07:00
Daniel Verkamp
348ccf1102 qcow_utils: add disk image expand function
This exports a new C API to resize a disk image.  The new function is
intended to only expand (increase in size) to avoid accidentally
truncating user data due to bugs elsewhere.

BUG=chromium:858815
TEST=build_test.py

Change-Id: I6f834209aba693618e0f51d920e7b73d4f2a9dfc
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1464384
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-02-14 05:27:21 -08:00
David Tolnay
2bac1e7a9c toolchain: Update to Rust 1.31.0
We updated the production toolchain from 1.30 to 1.31 in CL:1366446.
This CL does the same upgrade for the local developer toolchain and
Kokoro.

The relevant changes are in rust-toolchain and kokoro/Dockerfile.
The rest are from rustfmt.

TEST=cargo fmt --all -- --check
TEST=as described in kokoro/README.md

Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4
Reviewed-on: https://chromium-review.googlesource.com/1374376
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-12-13 19:28:04 -08:00
Zach Reizner
94923406ae qcow_utils: do not close given fds in convert_to_* functions
The `convert_to_*` functions take ownership of the passed FDs even
though they should not according to the function's contract. This change
clones the passed FDs so that the caller can retain ownership of its
FDs.

This change also wraps most of the implementations in catch_unwind so
that panics do not unwind past FFI boundaries, which is undefined
behavior.

BUG=chromium:905799
TEST=in crosh: `vmc export <vm name> <file name>`

Change-Id: I2f65ebff51243675d0854574d8fd02cec1b237a4
Reviewed-on: https://chromium-review.googlesource.com/1338501
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2018-11-16 05:01:42 -08:00
Daniel Verkamp
7f9b9ea344 qcow: add convert API and export it in qcow_utils
This will be used in vm_concierge's ExportDiskImage function in order to
allow a minimal qcow2 image to be written on the fly (containing only
the required clusters in a tightly-packed image file). It also allows
future flexibility to change the underlying disk image file format while
still exporting qcow2 images (e.g. via `vmc export`).

For testing, add a qcow_img `convert` command, which can convert
between raw and qcow2 as both source and destination.

BUG=None
TEST=Use qcow_img to convert a raw image to qcow2 and back and verify
     its contents are the same as the original.

Change-Id: I74167aca9a9c857d892e24adf5ee17afc0f6e6b5
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1272060
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-10-18 19:01:06 -07:00
Dylan Reid
cd9f86b299 qcow: Add a utility program for qcow analysis
This program makes figuring out the state of a qcow file easier.

Change-Id: If297eb0cd835a86d8f284d3aef3d7e962e095726
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1207455
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2018-09-19 15:40:06 -07:00
Dylan Reid
2dcb632405 qcow: Set refcounts for initial clusters.
All qcow clusters need to have their refcounts set. Add a `new` method
to `Qcowfile` and use it instead of just headers from the library.

The new method will loop over the initial clusters and initialize their
refcounts.

Add a `create_qcow2` option to the main executable so there is a way to
test image creation that doesn't require DBUS and Concierge.

BUG=none
TEST='crosvm create_qcow2 /tmp/file.qcow2 1000000'
'qemu-img check /tmp/file.qcow2'
no errors reported.

Change-Id: I8798df5942fb23f79cc7ca86820d0783d1f2b608
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1136900
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-07-16 03:42:07 -07:00
Zach Reizner
d1ab493672 fix some clippy errors that are default deny
Clippy only has 6 lints that are defaulted to deny, which this CL fixes.
The first step to running clippy and establishing our own set of default
deny lints, is to ensure we aren't running afoul of the most common
deny lints.

BUG=None
TEST=cargo clippy --all

Change-Id: I225801357d76a8a9e246e3842bc9bf550fcd7207
Reviewed-on: https://chromium-review.googlesource.com/952045
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>
2018-03-07 19:47:11 -08:00
Stephen Barber
19e57b9532 qcow_utils: add pkgconfig script
Add a pkgconfig file and script to fix it up at build time.

Also fix extern "C" for the qcow_utils header.

BUG=chromium:806119
TEST=emerge-eve-kvm crosvm

Change-Id: Ib69d9e88b42d2f2c8661798c37537a4236e0506e
Reviewed-on: https://chromium-review.googlesource.com/891572
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-02-01 21:29:32 -08:00
Dylan Reid
6ecbbfd723 Add qcow_utils for exposing qcow functions as a C library
This C library will be use by the VM launcher to create the qcow2 files
used for persistent VM data.

CQ-DEPEND=CL:884263
BUG=none
TEST=cargo test --all -- --test-threads=1

Change-Id: Ibd7f71d2e3f1f72f781978f014865d2161f033f5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/875116
2018-02-01 21:29:31 -08:00