How To Setup Libvirt
How to Setup Libvirt
The following guide will walk you through setting up a server to host other virtual machines utilizing The libvirt project. This guide can be used on a graphical host and vert-manager can be used to administrate the virtual machines. Alternatively this guide can be used on a headless server, and a remote connection via SSH in virt-manager can be used on a laptop or other machine to administrate this server remotely.
We will also install Cockpit and configure it to manage the virtual machines as virt-manager is deprecated and Cockpit is intended to become its replacement in a subsequent release. It is, therefore, recommended that you use the web console for managing virtualization in a GUI.
- 1. A Machine with Centos 7 or later
Step 1. Install the requisite software
yum install qemu-kvm qemu libvirt libvirt-bin libvirt-python bridge-utils virt-manager libguestfs-tools spice-vdagent virt-viewer spice-vdagent bridge-utils -y
Step 2. Start the libvirt daemon
systemctl start libvirtd
Step 3. Enable the libvirt daemon
systemctl enable libvirtd
Step 4. Setup virt-manager to connect to the host
- Open virt-manager
- If virt-manager is running on the same machine, you will see "localhost"
- If virt-manager is running on a different machine - click "File" then "Add Connection"
- Check the box that says "Connect to remote host"
- Enter the IP or hostname of the libvirt server
- click "Connect"
- You will be prompted for authentication after which the "Not connected" message to the right of the connection will dispensary
Step 5. Setup the network bridge so our servers will have direct access to the network
- Double click on the either the localhost or remote host
- Open the "Network Interfaces" tab
- Click on the + at the bottom left to add a new network interface
- Interface type: Bridge
- Click "Forward"
- The Name of the bridge can be left at default
- Change the Start mode to "onboot"
- Check the "Activate Now" box
- Select the network interface card your server is using
- Click "Finish"