Install Qemu-KVM and libvirt
sudo apt-get install qemu-kvm
- Clone Qemu's git repository into a folder of your choice, e.g.,
/opt/build/qemu
, further referenced asQEMU
mkdir $QEMU
cd $QEMU
git clone git://git.qemu-project.org/qemu.git
- Check out supported revision from git repository
cd $KVM/qemu
git checkout 1680d485777ecf436d724631ea8722cc0c66990e
- Perform necessary changes on Qemu and build from source:
- apply VMI-PL patch for Qemu, which is located in the
back_end
folder under the root directory of the VMI-PL repository (the root directory is further referenced asVMI-PL
), on the checked outQEMU
folder, as shown below - build patched Qemu
cd $QEMU/qemu
patch -p1 < $VMI-PL/back_end/qemu.patch
./configure
make
- Clone the git repository of the KVM kernel module into a folder of your choice, e.g.,
/opt/build/kvm
, further referenced asKVM
mkdir $KVM
cd $KVM
git clone git://git.kiszka.org/kvm-kmod.git
- Check out supported revision from git repository
cd $KVM/kvm-kmod
git checkout 42c01897781bcb5a4ac7707b350d98348549e663
- Load the corresponding linux submodule, as described here: kvm-kmod readme
cd $KVM/kvm-kmod
git submodule init
git submodule update
- Perform necessary changes on the KVM kernel module:
- apply VMI-PL patch, which is located in the
back_end
folder under the root directory of the VMI-PL repository (the root directory is further referenced asVMI-PL
), on the checked outKVM
folder, as shown below - copy the VMI-PL header file, which is also located in the
back_end
folder, into following folder:$KVM/kvm-kmod/linux/arch/x86/kvm/
- apply additional patch from the
back_end
folder, if you are running on Linux kernel version 3.2
cd $KVM/kvm-kmod/linux
patch -p1 < $VMI-PL/back_end/vmipl.patch
cp $VMI-PL/back_end/vmi_pl.h arch/x86/kvm/
# additional patch for Linux kernel version 3.2
patch -p1 < $VMI-PL/back_end/external-module-compat-comm_h.patch
- Build and install new KVM kernel module
cd $KVM/kvm-kmod
./configure
make sync
make
sudo rmmod kvm_intel
sudo rmmod kvm
sudo insmod ./x86/kvm.ko
sudo insmod ./x86/kvm-intel.ko
- Start VMI-PL execution environment, which is located in the
front_end
folder under the root directory of the VMI-PL repository, further referenced asVMI-PL
(provide path to custom build qemu version (in this case:$QEMU/qemu/x86_64-softmmu/qemu-system-x86_64
), if it cannot be run using theqemu
command)
sudo $VMI-PL/front_end/server.py -s $QEMU/qemu/x86_64-softmmu/qemu-system-x86_64 &
- Configure and start virtual machine, which should be monitored:
- create VMI-PL script file in a location of your choice, e.g., /opt/vmi-pl/test_script, further referenced as
SCRIPT_LOC
- create virtual machine description file for qemu (the location of this file is further referenced as
VM_DESC_LOC
) - start VMI-PL client, which is also located in the
front_end
folder, as shown below
$VMI-PL/front_end/client.py --start $VM_DESC_LOC $SCRIPT_LOC
Note: It must be possible to start the virtual machine from the provided virtual machine description file using qemu, as shown below
qemu -readconfig $VM_DESC_LOC
- Reconfigure virtual machine (not yet implemented):
- read virtual machine id from the output of the VMI-PL client when the virtual machine was started (further referenced as
VM_ID
) - write VMI-PL reconfiguration script and place it at a location of your choice (further referenced as
SCRIPT_LOC
)
$VMI-PL/front_end/client.py --reconfig $VM_ID $SCRIPT_LOC
Several simple VMI-PL example scripts can be found in the examples
folder under the root directory of the VMI-PL repository. These scripts use VMI-PL to retrieve following information from the guest operating system.
- network traffic to and from the virtual machine (
network_monitoring
) - performed system calls (
process_execution_monitoring
) - a list of running processes, whenever a process is terminated (
process_list
) - scheduling and termination of a process (
process_life_cycle_monitoring
)
Note: The configuration of these scripts was tested for a virtual maching running Ubuntu 12.04 with a 32-bit Linux kernel version 3.2.0, which was started using the Qemu configuration script found in the examples
folder (ubuntu_12_04.cfg
)