mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: move migration modules into folder
On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Bo Chen
parent
7c7a827ded
commit
a56594324c
+1
-1
@@ -55,7 +55,7 @@ pub use self::http::{start_http_fd_thread, start_http_path_thread};
|
|||||||
use crate::Error as VmmError;
|
use crate::Error as VmmError;
|
||||||
use crate::config::RestoreConfig;
|
use crate::config::RestoreConfig;
|
||||||
use crate::device_tree::DeviceTree;
|
use crate::device_tree::DeviceTree;
|
||||||
use crate::migration_transport::{
|
use crate::migration::transport::{
|
||||||
MAX_MIGRATION_CONNECTIONS, TcpAddressParseError, tcp_address_to_server_name,
|
MAX_MIGRATION_CONNECTIONS, TcpAddressParseError, tcp_address_to_server_name,
|
||||||
};
|
};
|
||||||
use crate::vm::{Error as VmError, VmState};
|
use crate::vm::{Error as VmError, VmState};
|
||||||
|
|||||||
+13
-24
@@ -59,11 +59,11 @@ use crate::landlock::Landlock;
|
|||||||
use crate::memory_manager::MemoryManager;
|
use crate::memory_manager::MemoryManager;
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
use crate::migration::get_vm_snapshot;
|
use crate::migration::get_vm_snapshot;
|
||||||
use crate::migration::{recv_vm_config, recv_vm_state};
|
use crate::migration::transport::{
|
||||||
use crate::migration_transport::{
|
self, ReceiveAdditionalConnections, ReceiveListener, SendAdditionalConnections, SocketStream,
|
||||||
ReceiveAdditionalConnections, ReceiveListener, SendAdditionalConnections, SocketStream,
|
|
||||||
};
|
};
|
||||||
use crate::migration_worker::{MigrationWorker, MigrationWorkerHandle, MigrationWorkerResult};
|
use crate::migration::worker::{MigrationWorker, MigrationWorkerHandle, MigrationWorkerResult};
|
||||||
|
use crate::migration::{recv_vm_config, recv_vm_state};
|
||||||
use crate::seccomp_filters::{Thread, get_seccomp_filter};
|
use crate::seccomp_filters::{Thread, get_seccomp_filter};
|
||||||
use crate::vm::{Error as VmError, Vm, VmState};
|
use crate::vm::{Error as VmError, Vm, VmState};
|
||||||
use crate::vm_config::{
|
use crate::vm_config::{
|
||||||
@@ -89,8 +89,6 @@ pub mod interrupt;
|
|||||||
pub mod landlock;
|
pub mod landlock;
|
||||||
pub mod memory_manager;
|
pub mod memory_manager;
|
||||||
pub mod migration;
|
pub mod migration;
|
||||||
pub mod migration_transport;
|
|
||||||
mod migration_worker;
|
|
||||||
mod pci_segment;
|
mod pci_segment;
|
||||||
pub mod seccomp_filters;
|
pub mod seccomp_filters;
|
||||||
mod serial_manager;
|
mod serial_manager;
|
||||||
@@ -1011,11 +1009,7 @@ impl Vmm {
|
|||||||
// When multiple TCP connections are configured, the worker connections carry
|
// When multiple TCP connections are configured, the worker connections carry
|
||||||
// all memory commands and the main connection is used only for control traffic.
|
// all memory commands and the main connection is used only for control traffic.
|
||||||
Command::Memory => {
|
Command::Memory => {
|
||||||
migration_transport::receive_memory_ranges(
|
transport::receive_memory_ranges(&config_data.guest_memory, req, socket)
|
||||||
&config_data.guest_memory,
|
|
||||||
req,
|
|
||||||
socket,
|
|
||||||
)
|
|
||||||
.inspect_err(|_| {
|
.inspect_err(|_| {
|
||||||
// connections.cleanup() already logs all errors that occurred in one of the
|
// connections.cleanup() already logs all errors that occurred in one of the
|
||||||
// threads. Furthermore, this path is only taken in the single-connection case,
|
// threads. Furthermore, this path is only taken in the single-connection case,
|
||||||
@@ -1469,13 +1463,13 @@ impl Vmm {
|
|||||||
let mut ctx = OngoingMigrationContext::new();
|
let mut ctx = OngoingMigrationContext::new();
|
||||||
|
|
||||||
// Set up the socket connection
|
// Set up the socket connection
|
||||||
let mut socket = migration_transport::send_migration_socket(
|
let mut socket = transport::send_migration_socket(
|
||||||
&send_data_migration.destination_url,
|
&send_data_migration.destination_url,
|
||||||
send_data_migration.tls_dir.as_deref(),
|
send_data_migration.tls_dir.as_deref(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Start the migration
|
// Start the migration
|
||||||
migration_transport::send_request_expect_ok(
|
transport::send_request_expect_ok(
|
||||||
&mut socket,
|
&mut socket,
|
||||||
Request::start(),
|
Request::start(),
|
||||||
MigratableError::MigrateSend(anyhow!("Error starting migration")),
|
MigratableError::MigrateSend(anyhow!("Error starting migration")),
|
||||||
@@ -1541,7 +1535,7 @@ impl Vmm {
|
|||||||
common_cpuid,
|
common_cpuid,
|
||||||
memory_manager_data: vm.memory_manager_data(),
|
memory_manager_data: vm.memory_manager_data(),
|
||||||
};
|
};
|
||||||
migration_transport::send_config(&mut socket, &vm_migration_config)?;
|
transport::send_config(&mut socket, &vm_migration_config)?;
|
||||||
|
|
||||||
// Let every Migratable object know about the migration being started.
|
// Let every Migratable object know about the migration being started.
|
||||||
vm.start_migration()?;
|
vm.start_migration()?;
|
||||||
@@ -1559,7 +1553,7 @@ impl Vmm {
|
|||||||
)
|
)
|
||||||
.expect("migration context should transition to VmPaused for local migration");
|
.expect("migration context should transition to VmPaused for local migration");
|
||||||
} else {
|
} else {
|
||||||
let mut mem_send = migration_transport::SendAdditionalConnections::new(
|
let mut mem_send = transport::SendAdditionalConnections::new(
|
||||||
&send_data_migration.destination_url,
|
&send_data_migration.destination_url,
|
||||||
send_data_migration.connections,
|
send_data_migration.connections,
|
||||||
send_data_migration.tls_dir.as_deref(),
|
send_data_migration.tls_dir.as_deref(),
|
||||||
@@ -1596,17 +1590,13 @@ impl Vmm {
|
|||||||
// One final memory iteration to handle side effects from snapshot.
|
// One final memory iteration to handle side effects from snapshot.
|
||||||
if !send_data_migration.local {
|
if !send_data_migration.local {
|
||||||
let memory_ranges = vm.dirty_log()?;
|
let memory_ranges = vm.dirty_log()?;
|
||||||
migration_transport::send_memory_ranges(
|
transport::send_memory_ranges(&vm.guest_memory(), &memory_ranges, &mut socket)?;
|
||||||
&vm.guest_memory(),
|
|
||||||
&memory_ranges,
|
|
||||||
&mut socket,
|
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
Ok(snapshot)
|
Ok(snapshot)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (_, send_snapshot_duration) =
|
let (_, send_snapshot_duration) =
|
||||||
measure_ok(|| migration_transport::send_state(&mut socket, &vm_snapshot))?;
|
measure_ok(|| transport::send_state(&mut socket, &vm_snapshot))?;
|
||||||
|
|
||||||
// Complete the migration.
|
// Complete the migration.
|
||||||
// When this returns, we know the VM was resumed (if it was running
|
// When this returns, we know the VM was resumed (if it was running
|
||||||
@@ -1618,7 +1608,7 @@ impl Vmm {
|
|||||||
Request::complete_paused()
|
Request::complete_paused()
|
||||||
};
|
};
|
||||||
let (_, complete_duration) = measure_ok(|| {
|
let (_, complete_duration) = measure_ok(|| {
|
||||||
migration_transport::send_request_expect_ok(
|
transport::send_request_expect_ok(
|
||||||
&mut socket,
|
&mut socket,
|
||||||
complete_req,
|
complete_req,
|
||||||
MigratableError::MigrateSend(anyhow!("Error completing migration")),
|
MigratableError::MigrateSend(anyhow!("Error completing migration")),
|
||||||
@@ -2788,7 +2778,7 @@ impl RequestHandler for Vmm {
|
|||||||
receive_data_migration.tls_dir.is_some()
|
receive_data_migration.tls_dir.is_some()
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut listener = migration_transport::receive_migration_listener(
|
let mut listener = transport::receive_migration_listener(
|
||||||
&receive_data_migration.receiver_url,
|
&receive_data_migration.receiver_url,
|
||||||
receive_data_migration.tls_dir.as_deref(),
|
receive_data_migration.tls_dir.as_deref(),
|
||||||
)?;
|
)?;
|
||||||
@@ -2798,7 +2788,6 @@ impl RequestHandler for Vmm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event!("vm", "migration-receive-ready");
|
event!("vm", "migration-receive-ready");
|
||||||
|
|
||||||
// Accept the connection and get the socket
|
// Accept the connection and get the socket
|
||||||
let mut socket = listener.accept()?;
|
let mut socket = listener.accept()?;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ use crate::coredump::GuestDebuggableError;
|
|||||||
use crate::vm::VmSnapshot;
|
use crate::vm::VmSnapshot;
|
||||||
use crate::vm_config::VmConfig;
|
use crate::vm_config::VmConfig;
|
||||||
|
|
||||||
|
pub(crate) mod transport;
|
||||||
|
pub(crate) mod worker;
|
||||||
|
|
||||||
pub const SNAPSHOT_STATE_FILE: &str = "state.json";
|
pub const SNAPSHOT_STATE_FILE: &str = "state.json";
|
||||||
pub const SNAPSHOT_CONFIG_FILE: &str = "config.json";
|
pub const SNAPSHOT_CONFIG_FILE: &str = "config.json";
|
||||||
|
|
||||||
Reference in New Issue
Block a user