diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2020-03-25 13:54:50 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-23 07:17:58 +0000 |
commit | b865810340f1b264b407137c4e69ad232194cc5e (patch) | |
tree | 49bb7d6e14d315a21fdd5c8e1365ddfebf3e5b80 /arch | |
parent | e538d5216fe1ec0f9755e1550cd7e67304653982 (diff) | |
download | crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar.gz crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar.bz2 crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar.lz crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar.xz crosvm-b865810340f1b264b407137c4e69ad232194cc5e.tar.zst crosvm-b865810340f1b264b407137c4e69ad232194cc5e.zip |
devices: add SerialDevice trait
This will be used to allow generic code to create serial devices as well as virtio-console devices. Also remove the new_in_out, new_out, and new_sink constructors for Serial and Console, since they are not used anywhere. BUG=chromium:1059924 TEST=cargo build Change-Id: I76da343e347aed36dabd3aa0541acf24c64fe122 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127321 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/src/serial.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/src/serial.rs b/arch/src/serial.rs index c0e27dc..3892c64 100644 --- a/arch/src/serial.rs +++ b/arch/src/serial.rs @@ -11,7 +11,7 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -use devices::{Bus, ProxyDevice, Serial}; +use devices::{Bus, ProxyDevice, Serial, SerialDevice}; use io_jail::Minijail; use sync::Mutex; use sys_util::{read_raw_stdin, syslog, EventFd}; @@ -97,11 +97,11 @@ impl SerialParameters { /// * `evt_fd` - eventfd used for interrupt events /// * `keep_fds` - Vector of FDs required by this device if it were sandboxed in a child /// process. `evt_fd` will always be added to this vector by this function. - pub fn create_serial_device( + pub fn create_serial_device<T: SerialDevice>( &self, evt_fd: &EventFd, keep_fds: &mut Vec<RawFd>, - ) -> std::result::Result<Serial, Error> { + ) -> std::result::Result<T, Error> { let evt_fd = evt_fd.try_clone().map_err(Error::CloneEventFd)?; keep_fds.push(evt_fd.as_raw_fd()); let input: Option<Box<dyn io::Read + Send>> = if let Some(input_path) = &self.input { @@ -145,7 +145,7 @@ impl SerialParameters { }, SerialType::UnixSocket => return Err(Error::Unimplemented(SerialType::UnixSocket)), }; - Ok(Serial::new(evt_fd, input, output)) + Ok(T::new(evt_fd, input, output, keep_fds.to_vec())) } } @@ -240,7 +240,7 @@ pub fn add_serial_devices( let mut preserved_fds = Vec::new(); let com = param - .create_serial_device(&com_evt, &mut preserved_fds) + .create_serial_device::<Serial>(&com_evt, &mut preserved_fds) .map_err(DeviceRegistrationError::CreateSerialDevice)?; match serial_jail.as_ref() { |