From ad128bf72d5457ce21370ac115393ddc84c6cf26 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 30 Aug 2019 18:24:01 +0100 Subject: [PATCH] vmm: Give vCPU and signal handler thread useful names Sadly only the first few characters of the thread name is preserved so use a shorter name for the vCPU thread for now. Also give the signal handling thread a name. Signed-off-by: Rob Bradford --- vmm/src/vm.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 21319a103..1988d0141 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -222,6 +222,9 @@ pub enum Error { /// Failed to allocate the IOAPIC memory range. IoapicRangeAllocation, + + /// Cannot spawn a signal handler thread + SignalHandlerSpawn(io::Error), } pub type Result = result::Result; @@ -1827,7 +1830,7 @@ impl<'a> Vm<'a> { let reset_evt = self.devices.reset_evt.try_clone().unwrap(); self.vcpus.push( thread::Builder::new() - .name(format!("cloud-hypervisor_vcpu{}", vcpu.id)) + .name(format!("vcpu{}", vcpu.id)) .spawn(move || { unsafe { extern "C" fn handle_signal(_: i32, _: *mut siginfo_t, _: *mut c_void) { @@ -1850,6 +1853,7 @@ impl<'a> Vm<'a> { match vcpu.run() { Err(e) => { error!("VCPU generated error: {:?}", e); + break; } Ok(true) => {} Ok(false) => { @@ -1871,7 +1875,11 @@ impl<'a> Vm<'a> { let signals = Signals::new(&[SIGWINCH]); match signals { Ok(sig) => { - thread::spawn(move || Vm::os_signal_handler(sig, console_input_clone)); + thread::Builder::new() + .name("signal_handler".to_string()) + .spawn(move || Vm::os_signal_handler(sig, console_input_clone)) + .map_err(Error::SignalHandlerSpawn)?; +; } Err(e) => error!("Signal not found {}", e), }