One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Clone the repository to get a copy for yourself
$ git clone https://github.com/mohapeameya/libvirt-vm-monitor.git
Change current directory to libvirt-vm-monitor
$ cd libvirt-vm-monitor
Install QEMU/libvirt/KVM on your system. Check out the following links for instructions:
Install the following dependencies if not already installed:
$ sudo apt install qemu qemu-kvm -y
$ sudo apt install libvirt-daemon-system libvirt-clients libvirt-bin libvirt-dev -y
$ sudo apt install virt-top -y
$ sudo apt install bridge-utils virt-manager -y
$ sudo apt install libosinfo-bin -y
$ sudo apt install libguestfs-tools -y
$ sudo apt install python3 -y
$ sudo apt install python-tk -y
$ pip3 install python-libvirt matplotlib
Start virt-manager to allow VM installation
$ sudo virt-manager
Install Ubuntu 18.04 LTS Server as Guest VM from ISO image using virt-manager as follows:
- Select Ubuntu 18.04 LTS Server ISO image during installation
- Allocate 2 GB RAM, 1 VCPU and 6GB Disk Space
- Set Name: ubuntu1804-x
where x is the instance # starting from 0 - Network: virtual network'default': NAT
- Network interface
name: ens3
type: eth
IPv4 method: manual
subnet: 192.168.122.0/24(subnet same as virbr0 interface on host)
address: 192.168.122.y where y = x + 2 and x is the instance #
gateway: 192.168.122.1
name server: 192.168.122.1 - Use entire disk for installation
- Set your server's name: ubuntu1804-x
where x is the instance # - Finish installation of the VM and store its xml configuration file in host at
./xmlConfig/
directory with the same naming convention(x is the instance # of the VM)
$ sudo virsh dumpxml ubuntu1804-x > ./xmlConfig/ubuntu1804-x.xml
To test the CMS, run a CPU intensive server in each VM instance as follows:
- Create
/etc/rc.local
in the VM if not already present
$ sudo touch /etc/rc.local
- Edit
/etc/rc.local
file using vim
$ sudo vim /etc/rc.local
- If file is newly created, add the line below at start of the file
#!/bin/sh -e
- Add the following lines at the eof
IPADDR=`ifconfig ens3 | grep "inet " | awk -F'[: ]+' '{print $3}'`
sudo /root/server $IPADDR 55555 &
exit 0
- Give permissions if the file was created
$ sudo chmod +x /etc/rc.local
- Create
server.cpp
in/root/
$ sudo touch /root/server.cpp
-
Shutdown VM to enable safe file editing from host
-
Use virt-edit on host to edit server file
/root/server.cpp
and add content(x is the instance # of the VM):
$ sudo virt-edit -d ubuntu1804-x /root/server.cpp
-
Copy-paste server code into the VM's
/root/server.cpp
file and save changes -
Install g++ on the VM
$ sudo apt install g++
- Compile the server program
$ sudo g++ --std=c++11 -o /root/server /root/server.cpp -lpthread
- Reboot the VM to enable the server
Repeat VM and Server Installation steps for each instance of VM.
Compile the client/load-generator application on host
$ g++ --std=c++11 -o loadgen loadgen.cpp -lpthread
- Run the CMS application
$ python3 ./cms.py
- Run any single VM instance through virt-manager as a default server, say instance 0(static IP 192.168.122.2). If you run multiple instances with no load on the VMs, CMS will shutdown all but 1 instance automatically.
- Run client/load-generator application on host
$ ./loadgen <default_server_ip> <monitor_ip> <min_threads> <max_threads> <test_time_in_secs|time_per_thread_in_secs>
For example:
$ ./loadgen 192.168.122.2 127.0.0.1 15 50 5
-
As the client/load-generator increases/decreases the load on the VMs, CMS will automatically scale up/down the number of VMs without loss of any requests from the client/load-generator. One can confim auto-scaling behaviour using virt-manager.
-
Graphical visualization of test data
$ python3 ./plot.py
- libvirt - an open-source API, daemon and management tool for managing platform virtualization
- Ameya Mohape - Initial work - mohapeameya
This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3 - see the LICENSE file for details