注意点: 1. 设置memory的时候,注意unit的写法 2. emulator的路径,写成一行 3. 能不分行写,一个标签,尽可能写在一行 4. 使用
qemu-img
管理工具建立虚拟机文件,例如:qemu-img create -f qcow2 test.qcow2 10G
5. 建立的文件没有权限,须要将建立的虚拟机文件更改用户组sudo chown hgf:root /var/lib/libvirt/images/test.qcow2
. 即执行start的用户的名下centos
<domain type="kvm"> <name>centos</name> <memory unit="MiB">1024</memory> <currentMemory unit="MiB">1024</currentMemory> <vcpu>2</vcpu> <os> <type arch="x86_64" machine="pc">hvm</type> <boot dev="hd" /> <boot dev="cdrom" /> </os> <features> <acpi /> <apic /> <pae /> </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="/var/lib/libvirt/images/test.qcow2" /> <target dev="hda" bus="ide"/> </disk> <disk type="file" device="cdrom"> <source file="/home/hgf/Dowmload/CentOS-7.0-1406-x86_64-DVD.iso" /> <target dev="hdb" bus="ide"/> </disk> <interface type="bridge"> <source bridge="virbr0"/> </interface> <input type="mouse" bus="ps2" /> <graphics type="vnc" port="-1" autoport="yes" listen="0.0.0.0" keymap="en-us" /> </devices> </domain>
virsh define test_virsh.xml
api
使用
virsh undefine [虚拟主机名]
来取消虚拟机的定义dom
virsh start cetos
ide
start后面的参数,是以前用xml定义的虚拟机的name标签指定的,也能够在define虚拟机后,使用命令
virsh list --alll
工具
查询虚拟机所使用的vnc端口 virsh vncdisplay centos
rest
yum install vnc
(安扎ungde是tiger vncviewer) 打开vnc viewer后,在地址栏输入IP地址:序号
,如127.0.0.1:0
code
注意:此处的序号是使用
virsh vncdisplay 主机名
查询出来的xml