How to emulate a device in kvm

I know that qemu-kvm emulates a device in KVM. Is qemu-kvm running in host user space? Therefore, when the kick function is encountered, it leaves the VM through the hypercall to the hypervisor, then the hypervisor passes qemu-kvm to the host space. Then, after doing the necessary things, qemu-kvm goes to the hypervisor, and then the hypervisor goes back to the virtual machine. So this means that there are two system calls: one from VM → Hypervisor and qemu-kvm → Hypervisor? Are these steps what is happening, or am I mistaken? If there is any documentation about such things, please give me a link. Thank you very much.

Thanks Bala

+3
source share
4 answers

I'm more familiar with the KVM part working on the x86 architecture, so try to explain this in the KVM x86 implementation.

In the x86 architecture, KVM uses CPU functions to separate the hypervisor and the guest mode. In terms of Intel, they are the root and non-root modes of VMX, respectively.

Writing to the VM (hypervisor → VM) is started by the KVM using the VMLAUNCH instruction with all the necessary information for the user filled in the VMCS CPU in kernel mode. Only a system call is invoked from qemu-kvm to the kvm kernel module.

VM , - , , HW . VM, CPU root . , VM (VM → ) HW, VMCS. KVM VMCS, . VM → .

, qemu-kvm qemu. , Intel VT-d, IOMMU . , .

, (Intel VT-x), linux/arch/x86/kvm/vmx.c. Intel VT.

+2

. , . , .

+1

qemu-kvm ? , , . PCI SR-IOV NIC NPIV . , -, KVM/qemu .

, , : VM → Hypervisor qemu-kvm → Hypervisor? , , , , .

, :

http://www.linux-kvm.org/wiki/images/4/42/Kvm-device-assignment.pdf

0

Source: https://habr.com/ru/post/1751912/


All Articles