@H_404_2@步骤一:创建一个空镜像文件(空磁盘)用来存放虚拟机
Qemu-imgcreate-fqcow2/raw/mnt/sunwei.qcow210G
步骤二:更改@H_404_2@libvirt.xml@H_404_2@文件
<name>vm1</name>#@H_404_2@更改名字
<memory>8388608</memory>#@H_404_2@更改内存
<sourcefile='/bcshare/cluster/instance/i-02672D9E/instance'/#@H_404_2@空镜像文件位置
<disktype='file'device='cdrom'>
<targetdev='hdc'bus='ide'/>
<sourcefile=""/>#iso@H_404_2@文件存放位置
<readonly/>#@H_404_2@创建好虚拟机后注释这行,否则启动不了
</disk>
<disktype='file'device='cdrom'>
<targetdev='hdd'bus='ide'/>
<sourcefile=""/>#@H_404_2@创建@H_404_2@windows@H_404_2@虚拟机时,驱动存放位置
<readonly/>
</disk>
<graphicstype='vnc'port='16606'passwd='ACAEA20F'autoport='no'keymap='en-us'listen='0.0.0.0'/>#vnc@H_404_2@设置
<interfacetype='bridge'><sourcebridge='eucabr102'/><macaddress='D0:0D:02:67:2D:9E'/><modeltype='virtio'/></interface>#@H_404_2@网卡桥接模式设置,需要更改@H_404_2@mac@H_404_2@地址,以及桥接名称(@H_404_2@br0@H_404_2@)
步骤@H_404_2@3@H_404_2@:如果在@H_404_2@xml@H_404_2@文件内没有设置网卡的话,那么此时就需要手动添加网卡
virshattach-interface--domainvm1--typebridge--sourcebr0
步骤@H_404_2@4@H_404_2@:此时物理机上面就会将@H_404_2@br0@H_404_2@与@H_404_2@vnet0@H_404_2@绑定在一起,这只是临时添加的,如果需要永久添加的话,就需要执行下面的这条语句
Virshdumpxmlvm1>/mnt/libvirt.xml#@H_404_2@将生成的新的配置文件导入原始的@H_404_2@xml@H_404_2@文件,达到永久保存。
[root@localhostlibvirt]#ls
libvirt.conflibvirtd.conflxc.confnwfilterqemuqemu.confqemu-lockd.confstoragevirtlockd.conf
[root@localhostlibvirt]#cdqemu/
[root@localhostqemu]#ls
networksrhel7.0.xmlvm1.xmlvm2.xml
[root@localhostqemu]#pwd#@H_404_2@自己创建的虚拟机@H_404_2@xml@H_404_2@文件存放位置
/etc/libvirt/qemu
[root@localhostqemu]#cd/var/lib/libvirt/images/
[root@localhostimages]#ls
rhel7.0.qcow2vm1vm2
[root@localhostimages]#pwd
/var/lib/libvirt/images#@H_404_2@镜像存放位置