Installing QEMU-KVM on Linux

Check cpu virtualization was enabled.

grep -E 'vmx|svm' /proc/cpuinfo
lscpu | grep Virtualization

Install packages.

yum -y install qemu-kvm qemu-img virt-manager libvirt libvirt-python python-virtinst libvirt-client

chkconfig libvirtd on
service libvirtd start

iptables -I INPUT -p tcp --dport 49152:49215 -j ACCEPT
iptables -I INPUT -p tcp --dport 16509 -j ACCEPT
yum -y install qemu-kvm libvirt virt-install libvirt-python virt-manager virt-install libvirt-client

systemctl enable --now libvirtd

# for migrate
firewall-cmd --add-port=49152-49215/tcp --permanent
firewall-cmd --add-port=16509/tcp --permanent
firewall-cmd --reload
sudo dnf -y install qemu-kvm libvirt virt-install virt-viewer

for drv in qemu network nodedev nwfilter secret storage interface; do sudo systemctl start virt${drv}d{,-ro,-admin}.socket; done

# for migrate
sudo firewall-cmd --add-port=49152-49215/tcp --permanent
sudo firewall-cmd --add-port=16509/tcp --permanent
sudo firewall-cmd --add-port=16514/tcp --permanent
sudo firewall-cmd --reload

Verification.

~]$ virt-host-validate
QEMU: Checking for hardware virtualization : PASS (VMX)
QEMU: Checking if device '/dev/kvm' exists : PASS
QEMU: Checking if device '/dev/kvm' is accessible : PASS
QEMU: Checking if device '/dev/vhost-net' exists : PASS
QEMU: Checking if device '/dev/net/tun' exists : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuset' controller support : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'devices' controller support : WARN (Enable 'devices' in kernel Kconfig file or mount/enable cgroup controller in your system)
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for device assignment IOMMU support : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)
QEMU: Checking for secure guest support : WARN (None of SEV, SEV-ES, SEV-SNP, TDX available)

~]$ lsmod | grep -i kvm
kvm_intel 471040 0
kvm 1417216 1 kvm_intel

Configuring SELinux

semanage fcontext -a -t virt_image_t "/vm/data(/.*)?"
restorecon -Rv /vm/data

Configuring Network

・ Configuring Network for QEMU-KVM

Create Virtual Machines

・ How to Create a Virtual Machine on QEMU-KVM

Uninstall QEMU-KVM

yum -y remove `rpm -qa | grep -E 'qemu|virt|kvm'`
rm -rf /var/lib/libvirt /etc/libvirt