Some questions from a freshman to this community
Hi all,
I am freshman to this community, I have some questions roughly about how does KVM work, please help me answer these questions, thank you!
1, What is the relation between kvm-mod and kvm-qemu?
Is kvm-qemu mainly used to emulate the first initial 16-bit code of a guest, then this qemu context will be replaced by the real guest, such as linux, windows? But I also see some emulation code in kvm-mod, what are these code used for?
2, How to handle irqs in kvm-mod?
I found vmx_inject_irq is used to inject an interrupt to a guest by writing vmcs for a guest, initialized by this call trace: vmx_init -> kvm_init -> kvm_arch_init (kvm_x86_ops is assigned in this call), then kvm_x86_ops will be used everywhere to set_irq for guests. Am I right?
But I seems to me that vmx_inject_irq is only called by .unlocked_ioctl in kvm_vcpu_fops file_operation struct, where could we use this file operation? If a device wants to issue an interrupt to a guest, how does this happen in device driver?
3, APIC.
I see that each vcpu has a local apic (vcpu.arch->apic), and some functions use this area ranged by this apic pointer to do setting and reading. Is this used to emulate apic for each vcpu? If so, when and where this will be used by guests?
4, The relation between kvm_vcpu_arch and vmcs.
There are some regular registers in kvm_vcpu_arch, and the values for these registers also be used to read and write. I am confused about this, if we want to read/write a register for a guest, we don't directly use those values in vmcs??
Regards,
Zhengwang
Hi guys,
Could you guys kindly help me answer these questions below? This is very helpful for me to learn kvm. Thanks! :-)
Regards,
Zhengwang
-------- Original Message --------
From: Zhengwang Ruan
Sent: 2012年06月26日 星期二 10时16分49秒
To: kvm
Subject: Some questions from a freshman to this community
Quoted 27 lines
Hi all,
I am freshman to this community, I have some questions roughly about how does KVM work, please help me answer these questions, thank you!
1, What is the relation between kvm-mod and kvm-qemu?
Is kvm-qemu mainly used to emulate the first initial 16-bit code of a guest, then this qemu context will be replaced by the real guest, such as linux, windows? But I also see some emulation code in kvm-mod, what are these code used for?
2, How to handle irqs in kvm-mod?
I found
vmx_inject_irqis used to inject an interrupt to a guest by writing vmcs for a guest, initialized by this call trace:vmx_init->kvm_init->kvm_arch_init(kvm_x86_opsis assigned in this call), thenkvm_x86_opswill be used everywhere toset_irqfor guests. Am I right?But I seems to me that
vmx_inject_irqis only called by .unlocked_ioctl inkvm_vcpu_fopsfile_operationstruct, where could we use this file operation? If a device wants to issue an interrupt to a guest, how does this happen in device driver?3, APIC.
I see that each vcpu has a local apic (
vcpu.arch->apic), and some functions use this area ranged by this apic pointer to do setting and reading. Is this used to emulate apic for each vcpu? If so, when and where this will be used by guests?4, The relation between
kvm_vcpu_archand vmcs.There are some regular registers in
kvm_vcpu_arch, and the values for these registers also be used to read and write. I am confused about this, if we want to read/write a register for a guest, we don't directly use those values in vmcs??Regards,
Zhengwang