2024-02-13 19:48:49 +00:00
|
|
|
use anyhow::{anyhow, Result};
|
2024-02-23 03:25:06 +00:00
|
|
|
|
|
|
|
|
use crate::console::XenConsole;
|
2024-02-13 19:48:49 +00:00
|
|
|
|
|
|
|
|
use super::ControllerContext;
|
|
|
|
|
|
|
|
|
|
pub struct ControllerConsole<'a> {
|
|
|
|
|
context: &'a mut ControllerContext,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ControllerConsole<'_> {
|
|
|
|
|
pub fn new(context: &mut ControllerContext) -> ControllerConsole<'_> {
|
|
|
|
|
ControllerConsole { context }
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 03:25:06 +00:00
|
|
|
pub async fn perform(&mut self, id: &str) -> Result<()> {
|
2024-02-13 19:48:49 +00:00
|
|
|
let info = self
|
|
|
|
|
.context
|
|
|
|
|
.resolve(id)?
|
|
|
|
|
.ok_or_else(|| anyhow!("unable to resolve container: {}", id))?;
|
|
|
|
|
let domid = info.domid;
|
2024-02-23 03:25:06 +00:00
|
|
|
let tty = self.context.xen.get_console_path(domid)?;
|
|
|
|
|
let console = XenConsole::new(&tty).await?;
|
|
|
|
|
console.attach().await?;
|
|
|
|
|
Ok(())
|
2024-02-13 19:48:49 +00:00
|
|
|
}
|
|
|
|
|
}
|