@@ -16,7 +16,7 @@ use std::{fmt, io, thread};
16
16
use kvm_bindings:: { KVM_SYSTEM_EVENT_RESET , KVM_SYSTEM_EVENT_SHUTDOWN } ;
17
17
use kvm_ioctls:: VcpuExit ;
18
18
use libc:: { c_int, c_void, siginfo_t} ;
19
- use log:: { error, info} ;
19
+ use log:: { error, info, warn } ;
20
20
use seccompiler:: { BpfProgram , BpfProgramRef } ;
21
21
use utils:: errno;
22
22
use utils:: eventfd:: EventFd ;
@@ -341,6 +341,10 @@ impl Vcpu {
341
341
match self . event_receiver . recv ( ) {
342
342
// Paused ---- Resume ----> Running
343
343
Ok ( VcpuEvent :: Resume ) => {
344
+ if self . kvm_vcpu . fd . get_kvm_run ( ) . immediate_exit == 1u8 {
345
+ warn ! ( "Received a VcpuEvent::Resume message with immediate_exit enabled. immediate_exit was disabled before proceeding" ) ;
346
+ self . kvm_vcpu . fd . set_kvm_immediate_exit ( 0 ) ;
347
+ }
344
348
// Nothing special to do.
345
349
self . response_sender
346
350
. send ( VcpuResponse :: Resumed )
@@ -445,7 +449,12 @@ impl Vcpu {
445
449
/// Runs the vCPU in KVM context and handles the kvm exit reason.
446
450
///
447
451
/// Returns error or enum specifying whether emulation was handled or interrupted.
448
- pub fn run_emulation ( & self ) -> Result < VcpuEmulation , VcpuError > {
452
+ pub fn run_emulation ( & mut self ) -> Result < VcpuEmulation , VcpuError > {
453
+ if self . kvm_vcpu . fd . get_kvm_run ( ) . immediate_exit == 1u8 {
454
+ warn ! ( "Requested a vCPU run with immediate_exit enabled. The operation was skipped" ) ;
455
+ self . kvm_vcpu . fd . set_kvm_immediate_exit ( 0 ) ;
456
+ return Ok ( VcpuEmulation :: Interrupted ) ;
457
+ }
449
458
match self . emulate ( ) {
450
459
Ok ( run) => match run {
451
460
VcpuExit :: MmioRead ( addr, data) => {
0 commit comments