官术网_书友最值得收藏!

How to do it...

To define a new KVM virtual machine, run the commands outlined here:

  1. List all virtual machines on the host OS:
root@kvm:~# virsh list --all
Id Name State
----------------------------------------------------

root@kvm:~#
  1. Create the following XML definition file:
root@kvm:~# cat kvm1.xml
<domain type='kvm' id='1'>
<name>kvm1</name>
<memory unit='KiB'>1048576</memory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
<boot dev='hd'/>
</os>
<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 type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/debian.img'/>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<interface type='network'>
<source network='default'/>
<target dev='vnet0'/>
<model type='rtl8139'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<graphics type='vnc' port='5900' autoport='yes' listen='146.20.141.158'>
<listen type='address' address='146.20.141.158'/>
</graphics>
</devices>
<seclabel type='none'/>
</domain>
root@kvm:~#
  1. Define the virtual machine:
root@kvm:~# virsh define kvm1.xml
Domain kvm1 defined from kvm1.xml

root@kvm:~#
  1. List all instances in all states:
root@kvm:~# virsh list --all
Id Name State
----------------------------------------------------
- kvm1 shut off

root@kvm:~#
主站蜘蛛池模板: 湖南省| 舞阳县| 玉屏| 洮南市| 白沙| 仁布县| 个旧市| 万州区| 无极县| 烟台市| 顺义区| 崇礼县| 永川市| 鹿泉市| 徐闻县| 定襄县| 新田县| 岚皋县| 桐柏县| 邹城市| 香格里拉县| 如东县| 柘城县| 贵港市| 三穗县| 沧源| 施甸县| 昆明市| 贺州市| 林甸县| 梨树县| 纳雍县| 玉树县| 治多县| 长沙市| 石景山区| 喀喇沁旗| 浮山县| 江达县| 得荣县| 资溪县|