Format instance.img
When instance.img is created by VS, it's header is formatted to have the
magic number and the version field correctly set.
Bug: 193504400
Test: od -t x /dev/block/by-name/vm-instance shows the magic number and
the version number.
Change-Id: Ie2a04c648a2d8d239aa305660e4408fb0ffc2c33
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 09f11d5..fe47d2c 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -19,6 +19,7 @@
mod sync;
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::IVirtualizationService::IVirtualizationService;
+use android_system_virtualizationservice::aidl::android::system::virtualizationservice::PartitionType::PartitionType;
use android_system_virtualizationservice::binder::{wait_for_interface, ProcessState, Strong};
use anyhow::{Context, Error};
use create_partition::command_create_partition;
@@ -91,9 +92,21 @@
/// The desired size of the partition, in bytes.
size: u64,
+
+ /// Type of the partition
+ #[structopt(short="t", long="type", default_value="raw", parse(try_from_str=parse_partition_type))]
+ partition_type: PartitionType,
},
}
+fn parse_partition_type(s: &str) -> Result<PartitionType, String> {
+ match s {
+ "raw" => Ok(PartitionType::RAW),
+ "instance" => Ok(PartitionType::ANDROID_VM_INSTANCE),
+ _ => Err(format!("Invalid partition type {}", s)),
+ }
+}
+
fn main() -> Result<(), Error> {
env_logger::init();
let opt = Opt::from_args();
@@ -122,7 +135,9 @@
}
Opt::Stop { cid } => command_stop(service, cid),
Opt::List => command_list(service),
- Opt::CreatePartition { path, size } => command_create_partition(service, &path, size),
+ Opt::CreatePartition { path, size, partition_type } => {
+ command_create_partition(service, &path, size, partition_type)
+ }
}
}