vmm, main: Optionalise creation of API server

Only if we have a valid API server path then create the API server. For
now this has no functional change there is a default API server path in
the clap handling but rather prepares to do so optionally.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-03-16 18:26:10 +00:00
parent f685f0e0b2
commit 9b0996a71f
2 changed files with 16 additions and 15 deletions

View File

@@ -245,7 +245,7 @@ impl Serialize for PciDeviceInfo {
pub fn start_vmm_thread(
vmm_version: String,
http_path: &str,
http_path: &Option<String>,
api_event: EventFd,
api_sender: Sender<ApiRequest>,
api_receiver: Receiver<ApiRequest>,
@@ -276,9 +276,10 @@ pub fn start_vmm_thread(
})
.map_err(Error::VmmThreadSpawn)?;
// The VMM thread is started, we can start serving HTTP requests
api::start_http_thread(http_path, http_api_event, api_sender, seccomp_action)?;
if let Some(http_path) = http_path {
// The VMM thread is started, we can start serving HTTP requests
api::start_http_thread(http_path, http_api_event, api_sender, seccomp_action)?;
}
Ok(thread)
}