創(chuàng)建橋接
編輯/etc/network/interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 192.168.50.199
netmask 255.255.255.0
gateway 192.168.50.1
dns-nameservers 114.114.114.114
bridge_ports eth0
bridge_stp off
bridge_waitport 0
bridge_fd 0
創(chuàng)建虛擬磁盤
qemu-img create -f qcow2 ubuntu_base.img 20G
安裝系統(tǒng)
kvm -m 1024 -drive file=ubuntu_base.img,if=virtio -cdrom /root/ubuntu-14.04.3-server-amd64.iso --nographic -vnc :0
windows安裝virtio驅(qū)動(dòng)
kvm -m -1024 -drive file=windows.img,if=virtio \
-cdrom windows7.iso \
-drive file=virtio-win-iso,index=3,media=cdrom \
--nographics -vnc:0
創(chuàng)建xml文件
<domain type="kvm">
<name>first-ubuntu</name>
<memory unit="MiB">1024</memory>
<currentMemory unit="MiB">1024</currentMemory>
<vcpu current="1">2</vcpu>
<os>
<type arch="x86_64" machine="pc">hvm</type>
<!--
<boot dev="cdrom"/>
-->
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk device="disk" type="file">
<driver cache="none" name="qemu" type="qcow2"/>
<source file="/vm/ubuntu_base.img"/>
<target dev="vda"/>
</disk>
<!--
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/tmp/ubuntu-12.04.2-server-amd64.iso'/>
<target dev="hda"/>
<readonly/>
</disk>
-->
<input bus="ps2" type="mouse"/>
<interface type="bridge">
<source bridge="br0"/>
<model type="virtio"/>
</interface>
<serial/>
<console/>
<graphics autoport="yes" listen="0.0.0.0" port="-1" tlsPort="-1" type="vnc">
<listen address="0.0.0.0" type="address"/>
</graphics>
<video>
<model heads="1" type="cirrus" vram="9126"/>
</video>
<memballoon model="virtio"/>
</devices>
</domain>
用xml文件啟動(dòng)虛擬機(jī)
virsh create ubuntu_base.xml