Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.
This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.
Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt
md files manually updated to fix line lengths.
Renaming `unix` modules to `linux` will be done in a later CL.
Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
931fcafe0b
commit
97dff044f8
162 changed files with 441 additions and 429 deletions
|
|
@ -41,8 +41,9 @@ Here is an example of a good commit message:
|
|||
```
|
||||
devices: vhost: user: vmm: Add Connection type
|
||||
|
||||
This abstracts away the cross-platform differences: cfg(unix) uses a
|
||||
Unix domain stream socket to connect to the vhost-user backend, and
|
||||
This abstracts away the cross-platform differences:
|
||||
cfg(any(target_os = "android", target_os = "linux")) uses a Unix
|
||||
domain domain stream socket to connect to the vhost-user backend, and
|
||||
cfg(windows) uses a Tube.
|
||||
|
||||
BUG=b:249361790
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ x86_64 = { path = "x86_64" }
|
|||
[target.'cfg(any(target_arch = "aarch64", target_arch = "arm"))'.dependencies]
|
||||
aarch64 = { path = "aarch64" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
minijail = "*" # provided by ebuild
|
||||
p9 = "0.2.3"
|
||||
vhost = { path = "vhost" }
|
||||
|
|
|
|||
|
|
@ -31,5 +31,5 @@ thiserror = "*"
|
|||
vm_control = { path = "../vm_control" }
|
||||
vm_memory = { path = "../vm_memory" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
minijail = "*"
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ use hypervisor::VmAArch64;
|
|||
#[cfg(windows)]
|
||||
use jail::FakeMinijailStub as Minijail;
|
||||
use kernel_loader::LoadedKernel;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use minijail::Minijail;
|
||||
use remain::sorted;
|
||||
use resources::AddressRange;
|
||||
use resources::SystemAllocator;
|
||||
use resources::SystemAllocatorConfig;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use sync::Condvar;
|
||||
use sync::Mutex;
|
||||
use thiserror::Error;
|
||||
|
|
@ -392,7 +392,9 @@ impl arch::LinuxArch for AArch64 {
|
|||
dump_device_tree_blob: Option<PathBuf>,
|
||||
_debugcon_jail: Option<Minijail>,
|
||||
#[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
|
||||
#[cfg(unix)] _guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] _guest_suspended_cvar: Option<
|
||||
Arc<(Mutex<bool>, Condvar)>,
|
||||
>,
|
||||
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
|
||||
where
|
||||
V: VmAArch64,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ thiserror = "1.0.20"
|
|||
vm_control = { path = "../vm_control" }
|
||||
vm_memory = { path = "../vm_memory" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
minijail = "*" # provided by ebuild
|
||||
power_monitor = { path = "../power_monitor" }
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ use devices::PciInterruptPin;
|
|||
use devices::PciRoot;
|
||||
use devices::PciRootCommand;
|
||||
use devices::PreferredIrq;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use devices::ProxyDevice;
|
||||
use devices::SerialHardware;
|
||||
use devices::SerialParameters;
|
||||
|
|
@ -62,7 +62,7 @@ use hypervisor::IoEventAddress;
|
|||
use hypervisor::Vm;
|
||||
#[cfg(windows)]
|
||||
use jail::FakeMinijailStub as Minijail;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use minijail::Minijail;
|
||||
use remain::sorted;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
|
@ -78,7 +78,7 @@ pub use serial::get_serial_cmdline;
|
|||
pub use serial::set_default_serial_parameters;
|
||||
pub use serial::GetSerialCmdlineError;
|
||||
pub use serial::SERIAL_ADDR;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use sync::Condvar;
|
||||
use sync::Mutex;
|
||||
use thiserror::Error;
|
||||
|
|
@ -373,7 +373,7 @@ pub struct RunnableLinuxVm<V: VmArch, Vcpu: VcpuArch> {
|
|||
pub mmio_bus: Arc<Bus>,
|
||||
pub no_smt: bool,
|
||||
pub pid_debug_label_map: BTreeMap<u32, String>,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub platform_devices: Vec<Arc<Mutex<dyn BusDevice>>>,
|
||||
pub pm: Option<Arc<Mutex<dyn PmResource + Send>>>,
|
||||
/// Devices to be notified before the system resumes from the S3 suspended state.
|
||||
|
|
@ -460,7 +460,9 @@ pub trait LinuxArch {
|
|||
#[cfg(target_arch = "x86_64")] pflash_jail: Option<Minijail>,
|
||||
#[cfg(target_arch = "x86_64")] fw_cfg_jail: Option<Minijail>,
|
||||
#[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
|
||||
#[cfg(unix)] guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] guest_suspended_cvar: Option<
|
||||
Arc<(Mutex<bool>, Condvar)>,
|
||||
>,
|
||||
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
|
||||
where
|
||||
V: VmArch,
|
||||
|
|
@ -493,7 +495,7 @@ pub trait LinuxArch {
|
|||
fn register_pci_device<V: VmArch, Vcpu: VcpuArch>(
|
||||
linux: &mut RunnableLinuxVm<V, Vcpu>,
|
||||
device: Box<dyn PciDevice>,
|
||||
#[cfg(unix)] minijail: Option<Minijail>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] minijail: Option<Minijail>,
|
||||
resources: &mut SystemAllocator,
|
||||
hp_control_tube: &mpsc::Sender<PciRootCommand>,
|
||||
#[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
|
||||
|
|
@ -569,14 +571,14 @@ pub enum DeviceRegistrationError {
|
|||
#[error("Allocating IRQ number")]
|
||||
AllocateIrq,
|
||||
/// Could not allocate IRQ resource for the device.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("Allocating IRQ resource: {0}")]
|
||||
AllocateIrqResource(devices::vfio::VfioError),
|
||||
/// Broken pci topology
|
||||
#[error("pci topology is broken")]
|
||||
BrokenPciTopology,
|
||||
/// Unable to clone a jail for the device.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to clone jail: {0}")]
|
||||
CloneJail(minijail::Error),
|
||||
/// Appending to kernel command line failed.
|
||||
|
|
@ -615,11 +617,11 @@ pub enum DeviceRegistrationError {
|
|||
/// Failed to insert device into PCI root.
|
||||
#[error("failed to insert device into PCI root: {0}")]
|
||||
PciRootAddDevice(PciDeviceError),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// Failed to initialize proxy device for jailed device.
|
||||
#[error("failed to create proxy device: {0}")]
|
||||
ProxyDeviceCreation(devices::ProxyError),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// Failed to register battery device.
|
||||
#[error("failed to register battery device to VM: {0}")]
|
||||
RegisterBattery(devices::BatteryError),
|
||||
|
|
@ -644,7 +646,7 @@ pub enum DeviceRegistrationError {
|
|||
pub fn configure_pci_device<V: VmArch, Vcpu: VcpuArch>(
|
||||
linux: &mut RunnableLinuxVm<V, Vcpu>,
|
||||
mut device: Box<dyn PciDevice>,
|
||||
#[cfg(unix)] jail: Option<Minijail>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] jail: Option<Minijail>,
|
||||
resources: &mut SystemAllocator,
|
||||
hp_control_tube: &mpsc::Sender<PciRootCommand>,
|
||||
#[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
|
||||
|
|
@ -704,7 +706,7 @@ pub fn configure_pci_device<V: VmArch, Vcpu: VcpuArch>(
|
|||
.register_device_capabilities()
|
||||
.map_err(DeviceRegistrationError::RegisterDeviceCapabilities)?;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
|
||||
let proxy = ProxyDevice::new(
|
||||
device,
|
||||
|
|
@ -729,7 +731,7 @@ pub fn configure_pci_device<V: VmArch, Vcpu: VcpuArch>(
|
|||
Arc::new(Mutex::new(device))
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
hp_control_tube
|
||||
.send(PciRootCommand::Add(pci_address, arced_dev.clone()))
|
||||
.map_err(DeviceRegistrationError::RegisterDevice)?;
|
||||
|
|
@ -768,7 +770,7 @@ pub fn generate_virtio_mmio_bus(
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
let mut sdts = sdts;
|
||||
for dev_value in devices.into_iter() {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let (mut device, jail) = dev_value;
|
||||
#[cfg(windows)]
|
||||
let (mut device, _) = dev_value;
|
||||
|
|
@ -805,7 +807,7 @@ pub fn generate_virtio_mmio_bus(
|
|||
.ok_or(DeviceRegistrationError::GenerateAcpi)?;
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
|
||||
let proxy = ProxyDevice::new(
|
||||
device,
|
||||
|
|
@ -1088,7 +1090,7 @@ pub fn generate_pci_root(
|
|||
let mut amls = BTreeMap::new();
|
||||
let mut gpe_scope_amls = BTreeMap::new();
|
||||
for (dev_idx, dev_value) in devices {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let (mut device, jail) = dev_value;
|
||||
#[cfg(windows)]
|
||||
let (mut device, _) = dev_value;
|
||||
|
|
@ -1121,7 +1123,7 @@ pub fn generate_pci_root(
|
|||
}
|
||||
let gpe_nr = device.set_gpe(resources);
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
|
||||
let proxy = ProxyDevice::new(
|
||||
device,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(crate) mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use hypervisor::ProtectionType;
|
|||
use jail::read_jail_addr;
|
||||
#[cfg(windows)]
|
||||
use jail::FakeMinijailStub as Minijail;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use minijail::Minijail;
|
||||
use remain::sorted;
|
||||
use thiserror::Error as ThisError;
|
||||
|
|
@ -123,7 +123,7 @@ pub fn add_serial_devices(
|
|||
.create_serial_device::<Serial>(protection_type, com_evt, &mut preserved_descriptors)
|
||||
.map_err(DeviceRegistrationError::CreateSerialDevice)?;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let serial_jail = if let Some(serial_jail) = serial_jail.as_ref() {
|
||||
let jail_clone = serial_jail
|
||||
.try_clone()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(crate) mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ pub fn add_goldfish_battery(
|
|||
}
|
||||
|
||||
/// Creates a platform device for use by this Vm.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub fn generate_platform_bus(
|
||||
devices: Vec<(VfioPlatformDevice, Option<Minijail>)>,
|
||||
irq_chip: &mut dyn IrqChip,
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
serde_json = "*"
|
||||
thiserror = "1.0.20"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
minijail = "*"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ zerocopy = { version = "0.7", features = ["derive"] }
|
|||
libtest-mimic = "0.6"
|
||||
protos = { path = "../protos", features = ["composite-disk"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
minijail = "*"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ pub use write_zeroes::WriteZeroesAt;
|
|||
// TODO(b/233233301): reorganize platform specific exports under platform
|
||||
// namespaces instead of exposing them directly in base::.
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub use sys::unix;
|
||||
|
||||
pub use unix::net;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl audio_streams::shm_streams::SharedMemory for SharedMemory {
|
|||
self.size()
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn as_raw_fd(&self) -> RawDescriptor {
|
||||
self.as_raw_descriptor()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub mod unix;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub mod windows;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub use unix as platform;
|
||||
pub use platform::*;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ pub enum Error {
|
|||
#[cfg(windows)]
|
||||
#[error("failed to flush named pipe: {0}")]
|
||||
Flush(io::Error),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("byte framing mode is not supported")]
|
||||
InvalidFramingMode,
|
||||
#[error("failed to serialize/deserialize json from packet: {0}")]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod test {
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
|
@ -108,27 +108,27 @@ fn main() {
|
|||
};
|
||||
|
||||
let tests = vec![
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
libtest_mimic::Trial::test("pid_diff", move || {
|
||||
test::pid_diff();
|
||||
Ok(())
|
||||
}),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
libtest_mimic::Trial::test("thread_name", move || {
|
||||
test::thread_name();
|
||||
Ok(())
|
||||
}),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
libtest_mimic::Trial::test("thread_name_trimmed", move || {
|
||||
test::thread_name_trimmed();
|
||||
Ok(())
|
||||
}),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
libtest_mimic::Trial::test("wait_for_success", move || {
|
||||
test::wait_for_success();
|
||||
Ok(())
|
||||
}),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
libtest_mimic::Trial::test("wait_for_panic", move || {
|
||||
test::wait_for_panic();
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
//! The implementation is provided in `cros_async::audio_streams_async`.
|
||||
|
||||
use std::io::Result;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::io::RawFd as RawDescriptor;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::net::UnixStream;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::RawHandle;
|
||||
|
|
@ -64,7 +64,7 @@ pub type AsyncStream = Box<dyn ReadWriteAsync + Send>;
|
|||
#[async_trait(?Send)]
|
||||
pub trait AudioStreamsExecutor {
|
||||
/// Create an object to allow async reads/writes from the specified UnixStream.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn async_unix_stream(&self, f: UnixStream) -> Result<AsyncStream>;
|
||||
|
||||
/// Wraps an event that will be triggered when the audio backend is ready to read more audio
|
||||
|
|
@ -80,7 +80,7 @@ pub trait AudioStreamsExecutor {
|
|||
async fn delay(&self, dur: Duration) -> Result<()>;
|
||||
|
||||
// Returns a future that resolves after the provided descriptor is readable.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
async fn wait_fd_readable(&self, _fd: RawDescriptor) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ pub mod test {
|
|||
|
||||
#[async_trait(?Send)]
|
||||
impl AudioStreamsExecutor for TestExecutor {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn async_unix_stream(&self, _f: UnixStream) -> Result<AsyncStream> {
|
||||
panic!("Not Implemented");
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ pub mod test {
|
|||
unimplemented!("async_event is not yet implemented on windows");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
async fn wait_fd_readable(&self, _fd: RawDescriptor) -> Result<()> {
|
||||
panic!("Not Implemented");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ use std::fmt::Display;
|
|||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::io::RawFd as RawDescriptor;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::RawHandle as RawDescriptor;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Condvar;
|
||||
|
|
@ -174,7 +174,7 @@ pub trait SharedMemory {
|
|||
fn size(&self) -> u64;
|
||||
|
||||
/// Returns the underlying raw fd.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn as_raw_fd(&self) -> RawFd;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ pub trait ShmStreamSource<E: std::error::Error>: Send {
|
|||
/// Returns any open file descriptors needed by the implementation.
|
||||
/// This list helps users of the ShmStreamSource enter Linux jails without
|
||||
/// closing needed file descriptors.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
Vec::new()
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ pub mod tests {
|
|||
0
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//! A wrapper module for platform dependent code.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
pub use unix::*;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ anyhow = "1.0"
|
|||
serde = "*"
|
||||
serde_keyvalue = { path = "../serde_keyvalue", features = ["argh_derive"] } # provided by ebuild
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
io_uring = { path = "../io_uring" } # provided by ebuild
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
|
|
|||
|
|
@ -7,30 +7,30 @@
|
|||
//! It implements the `AudioStreamsExecutor` trait for `Executor`, so it can be passed into
|
||||
//! the audio_streams API.
|
||||
use std::io::Result;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::net::UnixStream;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::RawHandle;
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use audio_streams::async_api::AsyncStream;
|
||||
use audio_streams::async_api::AudioStreamsExecutor;
|
||||
use audio_streams::async_api::EventAsyncWrapper;
|
||||
use audio_streams::async_api::ReadAsync;
|
||||
use audio_streams::async_api::ReadWriteAsync;
|
||||
use audio_streams::async_api::WriteAsync;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use base::Descriptor;
|
||||
#[cfg(windows)]
|
||||
use base::Event;
|
||||
#[cfg(windows)]
|
||||
use base::FromRawDescriptor;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use base::RawDescriptor;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use super::AsyncWrapper;
|
||||
use crate::EventAsync;
|
||||
use crate::IntoAsync;
|
||||
|
|
@ -82,7 +82,7 @@ impl EventAsyncWrapper for EventAsync {
|
|||
|
||||
#[async_trait(?Send)]
|
||||
impl AudioStreamsExecutor for super::Executor {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn async_unix_stream(&self, stream: UnixStream) -> Result<AsyncStream> {
|
||||
Ok(Box::new(IoSourceWrapper {
|
||||
source: self.async_from(AsyncWrapper::new(stream))?,
|
||||
|
|
@ -103,7 +103,7 @@ impl AudioStreamsExecutor for super::Executor {
|
|||
TimerAsync::sleep(self, dur).await.map_err(Into::into)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
async fn wait_fd_readable(&self, fd: RawDescriptor) -> Result<()> {
|
||||
self.async_from(AsyncWrapper::new(Descriptor(fd)))?
|
||||
.wait_readable()
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub mod unix;
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use std::ops::DerefMut;
|
|||
|
||||
use base::AsRawDescriptor;
|
||||
use base::RawDescriptor;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use base::UnixSeqpacket;
|
||||
use remain::sorted;
|
||||
use thiserror::Error as ThisError;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[sorted]
|
||||
#[derive(ThisError, Debug)]
|
||||
pub enum Error {
|
||||
|
|
@ -49,21 +49,21 @@ pub enum Error {
|
|||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl From<crate::sys::unix::uring_executor::Error> for Error {
|
||||
fn from(err: crate::sys::unix::uring_executor::Error) -> Self {
|
||||
Error::Uring(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl From<crate::sys::unix::poll_source::Error> for Error {
|
||||
fn from(err: crate::sys::unix::poll_source::Error) -> Self {
|
||||
Error::Poll(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl From<Error> for io::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
use Error::*;
|
||||
|
|
@ -113,7 +113,7 @@ impl From<crate::sys::windows::handle_executor::Error> for Error {
|
|||
pub trait IntoAsync: AsRawDescriptor {}
|
||||
|
||||
impl IntoAsync for File {}
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl IntoAsync for UnixSeqpacket {}
|
||||
|
||||
/// Simple wrapper struct to implement IntoAsync on foreign types.
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use std::sync::Arc;
|
|||
|
||||
use base::AsRawDescriptor;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use crate::sys::unix::PollSource;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use crate::sys::unix::UringSource;
|
||||
#[cfg(windows)]
|
||||
use crate::sys::windows::HandleSource;
|
||||
|
|
@ -21,9 +21,9 @@ use crate::MemRegion;
|
|||
/// Associates an IO object `F` with cros_async's runtime and exposes an API to perform async IO on
|
||||
/// that object's descriptor.
|
||||
pub enum IoSource<F: base::AsRawDescriptor> {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
Uring(UringSource<F>),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
Epoll(PollSource<F>),
|
||||
#[cfg(windows)]
|
||||
Handle(HandleSource<F>),
|
||||
|
|
@ -32,14 +32,14 @@ pub enum IoSource<F: base::AsRawDescriptor> {
|
|||
}
|
||||
|
||||
pub enum AllocateMode {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
Allocate,
|
||||
PunchHole,
|
||||
ZeroRange,
|
||||
}
|
||||
|
||||
// This assume we always want KEEP_SIZE
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl From<AllocateMode> for u32 {
|
||||
fn from(value: AllocateMode) -> Self {
|
||||
match value {
|
||||
|
|
@ -60,9 +60,9 @@ impl From<AllocateMode> for u32 {
|
|||
macro_rules! await_on_inner {
|
||||
($x:ident, $method:ident $(, $args:expr)*) => {
|
||||
match $x {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
IoSource::Uring(x) => UringSource::$method(x, $($args),*).await,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
IoSource::Epoll(x) => PollSource::$method(x, $($args),*).await,
|
||||
#[cfg(windows)]
|
||||
IoSource::Handle(x) => HandleSource::$method(x, $($args),*).await,
|
||||
|
|
@ -78,9 +78,9 @@ macro_rules! await_on_inner {
|
|||
macro_rules! on_inner {
|
||||
($x:ident, $method:ident $(, $args:expr)*) => {
|
||||
match $x {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
IoSource::Uring(x) => UringSource::$method(x, $($args),*),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
IoSource::Epoll(x) => PollSource::$method(x, $($args),*),
|
||||
#[cfg(windows)]
|
||||
IoSource::Handle(x) => HandleSource::$method(x, $($args),*),
|
||||
|
|
@ -192,13 +192,13 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use crate::mem::VecIoWrapper;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use crate::sys::unix::uring_executor::is_uring_stable;
|
||||
use crate::Executor;
|
||||
use crate::ExecutorKind;
|
||||
use crate::MemRegion;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn all_kinds() -> Vec<ExecutorKind> {
|
||||
let mut kinds = vec![ExecutorKind::Fd];
|
||||
if is_uring_stable() {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ mod queue;
|
|||
mod select;
|
||||
pub mod sync;
|
||||
pub mod sys;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use sys::unix::uring_executor::is_uring_stable;
|
||||
pub use sys::Executor;
|
||||
pub use sys::ExecutorKind;
|
||||
|
|
@ -81,7 +81,7 @@ use std::task::Poll;
|
|||
|
||||
pub use async_types::*;
|
||||
pub use base::Event;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use blocking::sys::unix::block_on::block_on;
|
||||
pub use blocking::unblock;
|
||||
pub use blocking::unblock_disarm;
|
||||
|
|
@ -120,7 +120,7 @@ pub enum Error {
|
|||
#[error("IO error: {0}")]
|
||||
Io(std::io::Error),
|
||||
/// Error from the polled(FD) source, which includes error from the FD executor.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("An error with a poll source: {0}")]
|
||||
PollSource(sys::unix::poll_source::Error),
|
||||
/// Error from Timer.
|
||||
|
|
@ -130,7 +130,7 @@ pub enum Error {
|
|||
#[error("Failure in TimerAsync: {0}")]
|
||||
TimerAsync(AsyncError),
|
||||
/// Error from the uring executor.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("Failure in the uring executor: {0}")]
|
||||
URingExecutor(sys::unix::uring_executor::Error),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ fn cancel_waiter(cv: usize, waiter: &Waiter, wake_next: bool) {
|
|||
}
|
||||
|
||||
// TODO(b/194338842): Fix tests for windows
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::future::Future;
|
||||
|
|
|
|||
|
|
@ -888,7 +888,7 @@ impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> {
|
|||
}
|
||||
|
||||
// TODO(b/194338842): Fix tests for windows
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::future::Future;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
pub use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ use crate::IoSource;
|
|||
/// Ok(len)
|
||||
/// }
|
||||
///
|
||||
/// #[cfg(unix)]
|
||||
/// #[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// # fn do_it() -> Result<(), Box<dyn Error>> {
|
||||
/// let ex = Executor::new()?;
|
||||
///
|
||||
|
|
@ -119,7 +119,7 @@ use crate::IoSource;
|
|||
///
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// #[cfg(unix)]
|
||||
/// #[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// # do_it().unwrap();
|
||||
/// ```
|
||||
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn await_uring_from_poll() {
|
||||
if !is_uring_stable() {
|
||||
|
|
@ -434,7 +434,7 @@ mod tests {
|
|||
handle.join().unwrap().unwrap();
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn await_poll_from_uring() {
|
||||
if !is_uring_stable() {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ use crate::IoSource;
|
|||
/// Ok(len)
|
||||
/// }
|
||||
///
|
||||
/// #[cfg(unix)]
|
||||
/// #[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// # fn do_it() -> Result<(), Box<dyn Error>> {
|
||||
/// let ex = Executor::new()?;
|
||||
///
|
||||
|
|
@ -111,7 +111,7 @@ use crate::IoSource;
|
|||
///
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// #[cfg(unix)]
|
||||
/// #[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// # do_it().unwrap();
|
||||
/// ```
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
use cros_async::Executor;
|
||||
use cros_async::ExecutorKind;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn all_kinds() -> Vec<ExecutorKind> {
|
||||
let mut kinds = vec![ExecutorKind::Fd];
|
||||
if cros_async::is_uring_stable() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use std::ffi::CStr;
|
|||
use std::panic::catch_unwind;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::time::Duration;
|
||||
|
||||
use libc::c_char;
|
||||
|
|
@ -166,7 +166,7 @@ pub unsafe extern "C" fn crosvm_client_balloon_vms(
|
|||
}
|
||||
|
||||
/// See crosvm_client_balloon_vms.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn crosvm_client_balloon_vms_wait_with_timeout(
|
||||
socket_path: *const c_char,
|
||||
|
|
@ -702,7 +702,7 @@ pub unsafe extern "C" fn crosvm_client_balloon_stats(
|
|||
) -> bool {
|
||||
crosvm_client_balloon_stats_impl(
|
||||
socket_path,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
None,
|
||||
stats,
|
||||
actual,
|
||||
|
|
@ -710,7 +710,7 @@ pub unsafe extern "C" fn crosvm_client_balloon_stats(
|
|||
}
|
||||
|
||||
/// See crosvm_client_balloon_stats.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn crosvm_client_balloon_stats_with_timeout(
|
||||
socket_path: *const c_char,
|
||||
|
|
@ -728,7 +728,7 @@ pub unsafe extern "C" fn crosvm_client_balloon_stats_with_timeout(
|
|||
|
||||
fn crosvm_client_balloon_stats_impl(
|
||||
socket_path: *const c_char,
|
||||
#[cfg(unix)] timeout_ms: Option<Duration>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] timeout_ms: Option<Duration>,
|
||||
stats: *mut BalloonStatsFfi,
|
||||
actual: *mut u64,
|
||||
) -> bool {
|
||||
|
|
@ -737,7 +737,7 @@ fn crosvm_client_balloon_stats_impl(
|
|||
let request = &VmRequest::BalloonCommand(BalloonControlCommand::Stats {});
|
||||
#[cfg(not(unix))]
|
||||
let resp = handle_request(request, socket_path);
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let resp = handle_request_with_timeout(request, socket_path, timeout_ms);
|
||||
if let Ok(VmResponse::BalloonStats {
|
||||
stats: ref balloon_stats,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#![cfg(target_arch = "x86_64")]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ vm_control = { path = "../vm_control" }
|
|||
vm_memory = { path = "../vm_memory" }
|
||||
zerocopy = { version = "0.7", features = ["derive"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
fuse = {path = "../fuse" }
|
||||
libcras = { version = "*", optional = true }
|
||||
minijail = "*"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use crate::DeviceId;
|
|||
use crate::PciAddress;
|
||||
use crate::PciDevice;
|
||||
use crate::Suspendable;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use crate::VfioPlatformDevice;
|
||||
use crate::VirtioMmioDevice;
|
||||
|
||||
|
|
@ -231,15 +231,15 @@ pub trait BusDeviceObj {
|
|||
fn into_pci_device(self: Box<Self>) -> Option<Box<dyn PciDevice>> {
|
||||
None
|
||||
}
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn as_platform_device(&self) -> Option<&VfioPlatformDevice> {
|
||||
None
|
||||
}
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn as_platform_device_mut(&mut self) -> Option<&mut VfioPlatformDevice> {
|
||||
None
|
||||
}
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn into_platform_device(self: Box<Self>) -> Option<Box<VfioPlatformDevice>> {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use crate::IrqEdgeEvent;
|
|||
use crate::IrqLevelEvent;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod kvm;
|
||||
pub use self::kvm::KvmKernelIrqChip;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ pub use self::virtio::VirtioPciDevice;
|
|||
pub use self::vtpm_proxy::VtpmProxy;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod platform;
|
||||
mod proxy;
|
||||
pub mod vmwdt;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//! Implements pci devices and busses.
|
||||
|
||||
mod acpi;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod coiommu;
|
||||
mod msi;
|
||||
mod msix;
|
||||
|
|
@ -15,12 +15,12 @@ mod pci_device;
|
|||
#[cfg(feature = "pci-hotplug")]
|
||||
mod pci_hotplug;
|
||||
mod pci_root;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod pcie;
|
||||
mod pm;
|
||||
mod pvpanic;
|
||||
mod stub;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod vfio_pci;
|
||||
|
||||
use libc::EINVAL;
|
||||
|
|
@ -31,11 +31,11 @@ pub use self::acpi::DeviceVcfgRegister;
|
|||
pub use self::acpi::DsmMethod;
|
||||
pub use self::acpi::GpeScope;
|
||||
pub use self::acpi::PowerResourceMethod;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::coiommu::CoIommuDev;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::coiommu::CoIommuParameters;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::coiommu::CoIommuUnpinPolicy;
|
||||
pub use self::msi::MsiConfig;
|
||||
pub use self::msix::MsixCap;
|
||||
|
|
@ -77,21 +77,21 @@ pub use self::pci_root::PciConfigMmio;
|
|||
pub use self::pci_root::PciRoot;
|
||||
pub use self::pci_root::PciRootCommand;
|
||||
pub use self::pci_root::PciVirtualConfigMmio;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::pcie::PciBridge;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::pcie::PcieDownstreamPort;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::pcie::PcieHostPort;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::pcie::PcieRootPort;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::pcie::PcieUpstreamPort;
|
||||
pub use self::pvpanic::PvPanicCode;
|
||||
pub use self::pvpanic::PvPanicPciDevice;
|
||||
pub use self::stub::StubPciDevice;
|
||||
pub use self::stub::StubPciParameters;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::vfio_pci::VfioPciDevice;
|
||||
|
||||
/// PCI has four interrupt pins A->D.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub const COMMAND_REG_MEMORY_SPACE_MASK: u32 = 0x0000_0002;
|
|||
const STATUS_REG: usize = 1;
|
||||
pub const STATUS_REG_CAPABILITIES_USED_MASK: u32 = 0x0010_0000;
|
||||
#[allow(dead_code)]
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub const CLASS_REG: usize = 2;
|
||||
pub const HEADER_TYPE_REG: usize = 3;
|
||||
pub const HEADER_TYPE_MULTIFUNCTION_MASK: u32 = 0x0080_0000;
|
||||
|
|
@ -40,7 +40,7 @@ pub const NUM_BAR_REGS: usize = 7; // 6 normal BARs + expansion ROM BAR.
|
|||
pub const ROM_BAR_IDX: PciBarIndex = 6;
|
||||
pub const ROM_BAR_REG: usize = 12;
|
||||
pub const CAPABILITY_LIST_HEAD_OFFSET: usize = 0x34;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub const PCI_CAP_NEXT_POINTER: usize = 0x1;
|
||||
const FIRST_CAPABILITY_OFFSET: usize = 0x40;
|
||||
pub const CAPABILITY_MAX_OFFSET: usize = 255;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(in crate::serial) mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ mod tests {
|
|||
assert_eq!(params.type_, SerialType::Sink);
|
||||
let params = from_serial_arg("type=syslog").unwrap();
|
||||
assert_eq!(params.type_, SerialType::Syslog);
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let opt = "type=unix";
|
||||
#[cfg(windows)]
|
||||
let opt = "type=namedpipe";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(crate) mod unix;
|
||||
use unix as platform;
|
||||
pub(crate) use unix::*;
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ fn run_worker(
|
|||
len,
|
||||
#[cfg(windows)]
|
||||
&vm_memory_client,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
&mem,
|
||||
)
|
||||
},
|
||||
|
|
@ -1060,7 +1060,7 @@ fn run_worker(
|
|||
len,
|
||||
#[cfg(windows)]
|
||||
&vm_memory_client,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
&mem,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -1549,20 +1549,20 @@ mod tests {
|
|||
}
|
||||
|
||||
// TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn reset_and_reactivate_single_worker() {
|
||||
reset_and_reactivate(false);
|
||||
}
|
||||
|
||||
// TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn reset_and_reactivate_multiple_workers() {
|
||||
reset_and_reactivate(true);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn reset_and_reactivate(enables_multiple_workers: bool) {
|
||||
// Create an empty disk image
|
||||
let f = tempfile().unwrap();
|
||||
|
|
@ -1662,7 +1662,7 @@ mod tests {
|
|||
|
||||
// TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
|
||||
// or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn resize_with_single_worker() {
|
||||
resize(false);
|
||||
|
|
@ -1670,7 +1670,7 @@ mod tests {
|
|||
|
||||
// TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
|
||||
// or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn resize_with_multiple_workers() {
|
||||
// Test resize handled by one worker affect the whole state
|
||||
|
|
@ -1789,7 +1789,7 @@ mod tests {
|
|||
|
||||
// TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
|
||||
// or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn run_worker_threads() {
|
||||
// Create an empty duplicable disk image
|
||||
|
|
@ -1906,6 +1906,6 @@ mod tests {
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
suspendable_virtio_tests!(asyncblock, create_device, 2, modify_device);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ mod tests {
|
|||
// async-executor
|
||||
#[cfg(windows)]
|
||||
let (ex_kind, ex_kind_opt) = (ExecutorKind::Handle, "handle");
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let (ex_kind, ex_kind_opt) = (ExecutorKind::Fd, "epoll");
|
||||
let params =
|
||||
from_block_arg(&format!("/some/path.img,async-executor={ex_kind_opt}")).unwrap();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
pub use self::unix::*;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//! Legacy console device that uses a polling thread. This is kept because it is still used by
|
||||
//! Windows ; outside of this use-case, please use [[asynchronous::AsyncConsole]] instead.
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub mod asynchronous;
|
||||
mod sys;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use anyhow::anyhow;
|
|||
use anyhow::Context;
|
||||
use base::debug;
|
||||
use base::error;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use base::platform::move_task_to_cgroup;
|
||||
use base::warn;
|
||||
use base::AsRawDescriptor;
|
||||
|
|
@ -800,7 +800,7 @@ enum WorkerToken {
|
|||
CtrlQueue,
|
||||
CursorQueue,
|
||||
Display,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
GpuControl,
|
||||
InterruptResample,
|
||||
Kill,
|
||||
|
|
@ -857,7 +857,7 @@ impl<'a> EventManager<'a> {
|
|||
struct Worker {
|
||||
interrupt: Interrupt,
|
||||
exit_evt_wrtube: SendTube,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube: Tube,
|
||||
mem: GuestMemory,
|
||||
ctrl_queue: SharedQueueReader,
|
||||
|
|
@ -870,7 +870,7 @@ struct Worker {
|
|||
}
|
||||
|
||||
struct WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube: Tube,
|
||||
resource_bridges: ResourceBridges,
|
||||
event_devices: Vec<EventDevice>,
|
||||
|
|
@ -915,7 +915,7 @@ impl Worker {
|
|||
(&ctrl_evt, WorkerToken::CtrlQueue),
|
||||
(&cursor_evt, WorkerToken::CursorQueue),
|
||||
(&display_desc, WorkerToken::Display),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
(&self.gpu_control_tube, WorkerToken::GpuControl),
|
||||
(&self.kill_evt, WorkerToken::Kill),
|
||||
#[cfg(windows)]
|
||||
|
|
@ -1027,7 +1027,7 @@ impl Worker {
|
|||
error!("failed to receive ModifyWaitContext request.")
|
||||
}
|
||||
}
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
WorkerToken::GpuControl => {
|
||||
let req = match self.gpu_control_tube.recv() {
|
||||
Ok(req) => req,
|
||||
|
|
@ -1110,10 +1110,10 @@ impl Worker {
|
|||
/// to use as fallbacks in case some do not work.
|
||||
#[derive(Clone)]
|
||||
pub enum DisplayBackend {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// Use the wayland backend with the given socket path if given.
|
||||
Wayland(Option<PathBuf>),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
/// Open a connection to the X server at the given display if given.
|
||||
X(Option<String>),
|
||||
/// Emulate a display without actually displaying it.
|
||||
|
|
@ -1130,9 +1130,9 @@ impl DisplayBackend {
|
|||
#[cfg(windows)] gpu_display_wait_descriptor_ctrl: SendTube,
|
||||
) -> std::result::Result<GpuDisplay, GpuDisplayError> {
|
||||
match self {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
DisplayBackend::Wayland(path) => GpuDisplay::open_wayland(path.as_ref()),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
DisplayBackend::X(display) => GpuDisplay::open_x(display.as_deref()),
|
||||
DisplayBackend::Stub => GpuDisplay::open_stub(),
|
||||
#[cfg(windows)]
|
||||
|
|
@ -1163,7 +1163,7 @@ struct GpuActivationResources {
|
|||
|
||||
pub struct Gpu {
|
||||
exit_evt_wrtube: SendTube,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube: Option<Tube>,
|
||||
mapper: Arc<Mutex<Option<Box<dyn SharedMemoryMapper>>>>,
|
||||
resource_bridges: Option<ResourceBridges>,
|
||||
|
|
@ -1199,7 +1199,7 @@ pub struct Gpu {
|
|||
/// context.
|
||||
gpu_display_wait_descriptor_ctrl_rd: Option<RecvTube>,
|
||||
capset_mask: u64,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_cgroup_path: Option<PathBuf>,
|
||||
/// Used to differentiate worker kill events that are for shutdown vs sleep. `virtio_sleep`
|
||||
/// sets this to true while stopping the worker.
|
||||
|
|
@ -1210,7 +1210,7 @@ pub struct Gpu {
|
|||
impl Gpu {
|
||||
pub fn new(
|
||||
exit_evt_wrtube: SendTube,
|
||||
#[cfg(unix)] gpu_control_tube: Tube,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] gpu_control_tube: Tube,
|
||||
resource_bridges: Vec<Tube>,
|
||||
display_backends: Vec<DisplayBackend>,
|
||||
gpu_parameters: &GpuParameters,
|
||||
|
|
@ -1219,7 +1219,7 @@ impl Gpu {
|
|||
base_features: u64,
|
||||
channels: &BTreeMap<String, PathBuf>,
|
||||
#[cfg(windows)] wndproc_thread: WindowProcedureThread,
|
||||
#[cfg(unix)] gpu_cgroup_path: Option<&PathBuf>,
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))] gpu_cgroup_path: Option<&PathBuf>,
|
||||
) -> Gpu {
|
||||
let mut display_params = gpu_parameters.display_params.clone();
|
||||
if display_params.is_empty() {
|
||||
|
|
@ -1282,7 +1282,7 @@ impl Gpu {
|
|||
|
||||
Gpu {
|
||||
exit_evt_wrtube,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube: Some(gpu_control_tube),
|
||||
mapper: Arc::new(Mutex::new(None)),
|
||||
resource_bridges: Some(ResourceBridges::new(resource_bridges)),
|
||||
|
|
@ -1306,7 +1306,7 @@ impl Gpu {
|
|||
#[cfg(windows)]
|
||||
gpu_display_wait_descriptor_ctrl_rd: Some(gpu_display_wait_descriptor_ctrl_rd),
|
||||
capset_mask: gpu_parameters.capset_mask,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_cgroup_path: gpu_cgroup_path.cloned(),
|
||||
sleep_requested: Arc::new(AtomicBool::new(false)),
|
||||
worker_snapshot: None,
|
||||
|
|
@ -1366,7 +1366,7 @@ impl Gpu {
|
|||
.context("error cloning exit tube")
|
||||
.unwrap();
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let gpu_control_tube = self
|
||||
.gpu_control_tube
|
||||
.take()
|
||||
|
|
@ -1402,7 +1402,7 @@ impl Gpu {
|
|||
.take()
|
||||
.expect("failed to take gpu_display_wait_descriptor_ctrl_rd");
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let gpu_cgroup_path = self.gpu_cgroup_path.clone();
|
||||
|
||||
let mapper = Arc::clone(&self.mapper);
|
||||
|
|
@ -1417,7 +1417,7 @@ impl Gpu {
|
|||
let sleep_requested = self.sleep_requested.clone();
|
||||
|
||||
let worker_thread = WorkerThread::start("v_gpu", move |kill_evt| {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
if let Some(cgroup_path) = gpu_cgroup_path {
|
||||
move_task_to_cgroup(cgroup_path, base::gettid())
|
||||
.expect("Failed to move v_gpu into requested cgroup");
|
||||
|
|
@ -1434,7 +1434,7 @@ impl Gpu {
|
|||
Err(e) => {
|
||||
error!("failed to build rutabaga {}", e);
|
||||
return WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube,
|
||||
resource_bridges,
|
||||
event_devices,
|
||||
|
|
@ -1459,7 +1459,7 @@ impl Gpu {
|
|||
Some(backend) => backend,
|
||||
None => {
|
||||
return WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube,
|
||||
resource_bridges,
|
||||
event_devices,
|
||||
|
|
@ -1483,7 +1483,7 @@ impl Gpu {
|
|||
// Other half of channel was dropped.
|
||||
Err(mpsc::RecvError) => {
|
||||
return WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube,
|
||||
resource_bridges,
|
||||
event_devices: virtio_gpu.display().borrow_mut().take_event_devices(),
|
||||
|
|
@ -1504,7 +1504,7 @@ impl Gpu {
|
|||
let mut worker = Worker {
|
||||
interrupt: activation_resources.interrupt,
|
||||
exit_evt_wrtube,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube,
|
||||
mem: activation_resources.mem,
|
||||
ctrl_queue: activation_resources.ctrl_queue,
|
||||
|
|
@ -1565,7 +1565,7 @@ impl Gpu {
|
|||
None
|
||||
};
|
||||
WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube: worker.gpu_control_tube,
|
||||
resource_bridges: worker.resource_bridges,
|
||||
event_devices,
|
||||
|
|
@ -1640,7 +1640,7 @@ impl VirtioDevice for Gpu {
|
|||
// casting the underlying DMA buffer wrapped in File to a copyable RawDescriptor.
|
||||
// TODO(davidriley): Remove once virgl has another path to include
|
||||
// debugging logs.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
if cfg!(debug_assertions) {
|
||||
keep_rds.push(libc::STDOUT_FILENO);
|
||||
keep_rds.push(libc::STDERR_FILENO);
|
||||
|
|
@ -1658,7 +1658,7 @@ impl VirtioDevice for Gpu {
|
|||
|
||||
keep_rds.push(self.exit_evt_wrtube.as_raw_descriptor());
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
if let Some(gpu_control_tube) = &self.gpu_control_tube {
|
||||
keep_rds.push(gpu_control_tube.as_raw_descriptor());
|
||||
}
|
||||
|
|
@ -1802,7 +1802,7 @@ impl VirtioDevice for Gpu {
|
|||
self.sleep_requested.store(true, Ordering::SeqCst);
|
||||
drop(activate_tx);
|
||||
let WorkerReturn {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
gpu_control_tube,
|
||||
resource_bridges,
|
||||
event_devices,
|
||||
|
|
@ -1811,7 +1811,7 @@ impl VirtioDevice for Gpu {
|
|||
self.sleep_requested.store(false, Ordering::SeqCst);
|
||||
|
||||
self.resource_bridges = Some(resource_bridges);
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
{
|
||||
self.gpu_control_tube = Some(gpu_control_tube);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ pub use self::virtio_pci_device::VirtioPciDevice;
|
|||
pub use self::virtio_pci_device::VirtioPciShmCap;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod p9;
|
||||
mod pmem;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ use super::VirtioDevice;
|
|||
pub(crate) const MAX_BUFFER_SIZE: usize = 65562;
|
||||
const QUEUE_SIZE: u16 = 256;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub static VHOST_NET_DEFAULT_PATH: &str = "/dev/vhost-net";
|
||||
|
||||
pub(crate) use sys::process_rx;
|
||||
|
|
@ -98,7 +98,7 @@ pub enum NetError {
|
|||
#[error("failed to read control message header: {0}")]
|
||||
ReadCtrlHeader(io::Error),
|
||||
/// There are no more available descriptors to receive into.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("no rx descriptors available")]
|
||||
RxDescriptorsExhausted,
|
||||
/// Failure creating the Slirp loop.
|
||||
|
|
@ -145,7 +145,7 @@ pub enum NetError {
|
|||
#[error("failed to write control message ack: {0}")]
|
||||
WriteAck(io::Error),
|
||||
/// Writing to a buffer in the guest failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to write to guest buffer: {0}")]
|
||||
WriteBuffer(io::Error),
|
||||
}
|
||||
|
|
@ -171,12 +171,12 @@ pub enum NetParametersMode {
|
|||
},
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn vhost_net_device_path_default() -> PathBuf {
|
||||
PathBuf::from(VHOST_NET_DEFAULT_PATH)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
|
||||
pub struct VhostNetParameters {
|
||||
|
|
@ -184,7 +184,7 @@ pub struct VhostNetParameters {
|
|||
pub device: PathBuf,
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
impl Default for VhostNetParameters {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
@ -201,7 +201,7 @@ pub struct NetParameters {
|
|||
pub vq_pairs: Option<u16>,
|
||||
// Style-guide asks to refrain against #[cfg] directives in structs, this is an exception due
|
||||
// to the fact this struct is used for argument parsing.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub vhost_net: Option<VhostNetParameters>,
|
||||
#[serde(default)]
|
||||
pub packed_queue: bool,
|
||||
|
|
@ -401,7 +401,7 @@ where
|
|||
self.overlapped_wrapper.get_h_event_ref().unwrap(),
|
||||
Token::RxTap,
|
||||
),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
(self.tap.get_read_notifier(), Token::RxTap),
|
||||
(self.rx_queue.event(), Token::RxQueue),
|
||||
(self.tx_queue.event(), Token::TxQueue),
|
||||
|
|
@ -906,7 +906,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapName {
|
||||
|
|
@ -921,7 +921,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapName {
|
||||
|
|
@ -936,7 +936,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapFd {
|
||||
|
|
@ -951,7 +951,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapFd {
|
||||
|
|
@ -969,7 +969,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::RawConfig {
|
||||
|
|
@ -989,7 +989,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn params_from_key_values_vhost_net() {
|
||||
let params = from_net_arg(
|
||||
"vhost-net=[device=/dev/foo],\
|
||||
|
|
@ -1061,7 +1061,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapName {
|
||||
|
|
@ -1076,7 +1076,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
params,
|
||||
NetParameters {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_net: None,
|
||||
vq_pairs: None,
|
||||
mode: NetParametersMode::TapName {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
} else if #[cfg(windows)] {
|
||||
mod windows;
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ async fn pcm_worker_loop(
|
|||
);
|
||||
#[cfg(windows)]
|
||||
let buffer_writer = &mut buffer_writer_lock;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
let (stream, buffer_writer) = (
|
||||
&mut sys_direction_output.async_playback_buffer_stream,
|
||||
&mut sys_direction_output.buffer_writer,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub mod file_backend;
|
|||
pub mod null_backend;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod vios_backend;
|
||||
|
||||
pub use vios_backend::new_sound;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use base::TubeError;
|
|||
use net_util::Error as TapError;
|
||||
use remain::sorted;
|
||||
use thiserror::Error;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use vhost::Error as VhostError;
|
||||
|
||||
mod control_socket;
|
||||
|
|
@ -18,7 +18,7 @@ pub mod user;
|
|||
pub use self::control_socket::*;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
#[cfg(feature = "net")]
|
||||
mod net;
|
||||
pub mod vsock;
|
||||
|
|
@ -71,7 +71,7 @@ pub enum Error {
|
|||
#[error("failed to set vnet header size: {0}")]
|
||||
TapSetVnetHdrSize(TapError),
|
||||
/// Get features failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to get features: {0}")]
|
||||
VhostGetFeatures(VhostError),
|
||||
/// Vhost IOTLB required but not supported.
|
||||
|
|
@ -84,51 +84,51 @@ pub enum Error {
|
|||
#[error("failed to read vhost event: {0}")]
|
||||
VhostIrqRead(SysError),
|
||||
/// Net set backend failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("net set backend failed: {0}")]
|
||||
VhostNetSetBackend(VhostError),
|
||||
/// Failed to open vhost device.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to open vhost device: {0}")]
|
||||
VhostOpen(VhostError),
|
||||
/// Set features failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set features: {0}")]
|
||||
VhostSetFeatures(VhostError),
|
||||
/// Set mem table failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set mem table: {0}")]
|
||||
VhostSetMemTable(VhostError),
|
||||
/// Set owner failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set owner: {0}")]
|
||||
VhostSetOwner(VhostError),
|
||||
/// Set vring addr failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set vring addr: {0}")]
|
||||
VhostSetVringAddr(VhostError),
|
||||
/// Set vring base failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set vring base: {0}")]
|
||||
VhostSetVringBase(VhostError),
|
||||
/// Set vring call failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set vring call: {0}")]
|
||||
VhostSetVringCall(VhostError),
|
||||
/// Set vring kick failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set vring kick: {0}")]
|
||||
VhostSetVringKick(VhostError),
|
||||
/// Set vring num failed.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set vring num: {0}")]
|
||||
VhostSetVringNum(VhostError),
|
||||
/// Failed to set CID for guest.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to set CID for guest: {0}")]
|
||||
VhostVsockSetCid(VhostError),
|
||||
/// Failed to start vhost-vsock driver.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[error("failed to start vhost-vsock driver: {0}")]
|
||||
VhostVsockStart(VhostError),
|
||||
#[error("queue missing vring base")]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ use std::collections::BTreeMap;
|
|||
use std::convert::From;
|
||||
use std::fs::File;
|
||||
use std::num::Wrapping;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::bail;
|
||||
use anyhow::Context;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use base::clear_fd_flags;
|
||||
use base::error;
|
||||
use base::Event;
|
||||
|
|
@ -360,7 +360,7 @@ impl VhostUserPlatformOps for VhostUserRegularOps {
|
|||
// Remove O_NONBLOCK from kick_fd. Otherwise, uring_executor will fails when we read
|
||||
// values via `next_val()` later.
|
||||
// This is only required (and can only be done) on Unix platforms.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
if let Err(e) = clear_fd_flags(file.as_raw_fd(), libc::O_NONBLOCK) {
|
||||
error!("failed to remove O_NONBLOCK for kick fd: {}", e);
|
||||
return Err(VhostError::InvalidParam);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
#[cfg(test)]
|
||||
pub use unix::test_helpers;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub use snd::Options as SndOptions;
|
|||
use vmm_vhost::VhostUserSlaveReqHandler;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod console;
|
||||
mod fs;
|
||||
mod vsock;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
pub(super) use self::unix::*;
|
||||
use unix as platform;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use vmm_vhost::Error as VhostError;
|
|||
pub use self::handler::VhostUserHandler;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub type Connection = std::os::unix::net::UnixStream;
|
||||
} else if #[cfg(windows)] {
|
||||
pub type Connection = base::Tube;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
use unix as platform;
|
||||
pub use crate::virtio::vhost::Vsock;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl VsockConfig {
|
|||
pub fn new<P: AsRef<Path>>(cid: u64, vhost_device: Option<P>) -> Self {
|
||||
Self {
|
||||
cid,
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_device: vhost_device
|
||||
.map(|p| PathBuf::from(p.as_ref()))
|
||||
.unwrap_or_else(|| PathBuf::from(VHOST_VSOCK_DEFAULT_PATH)),
|
||||
|
|
@ -77,7 +77,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
from_vsock_arg("78").unwrap(),
|
||||
VsockConfig {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
vhost_device: VHOST_VSOCK_DEFAULT_PATH.into(),
|
||||
cid: 78,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
mod x86_64;
|
||||
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ impl Vcpu for FakeVcpu {
|
|||
|
||||
fn set_immediate_exit(&self, _exit: bool) {}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
fn signal_handle(&self) -> hypervisor::VcpuSignalHandle {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ File: `sys.rs`
|
|||
|
||||
```rust
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
mod unix;
|
||||
pub use platform_print::UnixPrinter as Printer;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
@ -137,13 +137,14 @@ cfg_if::cfg_if! {
|
|||
|
||||
## Imports
|
||||
|
||||
When conditionally importing and using modules, use `cfg(unix)` and `cfg(windows)` for describing
|
||||
the platform. Order imports such that common comes first followed by unix and windows dependencies.
|
||||
When conditionally importing and using modules, use
|
||||
`cfg(any(target_os = "android", target_os = "linux"))` and `cfg(windows)` for describing the
|
||||
platform. Order imports such that common comes first followed by unix and windows dependencies.
|
||||
|
||||
```rust
|
||||
// All other imports
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use {
|
||||
std::x::y,
|
||||
base::a::b::{Foo, Bar},
|
||||
|
|
@ -394,7 +395,7 @@ File: `sys.rs`
|
|||
|
||||
```rust
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
@ -441,7 +442,7 @@ use mylib::sys::print;
|
|||
fn my_print() {
|
||||
print();
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mylib::sys::unix::print_u8(1);
|
||||
|
||||
#[cfg(windows)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(super) mod unix;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use std::env;
|
||||
use std::io::ErrorKind;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
|
@ -126,7 +126,7 @@ impl CommandExt for Command {
|
|||
if let Some(code) = output.status.code() {
|
||||
return Err(CommandError::ErrorCode(code));
|
||||
} else {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
if let Some(signal) = output.status.signal() {
|
||||
return Err(CommandError::Signal(signal));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ mod wire_format;
|
|||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
|
@ -53,7 +53,7 @@ fn listen(
|
|||
stderr: String::from_utf8_lossy(&result.stderr).into_owned(),
|
||||
exit_status: match result.status.code() {
|
||||
Some(code) => wire_format::ExitStatus::Code(code),
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
None => match result.status.signal() {
|
||||
Some(signal) => wire_format::ExitStatus::Signal(signal),
|
||||
None => wire_format::ExitStatus::None,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Testing virtio-block.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::time;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,21 +44,21 @@ fn boot_test_vm_uring() -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_vm_odirect() {
|
||||
let mut vm = TestVm::new(Config::new().o_direct()).unwrap();
|
||||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_vm_config_file() {
|
||||
let mut vm = TestVm::new_with_config_file(Config::new()).unwrap();
|
||||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_suspend_resume() {
|
||||
// There is no easy way for us to check if the VM is actually suspended. But at
|
||||
|
|
@ -69,7 +69,7 @@ fn boot_test_suspend_resume() {
|
|||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_suspend_resume_full() {
|
||||
// There is no easy way for us to check if the VM is actually suspended. But at
|
||||
|
|
@ -88,28 +88,28 @@ fn boot_test_suspend_resume_full() {
|
|||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_vm_disable_sandbox() {
|
||||
let mut vm = TestVm::new(Config::new().disable_sandbox()).unwrap();
|
||||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_vm_disable_sandbox_odirect() {
|
||||
let mut vm = TestVm::new(Config::new().disable_sandbox().o_direct()).unwrap();
|
||||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_vm_disable_sandbox_config_file() {
|
||||
let mut vm = TestVm::new_with_config_file(Config::new().disable_sandbox()).unwrap();
|
||||
assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn boot_test_disable_sandbox_suspend_resume() {
|
||||
// There is no easy way for us to check if the VM is actually suspended. But at
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ fn copy_file() {
|
|||
/// 3. Start a VM with a virtiofs device for the temporal directory.
|
||||
/// 4. Check that `user_file.txt`'s uid is <mapped-uid> in the VM.
|
||||
/// 5. Verify gid similarly.
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[test]
|
||||
fn file_ugid() {
|
||||
const FILE_NAME: &str = "user_file.txt";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Testing vmm-swap
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Testing vsock.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! FUSE (Filesystem in Userspace) server and filesystem mounting support.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
|
||||
use std::ffi::FromBytesWithNulError;
|
||||
use std::fs::File;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![cfg(not(test))]
|
||||
#![no_main]
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod fuzzer {
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
use crosvm_fuzz::fuzz_target;
|
||||
|
||||
fuzz_target!(|bytes: &[u8]| {
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
p9::fuzzing::tframe_decode(bytes);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use std::process::exit;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod platform {
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ mod event_device;
|
|||
mod gpu_display_stub;
|
||||
#[cfg(windows)]
|
||||
mod gpu_display_win;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod gpu_display_wl;
|
||||
#[cfg(feature = "x")]
|
||||
mod gpu_display_x;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
if #[cfg(any(target_os = "android", target_os = "linux"))] {
|
||||
pub(crate) mod unix;
|
||||
pub use unix::UnixGpuDisplayExt as SysGpuDisplayExt;
|
||||
pub(crate) use unix::UnixDisplayT as SysDisplayT;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ sync = { path = "../common/sync" }
|
|||
base = { path = "../base" }
|
||||
vm_memory = { path = "../vm_memory" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||
kvm = { path = "../kvm" }
|
||||
kvm_sys = { path = "../kvm_sys" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Bindings for the GZVM (Geniezone Hypervisor) API.
|
||||
|
||||
#![cfg(unix)]
|
||||
#![cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ mod win;
|
|||
#[cfg(windows)]
|
||||
use win::*;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
mod unix;
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
use unix::*;
|
||||
|
||||
static USE_GHAXM: AtomicBool = AtomicBool::new(true);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue