1. Preparatory work
| Systemctl Disable Firewalldsystemctl stop firewalld setenforce 0hostnamectl set-hostname libvirt-manage rpm-qa|grep kvmy Um groupinstall virtual* yum install Virt-manager libvirt libvirt-python python-virtinstsystemctl status libvirtdmkdir/h Ome/vm/centos qemu-img create-f qcow2/home/vm/centos/centos.qcow2 10G VI lib.xml |
2. Configure Lib.xml
| <domain type= ' KVM ' > <name>CentOS</name> //Virtual machine name <memory>1048576</memory> //Max memory, Unit k <currentmemory>1048576</currentmemory> // Available memory, Unit k <vcpu>1</vcpu> //number of virtual CPUs <os> < type>hvm</type> <boot dev= ' cdrom '/ > //Disc Start </os> <features> <acpi/> <apic/> <pae /> &nbsP; </features> <clock offset= ' LocalTime '/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type= ' file ' device= ' disk ' > <driver name= ' qemu ' type= ' Qcow2 '/> <source file= '/home/vm/centos/centos.qcow2 '/>//destination Image path<target dev= ' hda ' bus= ' ide '/> </disk> <disk type= ' file ' device= ' cdrom ' > <so Urce file= '/home/centos-7-x86_64-minimal-1511.iso '/>//put it in advance. <target dev= ' HDB ' bus= ' IDE '/ > </disk> <interface type= ' bridge ' > //virtual Machine network connection mode <source bridge= ' virbr0 '/> //name of current host bridge <mac address= "00:16:3e:5d:aa:a8"/> </interface> <input type= ' Mouse ' bus= ' ps2 '/> <graphics type= ' VNC ' Port= '-1 ' autoport= ' yes ' listen = ' 0.0.0.0 ' keymap= ' en-US '/> </devices> </domain> |
3. Launch the instance to get the VNC screen number
| Virsh Start Centosvirsh vncdisplay CentOS |
4. Start Vncviewer on WindowsDirect activation of the connection may cause the VNC window to flash backThe configuration is as follows:
Options ... > Advanced ... > Expert
Change
–fullcolour to True
–preferredencoding to Hextile
5. Connecting to VNC
Build a virtual machine using Libvirt on Linux