From 299c1121c3f70d2143c08271b1c85a00f381cc83 Mon Sep 17 00:00:00 2001 From: Kameron Lutes Date: Mon, 9 May 2022 22:29:09 +0000 Subject: [PATCH] crosvm_control: Add make_rt API Adds a make_rt API to the crosvm_control library. BUG=b:188858559 TEST=cq Change-Id: I3affcd6cb003a17f125b45e78906fabe1e371c43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3635255 Tested-by: kokoro Commit-Queue: Kameron Lutes Reviewed-by: Junichi Uekawa --- crosvm_control/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crosvm_control/src/lib.rs b/crosvm_control/src/lib.rs index 7c709d10fb..8a75357570 100644 --- a/crosvm_control/src/lib.rs +++ b/crosvm_control/src/lib.rs @@ -73,6 +73,21 @@ pub extern "C" fn crosvm_client_resume_vm(socket_path: *const c_char) -> bool { .unwrap_or(false) } +/// Creates an RT vCPU for the crosvm instance whose control socket is listening on `socket_path`. +/// +/// The function returns true on success or false if an error occured. +#[no_mangle] +pub extern "C" fn crosvm_client_make_rt_vm(socket_path: *const c_char) -> bool { + catch_unwind(|| { + if let Some(socket_path) = validate_socket_path(socket_path) { + vms_request(&VmRequest::MakeRT, &socket_path).is_ok() + } else { + false + } + }) + .unwrap_or(false) +} + /// Adjusts the balloon size of the crosvm instance whose control socket is /// listening on `socket_path`. ///