Skip to content

Commit fd0673a

Browse files
authored
openvmm_entry: shut down mesh cleanly on worker launch failure (microsoft#3299)
When the worker fails to launch, the VmmMesh was dropped without calling shutdown(), causing the child mesh host process to spew connection-reset errors and span-close logs to stderr after the actual error message. Ensure mesh.shutdown() is always called on the error path so the user sees a clean error and nothing else.
1 parent f9d66a7 commit fd0673a

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

  • openvmm/openvmm_entry/src

openvmm/openvmm_entry/src/lib.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,10 +2064,7 @@ fn do_main(pidfile_path: &mut Option<PathBuf>) -> anyhow::Result<()> {
20642064
});
20652065
}
20662066

2067-
DefaultPool::run_with(async |driver| {
2068-
let mesh = VmmMesh::new(&driver, opt.single_process)?;
2069-
run_control(&driver, mesh, opt).await
2070-
})
2067+
DefaultPool::run_with(async |driver| run_control(&driver, opt).await)
20712068
}
20722069

20732070
fn new_hvsock_service_id(port: u32) -> Guid {
@@ -2079,8 +2076,24 @@ fn new_hvsock_service_id(port: u32) -> Guid {
20792076
}
20802077
}
20812078

2082-
async fn run_control(driver: &DefaultDriver, mesh: VmmMesh, opt: Options) -> anyhow::Result<()> {
2083-
let (mut vm_config, mut resources) = vm_config_from_command_line(driver, &mesh, &opt).await?;
2079+
async fn run_control(driver: &DefaultDriver, opt: Options) -> anyhow::Result<()> {
2080+
let mut mesh = Some(VmmMesh::new(&driver, opt.single_process)?);
2081+
let result = run_control_inner(driver, &mut mesh, opt).await;
2082+
// If setup failed before the mesh was handed to the controller, shut it
2083+
// down so the child host process exits cleanly without noisy logs.
2084+
if let Some(mesh) = mesh {
2085+
mesh.shutdown().await;
2086+
}
2087+
result
2088+
}
2089+
2090+
async fn run_control_inner(
2091+
driver: &DefaultDriver,
2092+
mesh_slot: &mut Option<VmmMesh>,
2093+
opt: Options,
2094+
) -> anyhow::Result<()> {
2095+
let mesh = mesh_slot.as_ref().unwrap();
2096+
let (mut vm_config, mut resources) = vm_config_from_command_line(driver, mesh, &opt).await?;
20842097

20852098
let mut vnc_worker = None;
20862099
if opt.gfx || opt.vnc {
@@ -2215,7 +2228,7 @@ async fn run_control(driver: &DefaultDriver, mesh: VmmMesh, opt: Options) -> any
22152228

22162229
// Build the VmController with exclusive resources.
22172230
let controller = vm_controller::VmController {
2218-
mesh,
2231+
mesh: mesh_slot.take().unwrap(),
22192232
vm_worker,
22202233
vnc_worker,
22212234
gdb_worker,

0 commit comments

Comments
 (0)