From ff651e0e28016990df34b4ef8354c0892e60eb8e Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 4 Oct 2023 11:20:34 -0700 Subject: [PATCH] vmm: Report enabled features from the '/vmm.ping' endpoint Fixes: #5817 Signed-off-by: Bo Chen --- Cargo.toml | 2 ++ vmm/src/api/mod.rs | 1 + vmm/src/api/openapi/cloud-hypervisor.yaml | 4 ++++ vmm/src/lib.rs | 24 +++++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 0f5750767..59a306782 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,8 @@ serde_json = "1.0.107" test_infra = { path = "test_infra" } wait-timeout = "0.2.0" +# Please adjust `vmm::feature_list()` accordingly when changing the +# feature list below [features] default = ["kvm", "io_uring"] dbus_api = ["zbus", "vmm/dbus_api"] diff --git a/vmm/src/api/mod.rs b/vmm/src/api/mod.rs index 8aac5d3cc..aaae8ee34 100644 --- a/vmm/src/api/mod.rs +++ b/vmm/src/api/mod.rs @@ -171,6 +171,7 @@ pub struct VmmPingResponse { pub build_version: String, pub version: String, pub pid: i64, + pub features: Vec, } #[derive(Clone, Deserialize, Serialize, Default, Debug)] diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index f29404fe5..fc782fbc8 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -445,6 +445,10 @@ components: pid: type: integer format: int64 + features: + type: array + items: + type: string description: Virtual Machine Monitor information VmInfo: diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 02ee347e4..eeee18a6c 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -293,6 +293,29 @@ impl Serialize for PciDeviceInfo { } } +pub fn feature_list() -> Vec { + vec![ + #[cfg(feature = "dbus_api")] + "dbus_api".to_string(), + #[cfg(feature = "dhat-heap")] + "dhat-heap".to_string(), + #[cfg(feature = "guest_debug")] + "guest_debug".to_string(), + #[cfg(feature = "io_uring")] + "io_uring".to_string(), + #[cfg(feature = "kvm")] + "kvm".to_string(), + #[cfg(feature = "mshv")] + "mshv".to_string(), + #[cfg(feature = "sev_snp")] + "sev_snp".to_string(), + #[cfg(feature = "tdx")] + "tdx".to_string(), + #[cfg(feature = "tracing")] + "tracing".to_string(), + ] +} + pub fn start_event_monitor_thread( mut monitor: event_monitor::Monitor, seccomp_action: &SeccompAction, @@ -931,6 +954,7 @@ impl Vmm { build_version, version, pid: std::process::id() as i64, + features: feature_list(), } }