virt-manager install on CentOS7-mini
virt-manager install on CentOS7.4-mini
We use virt-manager to boot VM on CentOS mini. This paper guide to install and configure the virt-manager and linux bridge. Because the virt-manager need display, we should install desktop(xfce) and vnc-server(tigervnc-server) at first. To avoid some issue, we disable and stop firewalld and selinux.
1. Stop firewall and selinux
1.1 firewall
1 systemctl stop firewalld 2 systemctl disable firewalld 3 iptables -F
# Check
1 systemctl status firewalld 2 iptables -L
1.2 selinux
Set selinux to permissive
1 setenforce 0
Set selinux to disabled (need reboot the system to enable the config)
1 sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
2 Desktop and VNC
# virt-manager need display
2.1 Install Desktop
1 yum install epel-release 2 yum groupinstall xfce
3 yum groupinstall "X Window System" #To enable startx
4 systemctl set-default graphical.target #Set the graphical as default
2.2 Install vnc-server
1 yum install tigervnc-server
2.3 Configure vnc-server
# Generate the configuration file when VNC is first enabled.
1 vncserver 2 cp ~/.vnc/xstartup ~/.vnc/xstartup.bak 3 vim ~/.vnc/xstartup
#!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS #exec /etc/X11/xinit/xinitrc startxfce4 & [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic &
4 vncserver -kill :1
2.4 Verify vnc-server
1 vncserver -geometry 1600x900
3 Install virt-manager
3.1 Install virt-manager and dependences
# add repo for libvirt latest
1 vim /etc/yum.repos.d/libvirt-latest.repo
[libvirt-latest] baseurl = https://buildlogs.centos.org/centos/7/virt/x86_64/libvirt-latest/ gpgcheck = 0 name = libvirt-latest for CentOS7
# Install virt-manager virt-viewer and virt-v2v. virt-v2v is the uefi(/usr/share/AAVMF).
1 yum install virt-manager virt-viewer virt-v2v
3.2 Update qemu to 2.10.2
3.2.1 add repo for ceph 10.2.10
# need enable rbd to use ceph as backend on openstack
# jewel is ceph 10.2.10 and has ceph-devel
1 vim /etc/yum.repos.d/ceph.repo
[Ceph] name=Ceph packages for $basearch baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/$basearch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.163.com/ceph/keys/release.asc priority=1 [Ceph-noarch] name=Ceph noarch packages baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/noarch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.163.com/ceph/keys/release.asc priority=1 [ceph-source] name=Ceph source packages baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/SRPMS enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.163.com/ceph/keys/release.asc priority=1
3.2.2 Install dependences
# Build & install need some dependences
1 yum -y install gcc gcc-c++ automake libtool zlib-devel glib2-devel bzip2-devel libuuid-devel spice-protocol spice-glib-devel usbredir-devel libaio-devel librbd-devel flex bison
3.2.3 Download source code
1 wget https://download.qemu.org/qemu-2.10.2.tar.xz 2 tar -xf qemu-2.10.2.tar.xz 3 cd qemu-2.10.2
3.2.4 Config, build and install
# If use ceph as backend storage, add "--enable-rbd", and install librbd-devel as dependences
1 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-rbd --enable-kvm 2 make –j 3 make -j install
3.2.5 Link the new qemu
1 ln -s /usr/bin/qemu-system-x86_64 /usr/libexec/qemu-kvm
3.3 Update libvirt to 4.0.0
3.3.1 Install dependences
1 yum -y install gcc libnl-devel libxml2-devel libxslt device-mapper-devel libpciaccess-devel yajl-devel
3.3.2 Download the packages
1 wget https://libvirt.org/sources/libvirt-4.0.0.tar.xz 2 tar -xf libvirt-4.0.0.tar.xz 3 cd libvirt-4.0.0
3.3.3 Configure & make & install
1 systemctl stop libvirtd 2 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var 3 make -j 4 make -j install 5 ldconfig 6 systemctl daemon-reload 7 systemctl restart libvirtd
3.4 Config libvirt to enable tcp connection
1 vim /etc/libvirt/libvirtd.conf
listen_tls = 0 listen_tcp = 1 tcp_port = "16509" listen_addr = "10.64.4.12" #the IP of your server unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0777" auth_tcp = "none" host_uuid = "a3dbe9e0-4a05-58f3-b4b1-2cc0f42d4513" #host_uuid should be different
2 vim /etc/sysconfig/libvirtd
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf LIBVIRTD_ARGS="--listen"
3 systemctl restart libvirtd 4 virsh -c qemu+tcp://10.64.4.12/system
3.5 Update uefi via edk2
Because virt-v2v can't boot cirros, we use edk2 to update uefi.
1 wget https://rpmfind.net/linux/fedora-secondary/releases/27/Everything/aarch64/os/Packages/e/edk2-aarch64-20170209git296153c5-5.fc27.noarch.rpm 2 rpm –i edk2-aarch64-20170209git296153c5-5.fc27.noarch.rpm 3 rm -rf /usr/share/AAVMF 4 mkdir /usr/share/AAVMF 5 ln /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw /usr/share/AAVMF/AAVMF_CODE.fd 6 ln /usr/share/edk2/aarch64/vars-template-pflash.raw /usr/share/AAVMF/AAVMF_VARS.fd
4 Linux bridge
4.1 Install bridge
1 yum install bridge-utils
4.2 Configure eth0 to br0 (temporary)
1 brctl addbr br0 2 brctl addif br0 eth0 3 ifconfig eth0 0 4 ifconfig br0 192.168.3.9 netmask 255.255.255.0 broadcast 192.168.3.255
4.3 Configure eth0 to br0 (permanent)
1 vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=none BRIDGE=br0 IPV6INIT=no HWADDR=8c:fd:f0:08:18:ab
2 vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=static IPADDR="10.64.37.158" PREFIX="24" GATEWAY="10.64.37.1" DNS1="10.128.0.10" IPV6INIT=no DELAY=0
3 systemctl restart network