From 06e583c9ab2346a151e63a1d42d8fcf7931de456 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Wed, 11 Jan 2023 09:36:48 -0800 Subject: [PATCH] vmm: move kvm feature gate right before the if condition This change uses the kvm feature gate cleaner way in the handling of PIO/MMIO exits. Signed-off-by: Muminul Islam --- vmm/src/cpu.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index abba3212b..ac0a2b8e4 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -920,15 +920,13 @@ impl CpuManager { // to be executed. #[cfg(feature = "kvm")] - { - if matches!(hypervisor_type, HypervisorType::Kvm) { - vcpu.lock().as_ref().unwrap().vcpu.set_immediate_exit(true); - if !matches!(vcpu.lock().unwrap().run(), Ok(VmExit::Ignore)) { - error!("Unexpected VM exit on \"immediate_exit\" run"); - break; - } - vcpu.lock().as_ref().unwrap().vcpu.set_immediate_exit(false); + if matches!(hypervisor_type, HypervisorType::Kvm) { + vcpu.lock().as_ref().unwrap().vcpu.set_immediate_exit(true); + if !matches!(vcpu.lock().unwrap().run(), Ok(VmExit::Ignore)) { + error!("Unexpected VM exit on \"immediate_exit\" run"); + break; } + vcpu.lock().as_ref().unwrap().vcpu.set_immediate_exit(false); } vcpu_run_interrupted.store(true, Ordering::SeqCst);