Saturday, November 9, 2013

QEMU Source Code Study - KVM_RUN

QEMU Part




Like KVM_VCPU_CREATE(), kvm_cpu_exec() is also called by function "qemu_kvm_cpu_thread_fn(...)". For the execution process of qemu_kvm_cpu_thread_fn(...), please check the KVM_VCPU_CREATE() post.

kvm_vcpu_exec()


kvm_arch_pre_run(cpu, run)

struct kvm_run


KVM Part




kvm_vcpu_ioctl(...)

kvm_arch_vcpu_ioctl(filp, ioctl, arg)

vcpu_enter_guest(kvm_vcpu *vcpu)

vmx_vcpu_run( kvm_vcpu *vcpu)

vmx_handle_exit()

static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu)

Friday, November 1, 2013

QEMU Source Code Study (3) - KVM_CREATE_VCPU

x86_cpu_register_types() ----> type_register_static(&x86_cpu_type_info) ----> TypeInfo x86_cpu_type_info.class_init = x86_cpu_common_class_init ----> x86_cpu_common_class_init(ObjectClass *oc, void *data) ----> dc->realize = x86_cpu_realizefn ----> x86_cpu_realizefn(DeviceState *dev, Error **error) ----> qemu_init_vcpu(cpu) ----> qemu_kvm_start_vcpu(cpu) ----> qemu_thread_create(cpu->thread, qemu_kvm_cpu_thread_fn, cpu) ----> nqemu_kvm_cpu_thread_fn(arg) ----> kvm_cpu_exec(cpu) ----> kvm_vcpu_ioctl(cpu, KVM_RUN, 0);


How to execute these object?


QEMU Part



kvm_init_vcpu(...)


KVM Part



kvm_vm_ioctl()


kvm_vm_ioctl_create_vcpu(kvm, id)


kvm_x86_ops


vmx_create_vcpu