NAME ==== Fabio Checconi EMAIL ADDRESS ============= fabio@gandalf.sssup.it PROJECT TITLE ============= Porting Linux KVM to FreeBSD POSSIBLE MENTOR =============== Luigi Rizzo DESCRIPTION =========== Linux KVM [1, 6] is a Virtual Machine Monitor, part of the Linux kernel, that uses Intel VT-x [2] or AMD-V [3] extensions for x86 processors to create a full virtualization environment. This project will consist in porting Linux KVM to the FreeBSD kernel. Since Linux KVM has a structure similar to that of a device driver (actually, it is a device driver, from many points of view,) core kernel changes will not be required, and the final product of this project will be an external loadable kernel module, exporting an interface based on ioctl() calls to a device descriptor. Part of the project will be also the porting of the userspace client for that interface, a modified qemu [4] that uses KVM for host execution. BENEFITS TO THE FREEBSD COMMUNITY ================================= First and foremost, this work will make it possible to use FreeBSD as a Virtual Machine Monitor for fully virtualized guests, and, in the future, para-virtualized ones. There is also an additional benefit. In order to reduce the complexity of the work, I will try to import as much as possible from the existing Linux kernel KVM code, and enhance the `linux-kmod-compat' [5] code (in /usr/ports/devel/) to implement the features required by the KVM code. As a consequence, the linux-kmod-compat improvements will be useful for other ports as well. In a sense, this project is partially overlapping the `Kernel support for linux device drivers' already proposed in the FreeBSD list of SoC ideas. DELIVERABLES ============ Intermediate: D1 A minimal version of a FreeBSD KVM driver, built from linux source plus a modified linux-kmod-devel code with enough code to let the KVM compile and load, and give access (but with very limited functionality) to the ioctl() descriptor. D2 Detailed workplan for the rest of the work, taking into account issues that should arise in the initial stages of the work. This deliverable should be ready before July the 1st. These two deliverables should be read by the mentor to understand the state of the project and the directions it can take in its second phase. Final: D3 Extend linux-kmod-devel with real implementation of the functions required to the KVM driver to be fully operational (see details in `Project Schedule.') D4 A complete FreeBSD KVM driver with enough functionality to support operation of a real guest OS on top of FreeBSD as a host. D5 Modified qemu code to work with the KVM module. D6 Documentation as needed. PROJECT SCHEDULE ================ 1. Now -> April 20th Study the Linux code and prepare a detailed workplan, grab required source packages, etc. 2. April 21st -> May 5th Create the skeleton of the compatibility layer needed for Linux KVM. 3. May 6th -> May 20th Test the interface using toy userspace clients and toy OSs as guests. 4. May 20th -> June 30th a) Prepare D1. b) Add the generic glue code. c) Add the MMU and FS glue code. d) Initial test of the various functionalities with ad hoc userspace clients and guests. e) Prepare D2 according to the results achieved so far. 4. July 1st -> End of the project a) Complete the missing KVM glue code. b) Test the interface with a qemu supporting Linux KVM. c) Test the whole thing with a real world guest. d) Package D3, D4 and D5. e) Prepare D6, i.e., adapt or integrate the Linux KVM documentation, if something got out of sync. STRATEGY TO ADDRESS PROBLEMS ============================ I have already studied in some detail the Linux KVM code and identified some of the porting issues. The basic approach to reduce the risks in carrying on the work is to partition tasks and deliverables so that even in the occurrence of some unexpected problems part of the project can still proceed. As an example, the linux-kmod-compat extensions should be of use even if the KVM port cannot be completed. Another example can be the modification of the user interface if preserving full compatibility would require too much work; in that case, a modification of the KVM qemu client will be needed, to adapt it to those changes. Among the possible sources of problems: The user interface is the area where the KVM code is more tightly bound to the Linux kernel, so it will be both a) the most interesting from the perspective of linux-kmod-compat extension and b) the one where the differences from Linux and FreeBSD will cause more problems. To face this the best way maybe will be use/extend linux-kmod-compat as much as possible, but not more than that (e.g., KVM uses an internal filesystem, not exported to userspace, for the files it creates; if that will be too hard or expensive the same userspace interface will be preserved via other means.) Another possible source of problems can be the MMU code. The machine dependent code should be portable without too many problems, since it is not dependent on the rest of the kernel; anyway it still depends on the rest of KVM, so both for it and for MMU code the best way to solve problems seems to be the execution of small, simple guests that exercise only the critical parts of the code, and figure out what is going wrong. AVAILABILITY ============ The activity is tightly linked to my PhD research program, so I will be able to work on it almost full time (40 hours per week.) BIO === I am a PhD student at Scuola Superiore S. Anna, in Pisa (Italy,) at the second year of my PhD program, that is on the design of component based operating systems. I have gained some experience on the Linux kernel working for private companies on driver development for embedded platforms (source code not available,) and have some experience on FreeBSD kernel programming, and good expertise is available among my student colleagues and professors. More info on [7]. REFERENCES ========== [1] http://kvm.qumranet.com [2] http://www.intel.com/technology/virtualization/ [3] http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html [4] http://fabrice.bellard.free.fr/qemu/ [5] http://info.iet.unipi.it/~luigi/FreeBSD/linux_bsd_kld.html [6] git://kvm.qumranet.com/home/avi/kvm.git (don't clone it, use only for pull) [7] http://feanor.sssup.it/~fabio