[service-vm] Print log from the service VM
Test: atest rialto_test
Test Run the ServiceVmClientApp in VM
Bug: 299411175
Change-Id: I1efbd3f1089e3a5931160f992d548ac32da7c42a
diff --git a/rialto/Android.bp b/rialto/Android.bp
index 0b26ccc..860e656 100644
--- a/rialto/Android.bp
+++ b/rialto/Android.bp
@@ -105,7 +105,6 @@
"libanyhow",
"liblibc",
"liblog_rust",
- "libnix",
"libservice_vm_comm",
"libservice_vm_manager",
"libvmclient",
diff --git a/rialto/tests/test.rs b/rialto/tests/test.rs
index 07cfd54..da1a063 100644
--- a/rialto/tests/test.rs
+++ b/rialto/tests/test.rs
@@ -16,8 +16,7 @@
use android_system_virtualizationservice::{
aidl::android::system::virtualizationservice::{
- CpuTopology::CpuTopology, DiskImage::DiskImage, Partition::Partition,
- VirtualMachineConfig::VirtualMachineConfig,
+ DiskImage::DiskImage, Partition::Partition, VirtualMachineConfig::VirtualMachineConfig,
VirtualMachineRawConfig::VirtualMachineRawConfig,
},
binder::{ParcelFileDescriptor, ProcessState},
@@ -27,11 +26,8 @@
use service_vm_comm::{Request, Response, VmType};
use service_vm_manager::ServiceVm;
use std::fs::File;
-use std::io::{self, BufRead, BufReader};
-use std::os::unix::io::FromRawFd;
use std::panic;
use std::path::PathBuf;
-use std::thread;
use vmclient::VmInstance;
const SIGNED_RIALTO_PATH: &str = "/data/local/tmp/rialto_test/arm64/rialto.bin";
@@ -94,8 +90,8 @@
let service = virtmgr.connect().context("Failed to connect to VirtualizationService")?;
let rialto = File::open(rialto_path(vm_type)).context("Failed to open Rialto kernel binary")?;
- let console = android_log_fd()?;
- let log = android_log_fd()?;
+ let console = service_vm_manager::android_log_fd()?;
+ let log = service_vm_manager::android_log_fd()?;
let disks = match vm_type {
VmType::ProtectedVm => {
@@ -114,16 +110,11 @@
};
let config = VirtualMachineConfig::RawConfig(VirtualMachineRawConfig {
name: String::from("RialtoTest"),
- kernel: None,
- initrd: None,
- params: None,
bootloader: Some(ParcelFileDescriptor::new(rialto)),
disks,
protectedVm: vm_type.is_protected(),
memoryMib: 300,
- cpuTopology: CpuTopology::ONE_CPU,
platformVersion: "~1.0".to_string(),
- gdbPort: 0, // No gdb
..Default::default()
});
VmInstance::create(
@@ -136,19 +127,3 @@
)
.context("Failed to create VM")
}
-
-fn android_log_fd() -> io::Result<File> {
- let (reader_fd, writer_fd) = nix::unistd::pipe()?;
-
- // SAFETY: These are new FDs with no previous owner.
- let reader = unsafe { File::from_raw_fd(reader_fd) };
- // SAFETY: These are new FDs with no previous owner.
- let writer = unsafe { File::from_raw_fd(writer_fd) };
-
- thread::spawn(|| {
- for line in BufReader::new(reader).lines() {
- info!("{}", line.unwrap());
- }
- });
- Ok(writer)
-}