Skip to content

Commit

Permalink
migtd: provide individual APIs in GHCI implementation
Browse files Browse the repository at this point in the history
Remove the state machine of MigrationSession and exposing several
individual APIs of GHCI.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Mar 26, 2024
1 parent d146053 commit 01b18ac
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 339 deletions.
14 changes: 6 additions & 8 deletions src/migtd/src/bin/migtd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
extern crate alloc;

use log::info;
use migtd::migration::{session::MigrationSession, MigrationResult};
use migtd::migration::session::{migrate, query, report_status, wait_for_request};
use migtd::migration::MigrationResult;
use migtd::{config, event_log, migration};

const MIGTD_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -88,29 +89,26 @@ fn get_ca_and_measure(event_log: &mut [u8]) {
fn handle_pre_mig() {
migration::event::register_callback();
// Query the capability of VMM
if MigrationSession::query().is_err() {
if query().is_err() {
panic!("Migration is not supported by VMM");
}
// Loop to wait for request
info!("Loop to wait for request");
loop {
let mut session = MigrationSession::new();
if session.wait_for_request().is_ok() {
if let Ok(info) = wait_for_request() {
#[cfg(feature = "vmcall-vsock")]
{
// Safe to unwrap because we have got the request information
let info = session.info().unwrap();
migtd::driver::vsock::vmcall_vsock_device_init(
info.mig_info.mig_request_id,
info.mig_socket_info.mig_td_cid,
);
}

let status = session
.op()
let status = migrate(&info)
.map(|_| MigrationResult::Success)
.unwrap_or_else(|e| e);
let _ = session.report_status(status as u8);
let _ = report_status(&info, status as u8);
#[cfg(all(feature = "coverage", feature = "tdx"))]
{
const MAX_COVERAGE_DATA_PAGE_COUNT: usize = 0x200;
Expand Down
Loading

0 comments on commit 01b18ac

Please sign in to comment.