Re: How does libvirt interaction with KVM to create a VM? | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On 06/28/2012 07:03 PM, Alex Jia wrote:
Yes, I noticed the code above in libvirt, but it's not related with my question in the first message...On 06/28/2012 05:21 PM, 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?http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_driver.c;h=2f934040ea7d996574ac447498a195d440ec0783;hb=HEAD 114 /* device for kvm ioctls */ 115 #define KVM_DEVICE "/dev/kvm" 1022 static int kvmGetMaxVCPUs(void) { 1023 int maxvcpus = 1; 1024 1025 int r, fd; 1026 1027 fd = open(KVM_DEVICE, O_RDONLY); 1028 if (fd< 0) { 1029 virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE); 1030 return -1; 1031 } 1032 1033 r = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS); 1034 if (r> 0) 1035 maxvcpus = r; 1036 1037 VIR_FORCE_CLOSE(fd); 1038 return maxvcpus; 1039 }
I guess the qemuProcessStart() is used to spawn a QEMU process, but seems that lot's of tricks in its implementation, essentially, does this function spawn the qemu process looks like, eg:http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_process.c;h=c5140c3c92a9ceec8cb7778c79c8542f60eca486;hb=HEAD Please see qemuProcessStart() implemetation: 3288 int qemuProcessStart(virConnectPtr conn, 3289 struct qemud_driver *driver, 3290 virDomainObjPtr vm, 3291 const char *migrateFrom, 3292 int stdin_fd, 3293 const char *stdin_path, 3294 virDomainSnapshotObjPtr snapshot, 3295 enum virNetDevVPortProfileOp vmop, 3296 unsigned int flags) ......BRs. Dennis _______________________________________________ libvirt-users mailing list libvirt-users@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvirt-users
StartProcess("/usr/bin/qemu-system-x86_64", ...);
BRs,
Dennis
_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users
[Virt Tools] [Lib OS Info] [Fedora Users] [Fedora Maintainers] [Fedora Desktop] [Fedora SELinux] [Big List of Linux Books] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools]