
On Thu, Jun 28, 2012 at 05:21:57PM +0800, Dennis Chen wrote:
All,
These days I am trying to understand the interaction relationship between the libvirt and KVM kernel module, eg. kvm_intel.ko.
We know that KVM kernel module expose an entry in form of device file "/dev/kvm" which can be accessed by user space application to control, for example, create a VM using KVM_CREATE_VM with help of ioctl.
Now let's say the tool virsh based upon libvirt, we can create a guest domain with the command looks like: #virsh create guest.xml Obviously, the above command will create a VM. But when I try to investigate the libvirt code, I can't find any code play with the "/dev/kvm" to send KVM_CREATE_VM ioctl code to KVM kernel module. But I do found that the reference count of the kvm_intel.ko changed before the virsh create command launched and after.
So my question is: how does the libvirt interaction with KVM to create a VM? Anybody can give me some tips about that, eg, the corresponding codes in libvirt?
The '/dev/kvm' device is the low level kernel interface for creating virtual domains. This is not actually used by libvirt at all. The QEMU binary has code that talks to /dev/kvm, so all libvirt does is to spawn a QEMU process which in turns creates the virtual machine All the libvirt code for this part is under $GIT/src/qemu/ in particular the qemu_command.c and qemu_process.c files Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|