summary refs log tree commit diff
path: root/protos
diff options
context:
space:
mode:
authorCody Schuffelen <schuffelen@google.com>2019-07-08 16:14:24 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-03 00:59:14 +0000
commitf9b035d50c431c2a544ad1cb91ca5121165ae7aa (patch)
treec1b4a9127d8d24502cff87210ccff82bbcb0f2ec /protos
parentb5237bbcf074eb30cf368a138c0835081e747d71 (diff)
downloadcrosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar.gz
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar.bz2
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar.lz
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar.xz
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.tar.zst
crosvm-f9b035d50c431c2a544ad1cb91ca5121165ae7aa.zip
Support composite disks.
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>
Diffstat (limited to 'protos')
-rw-r--r--protos/Cargo.toml1
-rw-r--r--protos/build.rs2
-rw-r--r--protos/src/cdisk_spec.proto18
-rw-r--r--protos/src/lib.rs3
4 files changed, 24 insertions, 0 deletions
diff --git a/protos/Cargo.toml b/protos/Cargo.toml
index 9fd0e5a..98cd4ae 100644
--- a/protos/Cargo.toml
+++ b/protos/Cargo.toml
@@ -6,6 +6,7 @@ edition = "2018"
 
 [features]
 plugin = ["kvm_sys"]
+composite-disk = []
 trunks = []
 
 [dependencies]
diff --git a/protos/build.rs b/protos/build.rs
index b510e54..2e870b4 100644
--- a/protos/build.rs
+++ b/protos/build.rs
@@ -48,6 +48,8 @@ struct LocalProto {
 static LOCAL_PROTOS: &[LocalProto] = &[
     #[cfg(feature = "plugin")]
     LocalProto { module: "plugin" },
+    #[cfg(feature = "composite-disk")]
+    LocalProto { module: "cdisk_spec" },
 ];
 
 fn main() -> Result<()> {
diff --git a/protos/src/cdisk_spec.proto b/protos/src/cdisk_spec.proto
new file mode 100644
index 0000000..771c7ce
--- /dev/null
+++ b/protos/src/cdisk_spec.proto
@@ -0,0 +1,18 @@
+syntax = "proto3";
+
+enum ReadWriteCapability {
+  READ_ONLY = 0;
+  READ_WRITE = 1;
+}
+
+message ComponentDisk {
+  string file_path = 1;
+  uint64 offset = 2;
+  ReadWriteCapability read_write_capability = 3;
+}
+
+message CompositeDisk {
+  uint64 version = 1;
+  repeated ComponentDisk component_disks = 2;
+  uint64 length = 3;
+};
diff --git a/protos/src/lib.rs b/protos/src/lib.rs
index 3fdbdc0..d73fb03 100644
--- a/protos/src/lib.rs
+++ b/protos/src/lib.rs
@@ -11,3 +11,6 @@ pub mod plugin;
 
 #[cfg(feature = "trunks")]
 pub use generated::trunks;
+
+#[cfg(feature = "composite-disk")]
+pub use generated::cdisk_spec;