vmm: api: include BUILD_VERSION and CH pid in VmmPingResponse

Signed-off-by: Omer Faruk Bayram <omer.faruk@sartura.hr>
This commit is contained in:
Omer Faruk Bayram 2023-04-07 11:22:08 +03:00 committed by Bo Chen
parent 59012ccc6e
commit 346ee09e6b
4 changed files with 36 additions and 7 deletions

View File

@ -511,7 +511,7 @@ fn start_vmm(toplevel: TopLevel) -> Result<Option<String>, Error> {
let vm_debug_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateDebugEventFd)?;
let vmm_thread = vmm::start_vmm_thread(
env!("CARGO_PKG_VERSION").to_string(),
vmm::VmmVersionInfo::new(env!("BUILD_VERSION"), env!("CARGO_PKG_VERSION")),
&api_socket_path,
api_socket_fd,
api_evt.try_clone().unwrap(),

View File

@ -165,7 +165,9 @@ pub struct VmInfo {
#[derive(Clone, Deserialize, Serialize)]
pub struct VmmPingResponse {
pub build_version: String,
pub version: String,
pub pid: i64,
}
#[derive(Clone, Deserialize, Serialize, Default, Debug)]

View File

@ -438,8 +438,13 @@ components:
- version
type: object
properties:
build_version:
type: string
version:
type: string
pid:
type: integer
format: int64
description: Virtual Machine Monitor information
VmInfo:

View File

@ -281,7 +281,7 @@ impl Serialize for PciDeviceInfo {
#[allow(unused_variables)]
#[allow(clippy::too_many_arguments)]
pub fn start_vmm_thread(
vmm_version: String,
vmm_version: VmmVersionInfo,
http_path: &Option<String>,
http_fd: Option<RawFd>,
api_event: EventFd,
@ -322,7 +322,7 @@ pub fn start_vmm_thread(
}
let mut vmm = Vmm::new(
vmm_version.to_string(),
vmm_version,
api_event,
#[cfg(feature = "guest_debug")]
debug_event,
@ -390,6 +390,21 @@ struct VmMigrationConfig {
memory_manager_data: MemoryManagerSnapshotData,
}
#[derive(Debug, Clone)]
pub struct VmmVersionInfo {
pub build_version: String,
pub version: String,
}
impl VmmVersionInfo {
pub fn new(build_version: &str, version: &str) -> Self {
Self {
build_version: build_version.to_owned(),
version: version.to_owned(),
}
}
}
pub struct Vmm {
epoll: EpollContext,
exit_evt: EventFd,
@ -399,7 +414,7 @@ pub struct Vmm {
debug_evt: EventFd,
#[cfg(feature = "guest_debug")]
vm_debug_evt: EventFd,
version: String,
version: VmmVersionInfo,
vm: Option<Vm>,
vm_config: Option<Arc<Mutex<VmConfig>>>,
seccomp_action: SeccompAction,
@ -482,7 +497,7 @@ impl Vmm {
}
fn new(
vmm_version: String,
vmm_version: VmmVersionInfo,
api_evt: EventFd,
#[cfg(feature = "guest_debug")] debug_evt: EventFd,
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
@ -802,8 +817,15 @@ impl Vmm {
}
fn vmm_ping(&self) -> VmmPingResponse {
let VmmVersionInfo {
build_version,
version,
} = self.version.clone();
VmmPingResponse {
version: self.version.clone(),
build_version,
version,
pid: std::process::id() as i64,
}
}
@ -2057,7 +2079,7 @@ mod unit_tests {
fn create_dummy_vmm() -> Vmm {
Vmm::new(
"dummy".to_string(),
VmmVersionInfo::new("dummy", "dummy"),
EventFd::new(EFD_NONBLOCK).unwrap(),
#[cfg(feature = "guest_debug")]
EventFd::new(EFD_NONBLOCK).unwrap(),