Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions vmm/rpc/proto/vmm_rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ message VmInfo {
string shutdown_progress = 12;
// Image version
string image_version = 13;
// Events
repeated GuestEvent events = 14;
}

message GuestEvent {
string event = 1;
string body = 2;
// Timestamp in milliseconds since Unix epoch
uint64 timestamp = 3;
}

message Id {
Expand Down
15 changes: 14 additions & 1 deletion vmm/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use id_pool::IdPool;
use ra_rpc::client::RaClient;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::{BTreeSet, HashMap};
use std::collections::{BTreeSet, HashMap, VecDeque};
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, MutexGuard};
use std::time::SystemTime;
use supervisor_client::SupervisorClient;
use tracing::{error, info};

Expand Down Expand Up @@ -411,6 +412,17 @@ impl App {
let Some(vm) = state.vms.values_mut().find(|vm| vm.config.cid == cid) else {
bail!("VM not found");
};
vm.state.events.push_back(pb::GuestEvent {
event: event.into(),
body: body.clone(),
timestamp: SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap_or_default()
.as_millis() as u64,
});
while vm.state.events.len() > self.config.event_buffer_size {
vm.state.events.pop_front();
}
match event {
"boot.progress" => {
vm.state.boot_progress = body;
Expand Down Expand Up @@ -648,6 +660,7 @@ struct VmStateMut {
boot_error: String,
shutdown_progress: String,
devices: GpuConfig,
events: VecDeque<pb::GuestEvent>,
}

impl VmStateMut {
Expand Down
3 changes: 3 additions & 0 deletions vmm/src/app/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct VmInfo {
pub shutdown_progress: String,
pub image_version: String,
pub gateway_enabled: bool,
pub events: Vec<pb::GuestEvent>,
}

#[derive(Debug, Builder)]
Expand Down Expand Up @@ -177,6 +178,7 @@ impl VmInfo {
app_id: self.manifest.app_id.clone(),
instance_id: self.instance_id.as_deref().map(Into::into),
exited_at: self.exited_at.clone(),
events: self.events.clone(),
}
}
}
Expand Down Expand Up @@ -222,6 +224,7 @@ impl VmState {
shutdown_progress: self.state.shutdown_progress.clone(),
image_version: self.config.image.info.version.clone(),
gateway_enabled: self.config.gateway_enabled,
events: self.state.events.clone().into(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions vmm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ pub struct Config {
#[serde(default)]
pub node_name: String,

/// The buffer size in VMM process for guest events
pub event_buffer_size: usize,

/// CVM configuration
pub cvm: CvmConfig,
/// Gateway configuration
Expand Down
1 change: 1 addition & 0 deletions vmm/vmm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ log_level = "debug"
address = "unix:./vmm.sock"
reuse = true
kms_url = "http://127.0.0.1:8081"
event_buffer_size = 20

[cvm]
qemu_path = ""
Expand Down
Loading