mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 21:21:32 +00:00
feat: guest metrics support (#46)
* feat: initial support for idm send in daemon * feat: implement IdmClient backend support * feat: daemon idm now uses IdmClient * fix: implement channel destruction propagation * feat: implement request response idm system * feat: implement metrics support * proto: move metrics into GuestMetrics for reusability * fix: log level of guest agent was trace * feat: metrics tree with process information
This commit is contained in:
@ -48,7 +48,7 @@ pub struct ChannelService {
|
||||
gnttab: GrantTab,
|
||||
input_receiver: Receiver<(u32, Vec<u8>)>,
|
||||
pub input_sender: Sender<(u32, Vec<u8>)>,
|
||||
output_sender: Sender<(u32, Vec<u8>)>,
|
||||
output_sender: Sender<(u32, Option<Vec<u8>>)>,
|
||||
}
|
||||
|
||||
impl ChannelService {
|
||||
@ -58,7 +58,7 @@ impl ChannelService {
|
||||
) -> Result<(
|
||||
ChannelService,
|
||||
Sender<(u32, Vec<u8>)>,
|
||||
Receiver<(u32, Vec<u8>)>,
|
||||
Receiver<(u32, Option<Vec<u8>>)>,
|
||||
)> {
|
||||
let (input_sender, input_receiver) = channel(GROUPED_CHANNEL_QUEUE_LEN);
|
||||
let (output_sender, output_receiver) = channel(GROUPED_CHANNEL_QUEUE_LEN);
|
||||
@ -203,12 +203,14 @@ pub struct ChannelBackend {
|
||||
pub domid: u32,
|
||||
pub id: u32,
|
||||
pub sender: Sender<Vec<u8>>,
|
||||
raw_sender: Sender<(u32, Option<Vec<u8>>)>,
|
||||
task: JoinHandle<()>,
|
||||
}
|
||||
|
||||
impl Drop for ChannelBackend {
|
||||
fn drop(&mut self) {
|
||||
self.task.abort();
|
||||
let _ = self.raw_sender.try_send((self.domid, None));
|
||||
debug!(
|
||||
"destroyed channel backend for domain {} channel {}",
|
||||
self.domid, self.id
|
||||
@ -226,7 +228,7 @@ impl ChannelBackend {
|
||||
store: XsdClient,
|
||||
evtchn: EventChannel,
|
||||
gnttab: GrantTab,
|
||||
output_sender: Sender<(u32, Vec<u8>)>,
|
||||
output_sender: Sender<(u32, Option<Vec<u8>>)>,
|
||||
use_reserved_ref: Option<u64>,
|
||||
) -> Result<ChannelBackend> {
|
||||
let processor = KrataChannelBackendProcessor {
|
||||
@ -242,11 +244,14 @@ impl ChannelBackend {
|
||||
|
||||
let (input_sender, input_receiver) = channel(SINGLE_CHANNEL_QUEUE_LEN);
|
||||
|
||||
let task = processor.launch(output_sender, input_receiver).await?;
|
||||
let task = processor
|
||||
.launch(output_sender.clone(), input_receiver)
|
||||
.await?;
|
||||
Ok(ChannelBackend {
|
||||
domid,
|
||||
id,
|
||||
task,
|
||||
raw_sender: output_sender,
|
||||
sender: input_sender,
|
||||
})
|
||||
}
|
||||
@ -304,7 +309,7 @@ impl KrataChannelBackendProcessor {
|
||||
|
||||
async fn launch(
|
||||
&self,
|
||||
output_sender: Sender<(u32, Vec<u8>)>,
|
||||
output_sender: Sender<(u32, Option<Vec<u8>>)>,
|
||||
input_receiver: Receiver<Vec<u8>>,
|
||||
) -> Result<JoinHandle<()>> {
|
||||
let owned = self.clone();
|
||||
@ -321,7 +326,7 @@ impl KrataChannelBackendProcessor {
|
||||
|
||||
async fn processor(
|
||||
&self,
|
||||
sender: Sender<(u32, Vec<u8>)>,
|
||||
sender: Sender<(u32, Option<Vec<u8>>)>,
|
||||
mut receiver: Receiver<Vec<u8>>,
|
||||
) -> Result<()> {
|
||||
self.init().await?;
|
||||
@ -396,7 +401,7 @@ impl KrataChannelBackendProcessor {
|
||||
unsafe {
|
||||
let buffer = self.read_output_buffer(channel.local_port, &memory).await?;
|
||||
if !buffer.is_empty() {
|
||||
sender.send((self.domid, buffer)).await?;
|
||||
sender.send((self.domid, Some(buffer))).await?;
|
||||
}
|
||||
};
|
||||
|
||||
@ -466,7 +471,7 @@ impl KrataChannelBackendProcessor {
|
||||
unsafe {
|
||||
let buffer = self.read_output_buffer(channel.local_port, &memory).await?;
|
||||
if !buffer.is_empty() {
|
||||
sender.send((self.domid, buffer)).await?;
|
||||
sender.send((self.domid, Some(buffer))).await?;
|
||||
}
|
||||
};
|
||||
channel.unmask_sender.send(channel.local_port).await?;
|
||||
|
@ -1,18 +0,0 @@
|
||||
use anyhow::Result;
|
||||
use tokio::fs::File;
|
||||
|
||||
pub struct XenConsole {
|
||||
pub read_handle: File,
|
||||
pub write_handle: File,
|
||||
}
|
||||
|
||||
impl XenConsole {
|
||||
pub async fn new(tty: &str) -> Result<XenConsole> {
|
||||
let read_handle = File::options().read(true).write(false).open(tty).await?;
|
||||
let write_handle = File::options().read(false).write(true).open(tty).await?;
|
||||
Ok(XenConsole {
|
||||
read_handle,
|
||||
write_handle,
|
||||
})
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ use xenstore::{XsdClient, XsdInterface};
|
||||
|
||||
use self::{
|
||||
autoloop::AutoLoop,
|
||||
console::XenConsole,
|
||||
launch::{GuestLaunchRequest, GuestLauncher},
|
||||
};
|
||||
use krataoci::cache::ImageCache;
|
||||
@ -23,7 +22,6 @@ use krataoci::cache::ImageCache;
|
||||
pub mod autoloop;
|
||||
pub mod cfgblk;
|
||||
pub mod channel;
|
||||
pub mod console;
|
||||
pub mod launch;
|
||||
|
||||
pub struct GuestLoopInfo {
|
||||
@ -321,17 +319,6 @@ impl Runtime {
|
||||
Ok(uuid)
|
||||
}
|
||||
|
||||
pub async fn console(&self, uuid: Uuid) -> Result<XenConsole> {
|
||||
let info = self
|
||||
.context
|
||||
.resolve(uuid)
|
||||
.await?
|
||||
.ok_or_else(|| anyhow!("unable to resolve guest: {}", uuid))?;
|
||||
let domid = info.domid;
|
||||
let tty = self.context.xen.get_console_path(domid).await?;
|
||||
XenConsole::new(&tty).await
|
||||
}
|
||||
|
||||
pub async fn list(&self) -> Result<Vec<GuestInfo>> {
|
||||
self.context.list().await
|
||||
}
|
||||
|
Reference in New Issue
Block a user