summaryrefslogtreecommitdiffstats
path: root/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs
diff options
context:
space:
mode:
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.rs88
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);
- }
-}
-