Merge "Don't ignore failure to set a property" into main
diff --git a/libs/avb/Android.bp b/libs/avb/Android.bp
deleted file mode 100644
index a2d9e1a..0000000
--- a/libs/avb/Android.bp
+++ /dev/null
@@ -1,55 +0,0 @@
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-rust_defaults {
- name: "libavb_bindgen.defaults",
- wrapper_src: "bindgen/avb.h",
- crate_name: "avb_bindgen",
- edition: "2021",
- visibility: ["//packages/modules/Virtualization:__subpackages__"],
- source_stem: "bindings",
- bindgen_flags: [
- "--constified-enum-module AvbDescriptorTag",
- "--default-enum-style rust",
- "--allowlist-type=AvbDescriptorTag",
- "--allowlist-function=.*",
- "--allowlist-var=AVB.*",
- "--use-core",
- "--raw-line=#![no_std]",
- "--ctypes-prefix=core::ffi",
- ],
- cflags: ["-DBORINGSSL_NO_CXX"],
-}
-
-rust_bindgen {
- name: "libavb_bindgen",
- defaults: ["libavb_bindgen.defaults"],
- host_supported: true,
- static_libs: [
- "libavb",
- ],
- shared_libs: [
- "libcrypto",
- ],
-}
-
-rust_bindgen {
- name: "libavb_bindgen_nostd",
- defaults: ["libavb_bindgen.defaults"],
- static_libs: [
- "libavb_baremetal",
- "libcrypto_baremetal",
- ],
-}
-
-rust_test {
- name: "libavb_bindgen_test",
- srcs: [":libavb_bindgen"],
- crate_name: "avb_bindgen_test",
- edition: "2021",
- test_suites: ["general-tests"],
- auto_gen_config: true,
- clippy_lints: "none",
- lints: "none",
-}
diff --git a/libs/avb/TEST_MAPPING b/libs/avb/TEST_MAPPING
deleted file mode 100644
index 57de6b3..0000000
--- a/libs/avb/TEST_MAPPING
+++ /dev/null
@@ -1,9 +0,0 @@
-// When adding or removing tests here, don't forget to amend _all_modules list in
-// wireless/android/busytown/ath_config/configs/prod/avf/tests.gcl
-{
- "avf-presubmit" : [
- {
- "name" : "libavb_bindgen_test"
- }
- ]
-}
diff --git a/libs/avb/bindgen/avb.h b/libs/avb/bindgen/avb.h
deleted file mode 100644
index b3d5385..0000000
--- a/libs/avb/bindgen/avb.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#pragma once
-
-#include <libavb/libavb.h>
diff --git a/microdroid_manager/src/main.rs b/microdroid_manager/src/main.rs
index a48d540..5a5b34a 100644
--- a/microdroid_manager/src/main.rs
+++ b/microdroid_manager/src/main.rs
@@ -341,7 +341,9 @@
let mut file = match File::open(path) {
Ok(dp) => dp,
Err(e) => {
- info!("{e:?}. Assumes <0>");
+ info!(
+ "Assumes that debug policy is disabled because failed to read debug policy ({e:?})"
+ );
return Ok(Some(false));
}
};
diff --git a/rialto/Android.bp b/rialto/Android.bp
index 33c24eb..55423ea 100644
--- a/rialto/Android.bp
+++ b/rialto/Android.bp
@@ -16,6 +16,7 @@
"liblibfdt",
"liblog_rust_nostd",
"libservice_vm_comm_nostd",
+ "libtinyvec_nostd",
"libvirtio_drivers",
"libvmbase",
],
diff --git a/rialto/src/communication.rs b/rialto/src/communication.rs
index 858ccfb..ee4ecdb 100644
--- a/rialto/src/communication.rs
+++ b/rialto/src/communication.rs
@@ -17,9 +17,11 @@
use crate::error::Result;
use ciborium_io::{Read, Write};
use core::hint::spin_loop;
+use core::mem;
use core::result;
use log::info;
use service_vm_comm::{Request, Response};
+use tinyvec::ArrayVec;
use virtio_drivers::{
self,
device::socket::{
@@ -29,10 +31,13 @@
Hal,
};
+const WRITE_BUF_CAPACITY: usize = 512;
+
pub struct VsockStream<H: Hal, T: Transport> {
connection_manager: VsockConnectionManager<H, T>,
/// Peer address. The same port is used on rialto and peer for convenience.
peer_addr: VsockAddr,
+ write_buf: ArrayVec<[u8; WRITE_BUF_CAPACITY]>,
}
impl<H: Hal, T: Transport> VsockStream<H, T> {
@@ -43,6 +48,7 @@
let mut vsock_stream = Self {
connection_manager: VsockConnectionManager::new(socket_device_driver),
peer_addr,
+ write_buf: ArrayVec::default(),
};
vsock_stream.connect()?;
Ok(vsock_stream)
@@ -176,12 +182,25 @@
type Error = virtio_drivers::Error;
fn write_all(&mut self, data: &[u8]) -> result::Result<(), Self::Error> {
- self.wait_for_send(data)
+ if data.len() >= self.write_buf.capacity() - self.write_buf.len() {
+ self.flush()?;
+ if data.len() >= self.write_buf.capacity() {
+ self.wait_for_send(data)?;
+ return Ok(());
+ }
+ }
+ self.write_buf.extend_from_slice(data);
+ Ok(())
}
fn flush(&mut self) -> result::Result<(), Self::Error> {
- // TODO(b/293411448): Optimize the data sending by saving the data to write
- // in a local buffer and then flushing only when the buffer is full.
+ if !self.write_buf.is_empty() {
+ // We need to take the memory from self.write_buf to a temporary
+ // buffer to avoid borrowing `*self` as mutable and immutable on
+ // the same time in `self.wait_for_send(&self.write_buf)`.
+ let buffer = mem::take(&mut self.write_buf);
+ self.wait_for_send(&buffer)?;
+ }
Ok(())
}
}
diff --git a/rialto/src/main.rs b/rialto/src/main.rs
index a8338ca..42d39c4 100644
--- a/rialto/src/main.rs
+++ b/rialto/src/main.rs
@@ -26,6 +26,7 @@
use crate::communication::VsockStream;
use crate::error::{Error, Result};
+use ciborium_io::Write;
use core::num::NonZeroUsize;
use core::slice;
use fdtpci::PciInfo;
@@ -141,6 +142,7 @@
let mut vsock_stream = VsockStream::new(socket_device, host_addr())?;
let response = requests::process_request(vsock_stream.read_request()?);
vsock_stream.write_response(&response)?;
+ vsock_stream.flush()?;
vsock_stream.shutdown()?;
Ok(())