summaryrefslogtreecommitdiffstats
path: root/meta-egvirt/recipes-extended/vhost-device-console/vhost-device-console-0.1.0/src/console.rs
blob: 079fe0cb04eb33e975ed559ec1e26a752f025f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Console backend device
//
// 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 crate::virtio_console::VirtioConsoleConfig;
use clap::ValueEnum;
use log::trace;

#[derive(ValueEnum, Clone, Copy, Default, Debug, Eq, PartialEq)]
pub enum BackendType {
    #[default]
    Nested,
    Network,
}

#[derive(Debug)]
pub(crate) struct ConsoleController {
    config: VirtioConsoleConfig,
    pub backend: BackendType,
    pub exit: bool,
}

impl 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(),
            },
            backend,
            exit: false,
        }
    }

    pub(crate) fn config(&self) -> &VirtioConsoleConfig {
        trace!("Get config\n");
        &self.config
    }
}