First, in Qemu, QEMU Process order "kvm-vcpu" to run like this

first,  x86_cpu_realizefn calls qemu_init_vcpu , in qemu/target-i386/cpu.c

2) qemu_init_vcpu calls qemu_kvm_start_vcpu , in cpus.c

3) qemu_kvm_start_vpuc calls qemu_kvm_cpu_thread_fn through creating thread, in cpus.c

4) qemu_kvm_cpu_thread_fn calls kvm_init_vcpu to initialize kvm_vcpu and then calls kvm_cpu_exec, in cpus.c

5) kvm_cpu_exec calls kvm_vpuc_ioctl for running vcpu stored in kvm-vcpu file.

 

then, in linux kernel, KVM modules get an order to run "vcpu" through "kvm-vcpu" anonymous file. so, called

1) kvm_vcpu_ioctl through ioctl function for kvm-vcpu is file operation "kvm_vcpu_fops" , in /virt/kvm/kvm_main.c

2) kvm_vcpu_ioctl calls kvm_arch_vcpu_ioctl_run , in /virt/kvm/kvm_main.c

3) kvm_arch_vcpc_ioctl_run calls __vcpu_run , in /arch/x86/kvm/x86.c

4) __vcpu_run calls vcpu_enter_guest , in /arch/x86/kvm/x86.c ( and while loop calls vcpu_enter_guest until return value is equal or more than zero)

5) vcpu_enter_guest calls x86 operations for VM already initialized when launching kvm modules, and also calls kvm_guest_enter and  kvm_x86_ops->run , in /arch/x86/kvm/x86.c

Posted by MeatNBrew
l