Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migtd: provide individual APIs in GHCI implementation #197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading