设为首页 收藏本站
查看: 1349|回复: 0

[经验分享] xen 启动

[复制链接]

尚未签到

发表于 2015-10-11 12:17:50 | 显示全部楼层 |阅读模式
Libvirt XML学习笔记

为什么要学习libvirt 中的XML
  l          Libvirt中配置虚拟机都是通过xml文件来配置的,如启动一个虚拟机需要的对虚拟机配置的描述就是通过XML来实现的。因此XML在libvirt管理虚拟机中有很重要的地位。
  
Domain XML format
  1.          元素和属性概述
  根元素为所有虚拟机需要的是命名域。它有两个属性,第一个属性是指定Hypervisor的类型,如”Xen”,“KVM”,“qemu”,“lxc”和“kqemu”。第二个属性是id,运行的guest Domain 的ID,已停用的guest Domain有没有ID值。
  
  
  2.          通用元数据
  每个guest Domain都有它的名称,uuid ,描述(描述可有可无)
  <domain type='xen' id='3'>
  <name>xp</name>
  <uuid>4dea22b31d52d8f32516782e98ab3fa0</uuid>
  <description>Some human readable description</description>
  
  
  3.          启动操作系统
  BIOS bootloader
  ...
  <os>
    <type>hvm</type>
    <loader>/usr/lib/xen/boot/hvmloader</loader>
    <boot dev='hd'/>
    <boot dev='cdrom'/>
    <bootmenu enable='yes'/>
  </os>
  ...
  type 表示全虚拟化还是半虚拟化,hvm表示全虚拟化
  loader 全虚拟化才需要的,表示全虚拟化的守护进程所在位置
  boot 怎么启动的,如&quot;fd&quot;表示从文件启动, &quot;hd&quot;从硬盘启动, &quot;cdrom&quot;从光驱启动&quot;network&quot;从网络启动
             bootmenu 当虚拟机启动时是否启用引导菜单,默认时表示使用引导菜单
  
  Host bootloader
  半虚拟化的虚拟机启动一般使用这个,在主机使用一个伪引导来为guest Domain提供一个界面选择启动的内核。下面是个xen下半虚拟化的启动范例
  ...
  <bootloader>/usr/bin/pygrub</bootloader>
  <bootloader_args>--append single</bootloader_args>
  ...
  Bootloader给出主机操作系统引导程序的完整路径,运行这个引导程序,选择启动的内核,这个会因使用的Hypervisor不同而不同。
  bootloader_args该元素的可选bootloader_args允许命令行参数传递到bootloader
  
  Direct kernel boot
  当安装新的一个客户机操作系统,直接从存储在主机操作系统上的内核和initrd启动是非常有效的引导,这样运行命令行参数直接传递给安装程序。全虚拟和半虚拟都可以使用这种引导方式
  ...
    <os>
      <type>hvm</type>
      <loader>/usr/lib/xen/boot/hvmloader</loader>
      <kernel>/root/f8-i386-vmlinuz</kernel>
      <initrd>/root/f8-i386-initrd</initrd>
      <cmdline>console=ttyS0 ks=http://example.com/f8-i386/os/</cmdline>
    </os>
    ...
  type
  This element has the same semantics as described earlier in the BIOS boot section
  loader
  This element has the same semantics as described earlier in the BIOS boot section
  kernel
  The contents of this element specify the fully-qualified path to the kernel image in the host OS.
  initrd
  The contents of this element specify the fully-qualified path to the (optional) ramdisk image in the host OS.
  cmdline
  The contents of this element specify arguments to be passed to the kernel (or installer) at boottime. This is often used to specify an alternate primary console (eg serial port), or the installation media source / kickstart file
  
  
  4.          配置虚拟机的基本资源
  
  ...
    <memory>524288</memory>
    <currentMemory>524288</currentMemory>
    <memoryBacking>
      <hugepages/>
    </memoryBacking>
    <memtune>
      <hard_limit>1048576</hard_limit>
      <soft_limit>131072</soft_limit>
      <swap_hard_limit>2097152</swap_hard_limit>
      <min_guarantee>65536</min_guarantee>
    </memtune>
    <vcpu cpuset=&quot;1-4,^3,6&quot; current=&quot;1&quot;>2</vcpu>
    ...
  
  CPU model and topology
<cpu match='exact'>
    <model>core2duo</model>
    <vendor>Intel</vendor>
    <topology sockets='1' cores='2' threads='1'/>
    <feature policy='disable' name='lahf_lm'/>
  </cpu>
  ...
  
  
  5.          Lifecycle control
  ...
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
    ...
  
  
  
  6.          Hypervisor features
  ...
    <features>
      <pae/>
      <acpi/>
      <apic/>
    </features>
    ...
  pae
  Physical address extension mode allows 32-bit guests to address more than 4 GB of memory.
  acpi
  ACPI is useful for power management, for example, with KVM guests it is required for graceful shutdown to work.
  
  
  7.          Time keeping
  Guest Domain 的时钟通常应初始化于主机时钟,然而大多数操作系统默认使用UTC时间,在windows中把这个叫做”localtime”
  UTC协调世界时,又称世界统一时间,世界标准时间,国际协调时间。定义:以原子时为基准的一种时间计量系统,其时刻与世界时时刻差不超过±0.9s。
  ...
  <clock offset=&quot;localtime&quot;>
    <timer name=&quot;rtc&quot; tickpolicy=&quot;catchup&quot; track=&quot;guest&quot;>
      <catchup threshold=123 slew=120 limit=10000/>
    </timer>
    <timer name=&quot;pit&quot; tickpolicy=&quot;none&quot;/>
  </clock>
  ...
  Clock
  Offset 的属性可能有四种&#20540;,用来让guest Domain 时钟采取什么方式同步到honst,但并不是所有的hypervisor都支持这四种方式
  Offset的四个&#20540;:
  utc
  The guest clock will always be synchronized to UTC when booted
  localtime
  The guest clock will be synchronized to the host's configured timezone when booted, if any.
  timezone
  The guest clock will be synchronized to the requested timezone using the timezone attribute. Since 0.7.7
  variable
  The guest clock will have an arbitrary offset applied relative to UTC. The delta relative to UTC is specified in seconds, using the adjustment attribute. The guest is free to adjust the RTC over time an expect that it will be honoured at next reboot. Thisis in contrast to 'utc' mode, where the RTC adjustments are lost at each reboot.(根据libvirt0.7.7版,Aclock may have zero or moretimersub-elements.Since 0.8.0
  Timer
  每一个timer元素都要求有一个name属性,指定不同的名字会有一些不同的属性,不同的hypervisor支持不同的属性组合
  name
  The name attribute selects which timer is being modified, and can be one of &quot;platform&quot;, &quot;pit&quot;, &quot;rtc&quot;, &quot;hpet&quot;, or &quot;tsc&quot;.
  track
  The track attribute specifies what the timer tracks, and can be &quot;boot&quot;, &quot;guest&quot;, or &quot;wall&quot;. Only valid for name=&quot;rtc&quot; or name=&quot;platform&quot;.
  tickpolicy
  The tickpolicy attribute determines how missed ticks in the guest are handled, and can be &quot;delay&quot;, &quot;catchup&quot;, &quot;merge&quot;, or &quot;discard&quot;. If the policy is &quot;catchup&quot;, there can be further details in the catchup sub-element.
  catchup
  The catchup element has three optional attributes, each a positive integer. The attributes are threshold, slew, and limit.
  frequency
  The frequency attribute is an unsigned integer specifying the frequency at which name=&quot;tsc&quot; runs.
  mode
  The mode attribute controls how the name=&quot;tsc&quot; timer is managed, and can be &quot;auto&quot;, &quot;native&quot;, &quot;emulate&quot;, &quot;paravirt&quot;, or &quot;smpsafe&quot;. Other timers are always emulated.
  present
  The present attribute can be &quot;yes&quot; or &quot;no&quot; to specify whether a particular timer is available to the guest
  
  8.          Devices
  在最后一组xml元组中用来描述为guest Domain提供设备的,所有的设备都是在这里描述的
  ...
    <devices>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
    </devices>
    ...
  Emulator 模拟器,给出二进制模拟器设备的完整路径
  ...
    <devices>
      <disk type='file'>
        <driver name=&quot;tap&quot; type=&quot;aio&quot; cache=&quot;default&quot;/>
        <source file='/var/lib/xen/images/fv0'/>
        <target dev='hda' bus='ide'/>
        <encryption type='...'>
          ...
        </encryption>
        <shareable/>
        <serial>
          ...
        </serial>
      </disk>
    </devices>
    ...
  Encryption如果存在,指定如何给存储卷加密,查看存储加密页面更多信息
  Serial  这个在全虚拟化中比较重要,如果用文件存储,不加下面一段代码,虚拟机无法运行,下面代码是指出硬盘为串口
  <serial type='pty'>
  <source path='/dev/pts/3'/>
  <target port='0'/>
  </serial>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125420-1-1.html 上篇帖子: XenCenter性能显示不准确!! 下篇帖子: vmware workstation + xen + ubuntu 12.04(Dom 0)环境搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表