admin 发表于 2019-9-5 09:36:11

本主题需向作者支付 2 金钱 才能浏览 购买主题

admin 发表于 2019-9-5 10:10:11

<domain type='kvm' id='131'>
<name>test</name>
<uuid>0e91050a-8a6e-4db9-ab8e-a5ffe4215132</uuid>
<description>Timos VM</description>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<memoryBacking>
    <hugepages/>
    <nosharepages/>
</memoryBacking>
<vcpu placement='static'>2</vcpu>
<cputune>
    <vcpupin vcpu='0' cpuset='45'/>
    <vcpupin vcpu='1' cpuset='44'/>
</cputune>
<numatune>
    <memory mode='preferred' nodeset='0'/>
</numatune>
<resource>
    <partition>/machine</partition>
</resource>
<sysinfo type='smbios'>
    <bios>
      <entry name='vendor'>KVM</entry>
    </bios>
    <system>
      <entry name='manufacturer'>alcatel-lucent.com</entry>
      <entry name='product'>TIMOS:slot=A chassis=VSR-I card=cpm-v mda/1=m20-v
      address=192.168.0.12/24@active
   </entry>
    </system>
</sysinfo>
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='hd'/>
    <smbios mode='sysinfo'/>
</os>
<cpu mode='host-model'>
    <model fallback='allow'/>
</cpu>
<clock offset='utc'>
    <timer name='rtc' tickpolicy='delay'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
</pm>
<devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='usb' index='0'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='50:54:00:59:e9:02'/>
      <source bridge='br2455'/>
      <target dev='vnet2'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='50:54:08:68:1f:c0'/>
      <source bridge='br2083'/>
      <target dev='vnet3'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/2'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/2'>
      <source path='/dev/pts/2'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5901' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vga' vram='16384' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
</devices>
<seclabel type='none' model='none'/>
</domain>

admin 发表于 2019-9-5 10:33:17

<domain type='kvm' id='192'>
<name>test</name>
<uuid></uuid>
<memory unit='KiB'>25165824</memory>
<currentMemory unit='KiB'>25165824</currentMemory>
<vcpu placement='static'>6</vcpu>
<resource>
    <partition>/machine</partition>
</resource>
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='hd'/>
</os>
<features>
    <acpi/>
    <apic/>
</features>
<cpu mode='custom' match='exact'>
    <model fallback='allow'>Haswell-noTSX</model>
</cpu>
<clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
</pm>
<devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/VSD-4.0.10_272.4.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <source bridge='br2455'/>
      <target dev=''/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/4'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/4'>
      <source path='/dev/pts/4'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-vsd4/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5901' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </memballoon>
</devices>
</domain>

admin 发表于 2019-9-5 14:15:51

kvm使用xml文件创建全过程,注意几点,在楼上的xml文件,
<domain type='kvm' id='1'<name>centos</name>      //虚拟机名称唯一


   <memory unit='KiB'>102400</memory>
   <currentMemory unit='KiB'>102400</currentMemory>
<vcpu placement='static'>1</vcpu>
   <os>
   <type arch='x86_64' machine='rhel6.6.0'>hvm</type>//arch指出系统架构类型,machine 则是机器类型,查看机器类型:qemu-system-x86_64
   <boot dev='hd'/>         //启动介质,第一次需要装系统可以选择cdrom光盘启动
</os>
   <features>
   <acpi/>               //Advanced Configuration and Power Interface,高级配置与电源接口
    <apic/>               //Advanced Programmable Interrupt Controller,高级可编程中断控制器
    <pae/>               //Physical Address Extension,物理地址扩展
</features>
   <clock offset='utc'/>      //虚拟机时钟设置,这里表示本地本机时间
<on_poweroff>destroy</on_poweroff>       //突发事件动作

<on_reboot>restart</on_reboot>

   <on_crash>restart</on_crash>
   <devices>
   <emulator>/usr/libexec/qemu-kvm</emulator>       //kvm 默认
    <disk type='file' device='disk'>
       <driver name='qemu' type='qcow2' cache='none'/>    //镜像类型
      <source file='/var/lib/libvirt/images/cirros-0.3.3-x86_64-disk.img'/>    //镜像位置
      <target dev='hda' bus='ide'/>      
   </disk>
   <interface type='bridge'>    //虚拟机网卡类型
      <source bridge='br0'/>   
       <target dev='vnet0'/>      //宿主机设备名称
    </interface>
   <console type='pty' tty='/dev/pts/2'>   //控制台登录设置
      <source path='/dev/pts/2'/>
       <target type='serial' port='0'/>
   </console>
   <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0'>   //配置VNC 设置
      <listen type='address' address='0.0.0.0'/>
   </graphics>
   </devices>
</domain>
页: [1]
查看完整版本: 使用virsh define使用xml文件启动虚拟机