Using KVM on CentOS7

  1. Install CentOS7 with Virtualization Host feature


The Virtualization Host doesn’t install the virt-install and virt-manager. Run the following command to install them.

$ sudo yum install virt-install virt-manager

Also you can install KVM by following command if you didn’t install Virtualization Host feature.

$ sudo yum install kvm virt-manager libvirt virt-install qemu-kvm xauth dejavu-lgc-sans-fonts

  1. check kvm module installation
$ lsmod|grep kvm

kvm_intel             162153  110

kvm                   525409  1 kvm_intel
  1. Setup X server and run virt-manager

$ export DISPLAY

$ sudo virt-manager
  1. KVM cli examples
// check cpu info

$ egrep -c '(vmx|svm)' /proc/cpuinfo
// list templates

$ osinfo-query os
// list VMs

$ sudo virsh --connect qemu:///system list

$ sudo virsh --connect qemu:///system list --all

// show guest infomration

$ sudo virsh dominfo Fedora24

Id:             -

Name:           Fedora24

UUID:           d1e8dd90-54fb-46ee-92af-dad8ec914b2e

OS Type:        hvm

State:          shut off

CPU(s):         2

Max memory:     4194304 KiB

Used memory:    0 KiB

Persistent:     yes

Autostart:      disable

Managed save:   no

Security model: selinux

Security DOI:   0

// shutdown

$ sudo virsh --connect qemu:///system shutdown Fedora24

// force stop

$ sudo virsh --connect qemu:///system destroy Fedora24

// start

$ sudo virsh --connect qemu:///system start Fedora24

// delete guest

$ sudo virsh --connect qemu:///system destroy Fedora24

$ sudo virsh --connect qemu:///system undefine Fedora24

$ sudo rm -f /var/lib/libvirt/images/Fedora24.img

$ sudo virsh pool-refresh default

  1. Autostart guest
// autostart guest

$ sudo virsh --connect qemu:///system autostart Fedora24

$ sudo virsh --connect qemu:///system dominfo Fedora24|grep Auto

Set auto start from GUI


  1. Issues

a) Using samba share file failed. Report permission denied. Copy install iso images to local and it works fine

b) After clone a VM from GUI, cannot start and report missing the folder such as Fedora24-template which is the source VM name. Created a tool to check the folder.  If the folder is gone, the tool creates it immediately.


Written on November 15, 2016