MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / send_migration_socket

Function send_migration_socket

vmm/src/migration_transport.rs:788–809  ·  view source on GitHub ↗

Connect to a migration endpoint and return the established stream.

(
    destination_url: &str,
)

Source from the content-addressed store, hash-verified

786
787/// Connect to a migration endpoint and return the established stream.
788pub(crate) fn send_migration_socket(
789 destination_url: &str,
790) -> Result<SocketStream, MigratableError> {
791 if let Some(address) = destination_url.strip_prefix("tcp:") {
792 info!("Connecting to TCP socket at {address}");
793
794 let socket = TcpStream::connect(address).map_err(|e| {
795 MigratableError::MigrateSend(anyhow!("Error connecting to TCP socket: {e}"))
796 })?;
797
798 Ok(SocketStream::Tcp(socket))
799 } else {
800 let path = socket_url_to_path(destination_url).map_err(MigratableError::MigrateSend)?;
801 info!("Connecting to UNIX socket at {path:?}");
802
803 let socket = UnixStream::connect(&path).map_err(|e| {
804 MigratableError::MigrateSend(anyhow!("Error connecting to UNIX socket: {e}"))
805 })?;
806
807 Ok(SocketStream::Unix(socket))
808 }
809}
810
811/// Bind a migration listener for the receiver side.
812pub(crate) fn receive_migration_listener(

Callers 2

send_migrationMethod · 0.85
newMethod · 0.85

Calls 1

socket_url_to_pathFunction · 0.85

Tested by

no test coverage detected