KVM虚拟机的配置文件在/etc/libvirt/qemu/下,为xml文件

整体结构如下:

 <domain type='kvm'>
虚拟机整体信息
系统信息
硬件资源特性
突发事件处理
虚拟磁盘(单个或多个)
虚拟光盘(可选)
虚拟网络(单个或多个)
vnc/spice配置
</domain>

在Libvirt官方文档里面,将虚拟机定义为domain,而不是vm(virtual machine)。Xen中Domain0表示宿主机系统,而在KVM中,domain完全指虚拟机系统。

type一项指明了使用的是哪种虚拟化技术。如果使用的是KVM,那么值为kvm。如果使用的是Xen,那么值为xen。当然,如果使用的是其他hypervisor,值也不尽相同

 <domain type='kvm'>          ##描述hypervisor
<name>centos7.</name>        ##定义虚拟机整体信息
<uuid>c2d264d3-5c61-4d2e--b28673c1f64b</uuid>
<memory unit='KiB'></memory>
<currentMemory unit='KiB'></currentMemory>
<vcpu placement='static'></vcpu>
<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>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>                ##外设资源
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>    ##描述虚拟磁盘image
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/centos7.0.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
<controller type='usb' index='' model='ich9-ehci1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
</controller>
<controller type='usb' index='' model='ich9-uhci1'>
<master startport=''/>
</controller>
<controller type='usb' index='' model='ich9-uhci2'>
<master startport=''/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
</controller>
<controller type='usb' index='' model='ich9-uhci3'>
<master startport=''/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
<controller type='virtio-serial' index=''>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</controller>
<interface type='bridge'>    ##虚拟网络,基于网桥
<mac address='52:54:00:6a:1e:54'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>      ##串口信息可以不用更改
<target port=''/>
</serial>
<console type='pty'>
<target type='serial' port=''/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='' bus='' port=''/>
</channel>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='' bus='' port=''/>
</channel>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
<sound model='ich6'>      ##从此往下的内容可以不用更改
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='qxl' ram='' vram='' vgamem='' heads=''/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<redirdev bus='usb' type='spicevmc'>
</redirdev>
<redirdev bus='usb' type='spicevmc'>
</redirdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</memballoon>
</devices>
</domain>

第一行定义了虚拟机的名字。libvirt可以通过虚拟机的名字对虚拟机进行管理。在同一台物理机上,虚拟机的名字必须要保证唯一的。如果存在重名的情况,添加和创建虚拟机时,会失败。

第二行定义的虚拟机的UUID。在同一台物理机上,UUID值也必须是唯一的,否则会出现冲突。

第三四行描述虚拟机的内存信息,通常以KB为单位。

第五行指明了分配的虚拟CPU的个数。

在系统信息部分主要包括了两部分信息:类型和启动信息

硬件资源特性主要包括:电源管理及内存扩展

突发事件处理定义了当发生poweroff时,直接destroy虚拟机。当虚拟机reboot、crash的时候,会自动采用重启操作,还可以自定义。

在虚拟化技术或者云计算中,都使用image一词来表示虚拟磁盘。

在<device></device>中的都是虚拟外设

常用的image格式为raw何qcow2,首先可以手动创建出一个image

  qemu-img  create  -f  raw  xxxxx.raw  20G

虚拟磁盘部分是比较重要的一块,详细参见磁盘管理篇

KVM虚拟化技术(七)虚拟机配置文件的更多相关文章

  1. KVM虚拟化技术

    KVM虚拟化技术 Qemu-kvm kvm virt-manager VNC Qemu-kvm创建和管理虚拟机 一.KVM简介 KVM(名称来自英语:Kernel-basedVirtual Machi ...

  2. [转] KVM虚拟化技术生态环境介绍

    KVM虚拟化技术生态环境介绍 http://xanpeng.github.io/wiki/virt/kvm-virtulization-echosystem-intro.html kvm和qemu/q ...

  3. KVM虚拟化技术(五)虚拟机管理

    一.为了提高内存.硬盘.网络的性能,需要支持半虚拟化:virtio半虚拟化驱动 二.对虚拟机的管理都是通过libvirt:所有必须要启用一个守护程序libvirtd. 三.virt-manager ① ...

  4. linux运维、架构之路-KVM虚拟化技术

    一.云计算概述 云计算:是一种资源使用和交付模式 虚拟化:一种具体的技术,用来将物理机虚拟成为多个相互独立的虚拟机.云计算不等于虚拟化,云计算是使用了虚拟化的技术做支撑 二.KVM配置使用 1.系统环 ...

  5. KVM虚拟化技术(二)KVM介绍

    KVM:Kernel Virtual Machine KVM是基于虚拟化扩展的x86硬件,是Linux完全原生的全虚拟化解决方案.部分半虚拟化支持,主要是通过半虚拟网络驱动程序的形式用于Linux和W ...

  6. KVM虚拟化技术(一)虚拟化简介

    一 .虚拟化 虚拟化是指计算机元件在虚拟的基础上而不是真实的基础上运行.虚拟化技术可以扩大硬件的容量,简化软件的重新配置过程.CPU的虚拟化技术可以单CPU模 拟多CPU并行,允许一个平台同时运行多个 ...

  7. KVM虚拟化之windows虚拟机性能调整

    通过KVM安装WindowsXP/2003/7/2008操作系统后,由于默认的磁盘驱动(IDE)性能与网卡驱动(RTL8139100M)的性能都极其低下,需要调整,通过加载Redhatvirtio驱动 ...

  8. VMware 虚拟化技术 创建虚拟机

    原文地址:https://www.linuxidc.com/Linux/2017-03/141972.htm 云最成熟的架构是IaaS(Infrastructure as a Service),其中用 ...

  9. 《KVM虚拟化技术实战和原理解析》读书笔记(十几篇)

    第一章和第二章 第一章 虚拟化和云计算 Saas(软件即服务):将已经部署好的软件作为一种服务来提供,比如:Google Docs, Google Apps Paas(平台即服务):将开发环境作为一种 ...

随机推荐

  1. virtualbox 使用USB引导启动安装系统

    想要测试u盘系统引导有没有问题,从u盘中启动我烧录的Android x86系统. 这种方式可以在已有空的虚拟机上直接启动U盘中的系统. 百度上能搜到的方式都是使用CMD命令(懒人表示太麻烦--),so ...

  2. Install CentOS 7 on Thinkpad t430

    - BIOS settings: - Thinkpadt430, BIOS settings: Config---------------------------- Network: wake on ...

  3. ASP.Net上传大文件解决方案之IIS7.0下的配置

    开源的Brettle.Web.NeatUpload.在公司IIS6.0使用正常,但是在Windows 2008 server IIS7上使用不正常.在网上看到一个解决办法但是没有效果 IIS 7 默认 ...

  4. js产生随机数函数

    函数: //产生随机数函数 function RndNum(n){ var rnd=""; for(var i=0;i<n;i++) rnd+=Math.floor(Math ...

  5. java读取文件之txt文本

    1.方法一: public static String txt2String(File file){ 13 String result = ""; 14 try{ 15 Buffe ...

  6. spring @Scheduled注解执行定时任务

    以前框架使用quartz框架执行定时调度问题. 这配置太麻烦.每个调度都需要多加在spring的配置中. 能不能减少配置的量从而提高开发效率. 最近看了看spring的 scheduled的使用注解的 ...

  7. WPF 容器的Z顺序操作

    当需要动态添加.修改.删除控件时,如果要达到最好的效果,肯定不只是把需要的控件添加到容器中,并且还需要把容器中的已有控件进行排序操作(置顶.置底.前移.后移操作).由于初次接触到wpf,所以对很多知识 ...

  8. HTML5中与页面显示相关的API

    1.HTML5中与页面显示相关的API 在HTML5中,增加了几个与页面显示相关的API,其中一个是Page Visibility API Page Visibility API  是指当页面变为最小 ...

  9. js 中文乱码解决方法

     bookManageAdd: function () {         top.MainFrameJS.confirm = true;         var action = getQueryS ...

  10. THINKPHP中关于接口问题(客户端)

    一 apk版本号 客户端发送get请求访问服务器端的控制器方法,通过用户传过来的用户名和密码. 二  服务器端通过客户端传入的user and password 去数据库进行查询,Success就生成 ...