diff options
author | Dylan Reid <dgreid@chromium.org> | 2018-07-23 17:58:09 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-10 17:17:35 -0700 |
commit | 059a188d0dd7162315c1e15b8e11d1db8bf3e832 (patch) | |
tree | 50cb7cf60e92dccf6109fdb860a47174b95fe07d /sys_util | |
parent | 7621d910f56ff85400b252f88fdef324a1cc13d6 (diff) | |
download | crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar.gz crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar.bz2 crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar.lz crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar.xz crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.tar.zst crosvm-059a188d0dd7162315c1e15b8e11d1db8bf3e832.zip |
Arch: Big refactor and add an empty PCI bus
When setting up IO, accept an optional PciRoot device to put on the IO bus. For aarch64, it's currently ignored. For x86_64, it will be added at 0xcf8. break up mmio device creation and registration Moving forward registration will be handled by the architecture specific code. However, creation will be handled by the common code. To make that easier split up the two steps so a list of devices is created, then each is registered later. Start moving to a model where the configuration generates a set of components that are passed to the architecture. The architecture will crate a VM from the components. Break up the big run_config function and move architecture specific parts to the various architectures. This doesn't refactor the function calls each architecture makes, but moves the setup flow in to the arch impls so that they can diverge in the future. Change-Id: I5b10d092896606796dc0c9afc5e34a1b288b867b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1099860 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/src/lib.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sys_util/src/lib.rs b/sys_util/src/lib.rs index c8f38de..55861af 100644 --- a/sys_util/src/lib.rs +++ b/sys_util/src/lib.rs @@ -63,8 +63,9 @@ pub use signalfd::Error as SignalFdError; pub use write_zeroes::WriteZeroes as WriteZeroes; use std::ffi::CStr; -use std::fs::File; +use std::fs::{File, remove_file}; use std::os::unix::io::{AsRawFd, FromRawFd}; +use std::os::unix::net::UnixDatagram; use std::ptr; use libc::{kill, syscall, sysconf, waitpid, pipe2, c_long, pid_t, uid_t, gid_t, _SC_PAGESIZE, @@ -271,3 +272,23 @@ pub fn pipe(close_on_exec: bool) -> Result<(File, File)> { }) } } + +/// Used to attempt to clean up a named pipe after it is no longer used. +pub struct UnlinkUnixDatagram(pub UnixDatagram); +impl AsRef<UnixDatagram> for UnlinkUnixDatagram { + fn as_ref(&self) -> &UnixDatagram { + &self.0 + } +} +impl Drop for UnlinkUnixDatagram { + fn drop(&mut self) { + if let Ok(addr) = self.0.local_addr() { + if let Some(path) = addr.as_pathname() { + if let Err(e) = remove_file(path) { + warn!("failed to remove control socket file: {:?}", e); + } + } + } + } +} + |