Merge "Trim more *_contexts files"
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 13c68d7..69d4568 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,8 +1,13 @@
{
- "postsubmit": [
+ "presubmit": [
{
"name": "MicrodroidHostTestCases"
- },
+ }
+ ],
+ "postsubmit": [
+ // TODO(jiyong): promote this to presubmit. That currently doesn't work because
+ // this test is skipped for cf_x86_64_phone (not aosp_cf_x86_64_phone), but tradefed
+ // somehow thinks that the test wasn't executed at all and reports it as a failure.
{
"name": "VirtualizationTestCases"
}
diff --git a/apkdmverity/TEST_MAPPING b/apkdmverity/TEST_MAPPING
index 997b3f9..1bbec76 100644
--- a/apkdmverity/TEST_MAPPING
+++ b/apkdmverity/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "postsubmit" : [
+ "presubmit" : [
{
"name" : "apkdmverity.test"
}
diff --git a/authfs/TEST_MAPPING b/authfs/TEST_MAPPING
index cabd5df..d0c0b09 100644
--- a/authfs/TEST_MAPPING
+++ b/authfs/TEST_MAPPING
@@ -3,10 +3,5 @@
{
"name": "authfs_device_test_src_lib"
}
- ],
- "postsubmit": [
- {
- "name": "MicrodroidHostTestCases"
- }
]
}
diff --git a/compositediskconfig/src/lib.rs b/compositediskconfig/src/lib.rs
index 3546dd3..dc199e4 100644
--- a/compositediskconfig/src/lib.rs
+++ b/compositediskconfig/src/lib.rs
@@ -15,7 +15,6 @@
//! JSON configuration for composite disks, as used for running `mk_cdisk` and by the `vm` tool.
use serde::{Deserialize, Serialize};
-use std::io::Write;
use std::path::PathBuf;
/// Configuration for running `mk_cdisk`.
@@ -36,10 +35,3 @@
#[serde(default)]
pub writable: bool,
}
-
-impl Config {
- /// Write the configuration as JSON, in the format used by `mk_cdisk`.
- pub fn write_json(&self, writer: impl Write) -> serde_json::Result<()> {
- serde_json::to_writer(writer, self)
- }
-}
diff --git a/microdroid/payload/metadata/Android.bp b/microdroid/payload/metadata/Android.bp
new file mode 100644
index 0000000..4b23394
--- /dev/null
+++ b/microdroid/payload/metadata/Android.bp
@@ -0,0 +1,16 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_library {
+ name: "libmicrodroid_metadata",
+ host_supported: true,
+ crate_name: "microdroid_metadata",
+ srcs: ["src/lib.rs"],
+ prefer_rlib: true,
+ edition: "2018",
+ rustlibs: [
+ "libmicrodroid_metadata_proto_rust",
+ "libprotobuf",
+ ],
+}
diff --git a/microdroid/payload/metadata/src/lib.rs b/microdroid/payload/metadata/src/lib.rs
new file mode 100644
index 0000000..9c97411
--- /dev/null
+++ b/microdroid/payload/metadata/src/lib.rs
@@ -0,0 +1,42 @@
+// Copyright 2021, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Read/write metadata blob for VM payload image. The blob is supposed to be used as a metadata
+//! partition in the VM payload image.
+//! The layout of metadata blob is like:
+//! 4 bytes : size(N) in big endian
+//! N bytes : protobuf message for Metadata
+
+use protobuf::Message;
+use std::io;
+use std::io::Read;
+use std::io::Write;
+
+pub use microdroid_metadata::metadata::{ApexPayload, ApkPayload, Metadata};
+
+/// Reads a metadata from a reader
+pub fn read_metadata<T: Read>(mut r: T) -> io::Result<Metadata> {
+ let mut buf = [0u8; 4];
+ r.read_exact(&mut buf)?;
+ let size = i32::from_be_bytes(buf);
+ Ok(Metadata::parse_from_reader(&mut r.take(size as u64))?)
+}
+
+/// Writes a metadata to a writer
+pub fn write_metadata<T: Write>(metadata: &Metadata, mut w: T) -> io::Result<()> {
+ let mut buf = Vec::new();
+ metadata.write_to_writer(&mut buf)?;
+ w.write_all(&(buf.len() as i32).to_be_bytes())?;
+ w.write_all(&buf)
+}
diff --git a/microdroid_manager/Android.bp b/microdroid_manager/Android.bp
index 5cf94a1..267147f 100644
--- a/microdroid_manager/Android.bp
+++ b/microdroid_manager/Android.bp
@@ -13,7 +13,7 @@
"libkernlog",
"libkeystore2_system_property-rust",
"liblog_rust",
- "libmicrodroid_metadata_proto_rust",
+ "libmicrodroid_metadata",
"libmicrodroid_payload_config",
"libprotobuf",
"libserde",
diff --git a/microdroid_manager/src/metadata.rs b/microdroid_manager/src/metadata.rs
index 4f7d7af..81d9cc4 100644
--- a/microdroid_manager/src/metadata.rs
+++ b/microdroid_manager/src/metadata.rs
@@ -15,25 +15,14 @@
//! Payload metadata from /dev/block/by-name/metadata
use log::info;
-use microdroid_metadata::metadata::Metadata;
-use protobuf::Message;
+use microdroid_metadata::{read_metadata, Metadata};
use std::fs::File;
use std::io;
-use std::io::Read;
const METADATA_PATH: &str = "/dev/block/by-name/metadata";
/// loads payload metadata from /dev/block/by-name/metadata
pub fn load() -> io::Result<Metadata> {
info!("loading payload metadata...");
-
- let mut f = File::open(METADATA_PATH)?;
- // metadata partition is
- // 4 bytes : size(N) in big endian
- // N bytes : message for Metadata
- let mut buf = [0u8; 4];
- f.read_exact(&mut buf)?;
- let size = i32::from_be_bytes(buf);
-
- Ok(Metadata::parse_from_reader(&mut f.take(size as u64))?)
+ read_metadata(File::open(METADATA_PATH)?)
}
diff --git a/tests/vsock_test.cc b/tests/vsock_test.cc
index 233c6dd..931e79d 100644
--- a/tests/vsock_test.cc
+++ b/tests/vsock_test.cc
@@ -86,7 +86,7 @@
VirtualMachineConfig config;
config.kernel = ParcelFileDescriptor(unique_fd(open(kVmKernelPath, O_RDONLY | O_CLOEXEC)));
config.initrd = ParcelFileDescriptor(unique_fd(open(kVmInitrdPath, O_RDONLY | O_CLOEXEC)));
- config.params = String16(kVmParams);
+ config.params = kVmParams;
config.protected_vm = protected_vm;
sp<IVirtualMachine> vm;
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/Partition.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/Partition.aidl
index 782c239..825c3da 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/Partition.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/Partition.aidl
@@ -18,7 +18,7 @@
/** A partition to be assembled into a composite image. */
parcelable Partition {
/** A label for the partition. */
- String label;
+ @utf8InCpp String label;
/** The backing file descriptor of the partition image. */
ParcelFileDescriptor image;
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineConfig.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineConfig.aidl
index cb28856..5d59f9d 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineConfig.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineConfig.aidl
@@ -29,7 +29,7 @@
* Parameters to pass to the kernel. As far as the VMM and boot protocol are concerned this is
* just a string, but typically it will contain multiple parameters separated by spaces.
*/
- @nullable String params;
+ @nullable @utf8InCpp String params;
/**
* The bootloader to use. If this is supplied then the kernel and initrd must not be supplied;
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineDebugInfo.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineDebugInfo.aidl
index 18b01ce..d081b8d 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineDebugInfo.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineDebugInfo.aidl
@@ -21,13 +21,13 @@
int cid;
/** Directory of temporary files used by the VM while it is running. */
- String temporaryDirectory;
+ @utf8InCpp String temporaryDirectory;
/** The UID of the process which requested the VM. */
int requesterUid;
/** The SID of the process which requested the VM. */
- String requesterSid;
+ @utf8InCpp String requesterSid;
/**
* The PID of the process which requested the VM. Note that this process may no longer exist and
diff --git a/zipfuse/TEST_MAPPING b/zipfuse/TEST_MAPPING
index 5b313c1..81a8aeb 100644
--- a/zipfuse/TEST_MAPPING
+++ b/zipfuse/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "postsubmit" : [
+ "presubmit" : [
{
"name" : "ZipFuseTest"
}