Merge "Erase data before initializeWritablePartition"
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 74a9365..5d64684 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -256,7 +256,13 @@
)
})?;
let image = clone_file(image_fd)?;
-
+ // initialize the file. Any data in the file will be erased.
+ image.set_len(0).map_err(|e| {
+ new_binder_exception(
+ ExceptionCode::SERVICE_SPECIFIC,
+ format!("Failed to reset a file: {}", e),
+ )
+ })?;
let mut part = QcowFile::new(image, size).map_err(|e| {
new_binder_exception(
ExceptionCode::SERVICE_SPECIFIC,