在RHEL6中,用于从磁盘启动的XML文件

  这里以dcs01.xml为例:

  <domain type='kvm'>
<name>dcs01</name>
<uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='rhel6.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/home/kvm/images/dcs01.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:ad:75:98'/>
<source bridge='br0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='vga' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>

  注释如下:

  1、kvm guest 定义开始
<domain type='kvm'>

  2、guest的short name。由字母和数字组成,不能包含空格
<name>dcs01</name>

  3、uuid,由命令行工具 uuidgen生成。
<uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid>

  4、在不reboot guest的情况下,guset可以使用的最大内存,以KB为单位
<memory>1048576</memory>

  5、guest启动时内存,可以通过virsh setmem来调整内存,但不能大于最大可使用内存。
<currentMemory>1048576</currentMemory>

  6、分配的虚拟cpu
<vcpu>1</vcpu>

  7、有关OS
架构:i686、x86_64
machine:宿主机的操作系统
boot:指定启动设备,可以重复多行,指定不同的值,作为一个启动设备列表。
<os>
<type arch='x86_64' machine='rhel6.0.0'>hvm</type>
<boot dev='hd'/>
</os>

  8、处理器特性
<features>
<acpi/>
<apic/>
<pae/>
</features>

  9、时钟。使用本地时间:localtime
<clock offset='localtime'/>

  10、定义了在kvm环境中power off,reboot,或crash时的默认的动作分别为destroy和restart。其他允许的动作包括: preserve,rename-restart.。
destroy:停止该虚拟机。相当于关闭电源。
restart重启虚拟机
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

  11、设备定义开始
<devices>

  12、模拟元素,此处写法用于kvm的guest
<emulator>/usr/libexec/qemu-kvm</emulator>

  13、用于kvm存储的文件。在这个例子中,在guest中显示为IDE设备。
使用qemu-img命令创建该文件,kvm image的默认目录为:/var/lib/libvirt/images/
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/home/kvm/images/dcs01.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>

  补充:可以定义多个磁盘。
使用virtio:
采用普通的驱动,即硬盘和网卡都采用默认配置情况下,网卡工作在 模拟的rtl 8139 网卡下,速度为100M 全双工。采用 virtio 驱动后,网卡工作在 1000M 的模式下。

  采用普通的驱动,即硬盘和网卡都采用默认配置情况下,硬盘是 ide 模式。采用 virtio 驱动后,硬盘工作是SCSI模式下。
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/usr/local/kvm/vmsample/disk.os'/>
<target dev='vda' bus='virtio'/>
</disk>

  CD-ROM device:
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>

  14、使用网桥类型。确保每个kvm guest的mac地址唯一。将创建tun设备,名称为vnetx(x为0,1,2...)
<interface type='bridge'>
<mac address='52:54:00:ad:75:98'/>
<source bridge='br0'/>
<address type='pcidomain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

  补充:
使用默认的虚拟网络代替网桥,即guest为NAT模式。也可以省略mac地址元素,这样将自动生成mac地址。
<interface type='network'>
<source network='default'/>
<mac address="3B:6E:01:69:3A:11"/>
</interface>
默认分配192.168.122.x/24的地址,也可以手动指定。网关为192.168.122.1

  使用virtio:
采用普通的驱动,即硬盘和网卡都采用默认配置情况下,网卡工作在 模拟的rtl 8139 网卡下,速度为100M 全双工。采用 virtio 驱动后,网卡工作在 1000M 的模式下。
<interface type='bridge'>
<source bridge='br1'/>
<model type='virtio' />
</interface>

  15、输入设备
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>

  16、定义与guset交互的图形设备。在这个例子中,使用vnc协议。listen的地址为host的地址。prot为-1,表示自动分配端口号,通过以下的命令查找端口号:
virsh vncdisplay <KVM Guest Name>

  这里未设置
<graphics type='vnc' port='-1' autoport='yes'/>

  17、设备定义结束
</devices>

  18、KVM定义结束
</domain>

http://www.cnblogs.com/yanghuahui/archive/2013/05/08/3067676.html

<domain type='kvm'>
<name>centos_x86_6.4</name>
#由字母和数字组成,不能包含空格 
<uuid>b9dcdd92-9b9b-14d6-3938-1982a9746a12</uuid>
<memory unit='KiB'>2097152</memory>
 #由字母和数字组成,不能包含空格 
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-1.2'>hvm</type>
#type 表示全虚拟化还是半虚拟化,hvm表示全虚拟化 
<boot dev='hd'/>
  #boot 怎么启动的,如"fd"表示从文件启动, "hd"从硬盘启动, "cdrom"从光驱启动 和 "network"从网络启动 #可以重复多行,指定不同的值,作为一个启动设备列表。 #The dev attribute takes one of the values "fd", "hd", "cdrom" or "network" 
</os>
#处理器特性 
<features>
<acpi/>
<apic/>
<pae/>
</features> 
<clock offset='localtime'>
<timer name='pit' tickpolicy='delay'/>
<timer name='rtc' tickpolicy='catchup'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
#Guest需要的设备
<emulator>/bin/qemu-kvm</emulator>
    <disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
#目的镜像路径 在这个例子中,在guest中显示为IDE设备。 
<source file='/home/template_make/centos_x86_6.4.img'>
<seclabel model='selinux' relabel='no'/>
</source>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/home/template_make/CentOS-6.4-x86_64-bin-DVD1.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<alias name='ide0-1-0'/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<alias name='usb0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<alias name='ide0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
#虚拟机网络连接方式 
<mac address='52:54:00:78:f9:5a'/>
<source bridge='br0'/>
<target dev='vnet27'/>
## 使用virtio: 采用普通的驱动,即硬盘和网卡都采用默认配置情况下,硬盘是 ide 模式, 而网卡工作在 模拟的rtl 8139 网卡下,速度为100M 全双工。 采用 virtio 驱动后,网卡工作在 1000M 的模式下,硬盘工作是SCSI模式下
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
#vnc方式登录,端口号自动分配 可以通过virsh vncdisplay来查询[vncdisplay domainId] 
<graphics type='vnc' port='5915' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='cirrus' vram='9216' 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='0x04' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='selinux' relabel='yes'>
<label>unconfined_u:system_r:svirt_t:s0:c362,c396</label>
<imagelabel>unconfined_u:object_r:svirt_image_t:s0:c362,c396</imagelabel>
</seclabel>
</domain>
 

KVM虚拟机的xml配置文件的更多相关文章

  1. openstack 动态加载usb,需要修改kvm虚拟机的xml文件

    一.利用libvirt命令动态挂载 在利用KVM的虚拟桌面应用中,有时候需要在虚拟桌面起来后还能够动态的挂载或卸载数据盘,以达到类似热插盘U盘或移动硬盘的效果,当然管理上需要做处理.如果纯粹中技术上来 ...

  2. Service系统服务(一):安装一个KVM服务器、KVM平台构建及简单管理、virsh基本管理操作、xml配置文件的应用、为虚拟机制作快照备份、快建新虚拟机

    一.安装一个KVM服务器 目标: 本例要求准备一台 RHEL7.2 服务器,将其搭建为KVM平台,主要完成下列操作: 1> 关闭本机的SELinux保护.防火墙服务   2> 挂载RHEL ...

  3. 烂泥:KVM虚拟机随KVM服务器的启动而启动

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 要使KVM虚拟机随KVM服务器的启动而启动,我们所需要做的工作很少.只需要把KVM虚拟机的XML配置文件做一个软连接到/etc/libvirt/qemu ...

  4. 6、安装kvm虚拟机

    6.1.虚拟机开启虚拟化: 6.2.检查linux虚拟机cpu是否开启了虚拟化: egrep -o 'vmx|svm' /proc/cpuinfo vmx 6.3.安装kvm管理和安装kvm虚拟机的软 ...

  5. 【转】libvirt kvm 虚拟机上网 – Bridge桥接

    libvirt kvm 虚拟机上网 – Bridge桥接 2013 年 7 月 3 日 / 东东东 / 暂无评论 目录 [hide] 1 Bridge桥接原理 2 在host机器配置桥接网络 2.1  ...

  6. libvirt kvm 虚拟机上网 – Bridge桥接

    版权声明:本文由陈煜东原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/90 来源:腾云阁 https://www.qclou ...

  7. CentOS 6.9下KVM虚拟机通过virt-clone克隆虚拟机(转)

    一.virt-clone概述 1.virt-clone作用简介 virt-clone主要是用来克隆kvm虚拟机,并且通过Options.General Option.Storage Configura ...

  8. KVM虚拟机相关步骤

    KVM是Kernel-based Virtual Machine的简称,是一个开源的虚拟化模块,该文档是基于CentOS 7.4环境操作的 一.操作系统安装 本文采用的是CentOS 7.4 1.查看 ...

  9. kvm虚拟机时间修改

    在虚拟化环境中,虚拟机在长时间运行过程中,时间会变慢,通常的作法是配置ntpdate定时与时间服务器进行时间同步的计划任务.KVM虚拟机默认采用utc时间,需要专门修改,以及考虑kvm时间同步问题.1 ...

随机推荐

  1. find -exec 与xargs 区别

    find . -name "*.txt" -exec rm {} \;find . -name "*.txt" | xargs rm {} -exec    1 ...

  2. linux下开启https

    1.在线安装mod_ssl yum -y install mod_ssl 查看openssl 是否安装成功 rpm -qa |grep openssl 2.建立服务器密钥 openssl genrsa ...

  3. 【Spring】Spring+struts2+Hibernate框架的搭建

    1.搭建过程 首先需要引入Spring.Struts2.Hibernate的开发包,已经数据库的驱动包. UserAction.java文件 package cn.shop.action; impor ...

  4. Docker未启动错误:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

    此问题是因为Docker安装后未启动所致,执行以下命令启动docker: systemctl start docker.service 具体日志如下: Connecting to ... Connec ...

  5. 【Linux】数据流重导向(后篇)

    1)/dev/null 垃圾桶黑洞装置与特殊写法 想象一下,如果我知道错误信息会发生,所以要将错误信息忽略掉而不显示或储存呢? 这个时候黑洞装置 /dev/null 就很重要了!这个 /dev/nul ...

  6. idea设置tomcat虚拟路径的两种方法

    1.使用tomcat自己的虚拟路径 1.1.在tomcat\config\server.xml中配置 path="/upload" 虚拟路径 E:\photo\upload 图片存 ...

  7. 异步加载js文件的方法总结

    方法一,jQuery.getScript HTML 代码: 代码如下 复制代码 <button id="go">Run</button><div cl ...

  8. Ubuntu 13..04 开机后桌面问题引发的一系列问题

    早上开机的时候,发现只能见到桌面,没有顶部的菜单栏,没有侧边栏(Unity桌面),不能使用快捷键(不能调出终端),貌似只能用 Ctrl Alt F1-7和关机快捷键.对于我这个刚使用Ubuntu不久的 ...

  9. 清理kafka zookeeper

    ; ; /; rm -rf /app/zookeeper/logs/*; rm -rf /app/pet_kafka_emds2_cluster/kafka-logs/*; rm -rf /app/p ...

  10. 滴滴passport设计之道:帐号体系高可用的7条经验

    导读:应对高可用及极端峰值,每个技术团队都有自己的优秀经验,但是这些方法远没有得到体系化的讨论.高可用架构在 6 月 25 日举办了『高压下的架构演进』专题活动,进行了闭门私董会研讨及对外开放的四个专 ...