From 76d6d28f3ecc202b4f501c4bdacf11fbe87115ec Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 27 Feb 2023 20:07:07 +0800 Subject: [PATCH] vmm: do not start signal thread to resize console if no need Now cloud hypervisor will start signal thread to catch SIGWINCH signal, cloud hypervisor then will resize the guest console via vconsole. This patch skip starting signal thread when there is no need to resize guest console, such as console is not configured. Signed-off-by: Yong He --- vmm/src/device_manager.rs | 8 ++++++++ vmm/src/vm.rs | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 76ca37759..f5b98a308 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -530,6 +530,14 @@ pub struct Console { } impl Console { + pub fn need_resize(&self) -> bool { + if let Some(_resizer) = self.console_resizer.as_ref() { + return true; + } + + false + } + pub fn update_console_size(&self) { if let Some(resizer) = self.console_resizer.as_ref() { resizer.update_console_size() diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 214173093..f3c64d50c 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1943,6 +1943,11 @@ impl Vm { fn setup_signal_handler(&mut self) -> Result<()> { let console = self.device_manager.lock().unwrap().console().clone(); let signals = Signals::new(Vm::HANDLED_SIGNALS); + + if !console.need_resize() { + return Ok(()); + } + match signals { Ok(signals) => { self.signals = Some(signals.handle());