diff options
author | Timos Ampelikiotis <t.ampelikiotis@virtualopensystems.com> | 2024-10-03 11:09:37 +0300 |
---|---|---|
committer | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2024-10-22 12:21:45 +0000 |
commit | d9b03f2d9b945805f56dfe3eb526264c68747d6f (patch) | |
tree | 6fcf0d51d76cdcdd602b8bc2c51d1a7441319d1e /meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs | |
parent | 7dd141f96eb0d7992365e74d34cba80ea5bde3a4 (diff) |
Update vhost-device-console
Bug-AGL: SPEC-4966
Change-Id: I41cbe30549ebe923f8e3000ece072aa66c5e90a9
Signed-off-by: Timos Ampelikiotis <t.ampelikiotis@virtualopensystems.com>
Diffstat (limited to 'meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs')
-rwxr-xr-x[-rw-r--r--] | meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs | 88 |
1 files changed, 23 insertions, 65 deletions
diff --git a/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs b/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs index 2e2972b2..079fe0cb 100644..100755 --- a/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs +++ b/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs @@ -1,86 +1,44 @@ -// CAN backend device +// Console backend device // -// Copyright 2023 VIRTUAL OPEN SYSTEMS SAS. All Rights Reserved. +// Copyright 2023-2024 VIRTUAL OPEN SYSTEMS SAS. All Rights Reserved. // Timos Ampelikiotis <t.ampelikiotis@virtualopensystems.com> // // SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause -use log::{warn, error}; -use std::sync::{Arc, RwLock}; +use crate::virtio_console::VirtioConsoleConfig; +use clap::ValueEnum; +use log::trace; -use thiserror::Error as ThisError; -use vm_memory::{ByteValued, Le16}; - -use crate::vhu_console::{VirtioConsoleConfig, VirtioConsoleControl}; - -type Result<T> = std::result::Result<T, Error>; - -#[derive(Copy, Clone, Debug, PartialEq, ThisError)] -pub(crate) enum Error { - #[error("Console not enabled yet")] - ConsoleNotEnabled, +#[derive(ValueEnum, Clone, Copy, Default, Debug, Eq, PartialEq)] +pub enum BackendType { + #[default] + Nested, + Network, } #[derive(Debug)] pub(crate) struct ConsoleController { config: VirtioConsoleConfig, - pub console_name: String, + pub backend: BackendType, + pub exit: bool, } impl ConsoleController { - // Creates a new controller corresponding to `device`. - pub(crate) fn new(console_name: String) -> Result<ConsoleController> { - - let console_name = console_name.to_owned(); - println!("console_name: {:?}", console_name); - - Ok(ConsoleController { + pub(crate) fn new(backend: BackendType) -> ConsoleController { + ConsoleController { config: VirtioConsoleConfig { - cols: 20.into(), - rows: 20.into(), - max_nr_ports: 1.into(), - emerg_wr: 64.into(), - }, - console_name, - }) + cols: 20.into(), + rows: 20.into(), + max_nr_ports: 1.into(), + emerg_wr: 64.into(), + }, + backend, + exit: false, + } } pub(crate) fn config(&self) -> &VirtioConsoleConfig { - log::trace!("Get config\n"); + trace!("Get config\n"); &self.config } - - pub(crate) fn operation(&self, tx_request: VirtioConsoleControl) -> Result<()> { - log::trace!("Console operation\n"); - Ok(()) - } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_new_console_controller() { - let console_name = String::from("test_console"); - let controller = ConsoleController::new(console_name.clone()); - - assert!(controller.is_ok()); - - let controller = controller.unwrap(); - assert_eq!(controller.console_name, "test_console"); - } - - #[test] - fn test_console_controller_config() { - let console_name = String::from("test_console"); - let controller = ConsoleController::new(console_name).unwrap(); - - let config = controller.config(); - assert_eq!(config.cols, 20); - assert_eq!(config.rows, 20); - assert_eq!(config.max_nr_ports, 1); - assert_eq!(config.emerg_wr, 64); - } -} - |