crosvm_control: add crosvm_client_resume_vm_full api

The crosvm_client_resume_vm function actually just resumes vcpus of the
VM. This is a little bit counter intuitive, but since crosvm_control
library provide api and abi stable interface, we can't change the
implementation without potentially breaking existing clients. Instead,
this patch adds a new crosvm_client_resume_vm_full function which
performs a "full" resume of the vm.

BUG=b:360102915
TEST=tools/presubmit

Change-Id: I28d9a338f24716a62655ba0f7e2db41c148ca0f8
Signed-off-by: Nikita Ioffe <ioffe@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5999729
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Nikita Ioffe 2024-11-08 19:29:51 +00:00 committed by crosvm LUCI
parent ef672e6039
commit a555cdda96

View file

@ -114,6 +114,9 @@ pub unsafe extern "C" fn crosvm_client_suspend_vm(socket_path: *const c_char) ->
/// Resumes the crosvm instance whose control socket is listening on `socket_path`.
///
/// Note: this function just resumes vcpus of the vm. If you need to perform a full resume, call
/// crosvm_client_resume_vm_full.
///
/// The function returns true on success or false if an error occurred.
///
/// # Safety
@ -133,6 +136,29 @@ pub unsafe extern "C" fn crosvm_client_resume_vm(socket_path: *const c_char) ->
.unwrap_or(false)
}
/// Resumes the crosvm instance whose control socket is listening on `socket_path`.
///
/// Note: unlike crosvm_client_resume_vm, this function resumes both vcpus and devices.
///
/// The function returns true on success or false if an error occurred.
///
/// # Safety
///
/// Function is unsafe due to raw pointer usage - a null pointer could be passed in. Usage of
/// !raw_pointer.is_null() checks should prevent unsafe behavior but the caller should ensure no
/// null pointers are passed.
#[no_mangle]
pub unsafe extern "C" fn crosvm_client_resume_vm_full(socket_path: *const c_char) -> bool {
catch_unwind(|| {
if let Some(socket_path) = validate_socket_path(socket_path) {
vms_request(&VmRequest::ResumeVm, socket_path).is_ok()
} else {
false
}
})
.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 occurred.