KVM(Kenerl-based virtual machine)安装包分析研究

简介:
kvm主要包括kvm、kmod-kvm、etherboot-zroms-kvm三个包,下面是对各个包的研究,通过研究这些文件,可以了解kvm的构成结构。
一、包内容分析
1、kvm 包
1)概要说明
------------------------------------------------------------------------------------------------
Name        : kvm                          Relocations: (not relocatable)
Version     : 83                                Vendor: CentOS
Release     : 239.el5.centos                Build Date: Fri 22 Jul 2011 09:52:35 PM CST
Install Date: Mon 21 Nov 2011 02:47:25 PM CST      Build Host: builder10.centos.org
Group       : Development/Tools             Source RPM: kvm-83-239.el5.centos.src.rpm
Size        : 2126435                          License: GPLv2
Signature   : DSA/SHA1, Sat 13 Aug 2011 05:26:42 AM CST, Key ID a8a447dce8562897
URL         : http://kvm.sf.net
Summary     : Kernel-based Virtual Machine
Description :
KVM(基于内核的虚拟机)是一个针x86平台上Linux的全虚拟化解决方案。
KVM (for Kernel-based Virtual Machine) is a full virtualization solution
for Linux on x86 hardware.
利用KVM,一个机器能够运行多个之上运行未经修改linux或windows操作系统的虚拟机。每一个虚拟机拥有其专有的
虚拟硬件:如网络接口卡、显卡等。
Using KVM, one can run multiple virtual machines running unmodified Linux
or Windows images. Each virtual machine has private virtualized hardware:
a network card, disk, graphics adapter, etc.
2)此包在操作系统上安装的文件
/etc/sysconfig/modules/kvm.modules   --kvm 模块加载配置文件
/etc/udev/rules.d/65-kvm.rules       --kvm 设备的udev规则文件 
/usr/bin/ksmctl                      --内核共享页合并程序(Kernel Sharedpage Merging)
                                       需要在/dev下有ksm设备
/usr/libexec/qemu-kvm                --基于qemu的虚拟机仿真程序,所有的虚拟机均通过此程序启动
/usr/share/kvm
--各类虚拟BIOS文件
/usr/share/kvm/bios.bin              
/usr/share/kvm/extboot.bin           extboot is an x86 Option ROM that passes through int13 functions to a VMM which
                                     allows a VMM to expose an arbitrary block device as the primary BIOS disk.  It
                                     can be used to boot SCSI or paravirtual devices.
--以下为通过PXE启动用到的网卡ROM BIOS,这些文件是指向/usr/share/qemu-pxe-roms/目录下,zrom格式的文件
/usr/share/kvm/pxe-e1000.bin
/usr/share/kvm/pxe-ne2k_pci.bin
/usr/share/kvm/pxe-pcnet.bin
/usr/share/kvm/pxe-rtl8139.bin
/usr/share/kvm/pxe-virtio.bin
/usr/share/kvm/vgabios-cirrus.bin
/usr/share/kvm/vgabios.bin
--键盘映射文件
/usr/share/kvm/keymaps
/usr/share/kvm/keymaps/ar
/usr/share/kvm/keymaps/common
/usr/share/kvm/keymaps/da
/usr/share/kvm/keymaps/de
/usr/share/kvm/keymaps/de-ch
/usr/share/kvm/keymaps/en-gb
/usr/share/kvm/keymaps/en-us
/usr/share/kvm/keymaps/es
/usr/share/kvm/keymaps/et
/usr/share/kvm/keymaps/fi
/usr/share/kvm/keymaps/fo
/usr/share/kvm/keymaps/fr
/usr/share/kvm/keymaps/fr-be
/usr/share/kvm/keymaps/fr-ca
/usr/share/kvm/keymaps/fr-ch
/usr/share/kvm/keymaps/hr
/usr/share/kvm/keymaps/hu
/usr/share/kvm/keymaps/is
/usr/share/kvm/keymaps/it
/usr/share/kvm/keymaps/ja
/usr/share/kvm/keymaps/lt
/usr/share/kvm/keymaps/lv
/usr/share/kvm/keymaps/mk
/usr/share/kvm/keymaps/modifiers
/usr/share/kvm/keymaps/nl
/usr/share/kvm/keymaps/nl-be
/usr/share/kvm/keymaps/no
/usr/share/kvm/keymaps/pl
/usr/share/kvm/keymaps/pt
/usr/share/kvm/keymaps/pt-br
/usr/share/kvm/keymaps/ru
/usr/share/kvm/keymaps/sl
/usr/share/kvm/keymaps/sv
/usr/share/kvm/keymaps/th
/usr/share/kvm/keymaps/tr
/usr/share/man/man1/qemu-kvm.1.gz     --qemu-kvm 帮助文件
从上面的文件类型来看,此包只涵盖KVM管理相关的文件或程序,不包括KVM核心模块,这些模块在哪里呢?在另一个
名称为kmod-kvm的包中,将在后面进行说明。
 
3)kvm包依赖的其他包
>alsa-lib
--分组:System Environment/Libraries
--说明:The Advanced Linux Sound Architecture (ALSA) 库. ALSA向Linux操作系统提供音频和MIDI功能。
>bash
--分组:System Environment/Shells
--说明:The GNU Bourne Again shell (bash)
>celt051
--分组:System Environment/Libraries
--说明:CELT (Constrained Energy Lapped Transform) 
        一个提供低延迟语音和音频通信的编解码器
>etherboot-zroms-kvm
--分组:Development/Tools 
--说明:网络引导
        KVM支持的.zrom格式的引导ROM(只读存储器)
>qcairo
--分组:System Environment/Libraries
--说明:一个二维图形库
This is a version of the cairo 2D graphics library, with additional
features required to support the implementation of the spice protocol.
Cairo is a 2D graphics library designed to provide high-quality display
and print output. Currently supported output targets include the X Window
System, OpenGL (via glitz), in-memory image buffers, and image files (PDF,
PostScript, and SVG).
>glibc
--分组:System Environment/Libraries
--说明:GNU libc库,
        The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
>gnutls
--分组:System Environment/Libraries
--说明:TLS协议实现
GnuTLS is a project that aims to develop a library which provides a secure
layer, over a reliable transport layer. Currently the GnuTLS library implements
the proposed standards by the IETF's TLS working group.
>initscripts
--分组:System Environment/Base
--说明:inittab 文件和 /etc/init.d 脚本
The initscripts package contains the basic system scripts used to boot
your CentOS system, change runlevels, and shut the system down
cleanly.  Initscripts also contains the scripts that activate and
deactivate most network interfaces.
>kmod-kvm
--分组:System Environment/Kernel
--说明:KVM内核模块
This package provides the kvm kernel modules built for the Linux
kernel 2.6.18-274.el5 for the x86_64 family of processors.
>libgcrypt
--分组:System Environment/Libraries
--说明:一个通用加密库。
>libgpg-error
--分组:System Environment/Libraries
--说明:This is a library that defines common error values for all GnuPG components.  
        Among these are GPG, GPGSM, GPGME, GPG-Agent, libgcrypt,pinentry, SmartCard Daemon and possibly more in the future.
>libpng
--分组:System Environment/Libraries
--说明:提供操作PNG格式图形文件功能的库。
he libpng package contains a library of functions for creating and
manipulating PNG (Portable Network Graphics) image format files.  PNG
is a bit-mapped graphics format similar to the GIF format.  PNG was
created to replace the GIF format, since GIF uses a patented data
compression algorithm.
Libpng should be installed if you need to manipulate PNG format image
files.
>libXrandr
--分组:System Environment/Libraries
--说明:X.Org X11 libXrandr运行时库
>log4cpp
--分组:Development/Libraries
--说明: C++ logging library
>nspr
--分组:System Environment/Libraries
--说明:Netscape Portable Runtime
NSPR provides platform independence for non-GUI operating system
facilities. These facilities include threads, thread synchronization,
normal file and network I/O, interval timing and calendar time, basic
memory management (malloc and free) and shared library linking.
>openssl
--分组:System Environment/Libraries
--说明:OpenSSL 工具包
The OpenSSL toolkit provides support for secure communications between
machines. OpenSSL includes a certificate management tool and shared
libraries which provide various cryptographic algorithms and
protocols.
>qffmpeg-libs
--分组:ystem Environment/Libraries
--说明:Codec and format libraries for qffmpeg intended for use with the SPICE virtual desktop protocol.
>qspice-libs
--分组:System Environment/Libraries
--说明: Libraries for qspice
This package contains the runtime libraries for any application that wishes to be a qspice server.
>SDL
--分组:System Environment/Libraries
--说明:A cross-platform multimedia library.
Simple DirectMedia Layer (SDL) is a cross-platform multimedia library
designed to provide fast access to the graphics frame buffer and audio
device.
>shadow-utils
--分组:System Environment/Base
--说明:Utilities for managing accounts and shadow password files
The shadow-utils package includes the necessary programs for
converting UNIX password files to the shadow password format, plus
programs for managing user and group accounts. The pwconv command
converts passwords to the shadow password format. The pwunconv command
unconverts shadow passwords and generates an npasswd file (a standard
UNIX password file). The pwck command checks the integrity of password
and shadow files. The lastlog command prints out the last login times
for all users. The useradd, userdel, and usermod commands are used for
managing user accounts. The groupadd, groupdel, and groupmod commands
are used for managing group accounts.
>zlib
--分组:System Environment/Libraries
--说明:The zlib compression and decompression library.
Zlib is a general-purpose, patent-free, lossless data compression
library which is used by many different programs.
================================================================================================ 
2、kmod-kvm包 
1)概要说明
------------------------------------------------------------------------------------------------
Name        : kmod-kvm                     Relocations: (not relocatable)
Version     : 83                                Vendor: (none)
Release     : 274.el5.centos.2              Build Date: Thu 17 Nov 2011 10:19:56 AM CST
Install Date: Mon 21 Nov 2011 02:51:30 PM CST      Build Host: localhost.localdomain
Group       : System Environment/Kernel     Source RPM: kmod-kvm-83-274.el5.centos.2.src.rpm
Size        : 476848                           License: GPL
Signature   : (none)
URL         : http://www.qumranet.com
Summary     : kvm kernel module
Description :
这个内核模块提供对使用硬件虚拟化(Intel VT-x&VT-i 或 AMD SVM)的虚拟机的支持。
This kernel module provides support for virtual machines using hardware support
(Intel VT-x&VT-i or AMD SVM).
2)此包在操作系统上安装的文件
/lib/modules/2.6.18-274.el5/extra/kmod-kvm
/lib/modules/2.6.18-274.el5/extra/kmod-kvm/ksm.ko
/lib/modules/2.6.18-274.el5/extra/kmod-kvm/kvm-amd.ko
/lib/modules/2.6.18-274.el5/extra/kmod-kvm/kvm-intel.ko
/lib/modules/2.6.18-274.el5/extra/kmod-kvm/kvm.ko
/lib/modules/2.6.18-274.7.1.el5/extra/kvm-amd.ko
/lib/modules/2.6.18-274.7.1.el5/extra/kvm-intel.ko
/lib/modules/2.6.18-274.7.1.el5/extra/kvm.ko
从安装文件内容来看,kvm内核模块文件都在这个包中。
3)kmod-kvm包依赖的其他包
此包只依赖内核,不涉及其他的库或者工具包
================================================================================================ 
3、etherboot-zroms-kvm包
1)概要说明
------------------------------------------------------------------------------------------------
Name        : etherboot-zroms-kvm          Relocations: (not relocatable)
Version     : 5.4.4                             Vendor: CentOS
Release     : 13.el5.centos                 Build Date: Mon 05 Apr 2010 03:05:57 AM CST
Install Date: Wed 16 Nov 2011 11:04:10 AM CST      Build Host: builder10.centos.org
Group       : Development/Tools             Source RPM: etherboot-5.4.4-13.el5.centos.src.rpm
Size        : 196608                           License: GPLv2
Signature   : DSA/SHA1, Tue 27 Apr 2010 07:41:01 AM CST, Key ID a8a447dce8562897
URL         : http://etherboot.org
Summary     : Etherboot - boot roms supported by KVM, .zrom format
Description :
此包中包含kvm仿真的通过网卡引导的.zrom格式的ROM文件。
2)此包在操作系统上安装的文件
/usr/share/etherboot
/usr/share/etherboot/e1000-82542.zrom
/usr/share/etherboot/ne.zrom
/usr/share/etherboot/pcnet32.zrom
/usr/share/etherboot/rtl8029.zrom
/usr/share/etherboot/rtl8139.zrom
/usr/share/etherboot/virtio-net.zrom
/usr/share/qemu-pxe-roms
3)etherboot-zroms-kvm包依赖的其他包
bash
只需要有shell支持即可。
================================================================================================
三、kvm模块配置文件
配置文件位置:/etc/sysconfig/modules/kvm.modules
文件内容如下:
----------------------------------------------------------------------------------------------
if [ $(grep -c vmx /proc/cpuinfo) -ne 0 ]; then    --判断是否为Intel CPU
    modprobe kvm-intel >/dev/null 2>&1             
fi
if [ $(grep -c svm /proc/cpuinfo) -ne 0 ]; then     --判断是否为AMD  CPU
    modprobe kvm-amd >/dev/null 2>&1
fi
modprobe ksm >/dev/null 2>&1                        
----------------------------------------------------------------------------------------------
本配置前两个语句主要是检查host CPU 类型,然后加载对应的模块,Intel 为 kvm-intel\AMD 为kvm-amd
无论是Intel 还是 AMD CPU,均需要加载 ksm模块。
 >/dev/null 2>&1 是指将模块加载命令的输出信息及错误信息都重定向到/dev/null设备中,默认情况下这两类
 信息都输出到屏幕 
================================================================================================
四、综合分析
通过对kvm包极其涵盖的文件分析,kvm提供的程序和文件主要包括三部分:
1、内核模块:kvm.ko、kvm-amd、kvm-intel.ko、ksm.ko
2、虚拟机仿真、管理相关文件:qemu-kvm、*.bin
3、网卡仿真BIOS文件。

明确了包含哪些文件,通过分析这些文件的作用,即可对kvm的运行机制有一个概要的理解了。




本文转自 freeterman 51CTO博客,原文链接:http://blog.51cto.com/myunix/1129703,如需转载请自行联系原作者

相关文章
|
6月前
|
存储 运维 Linux
KVM详解(三)——KVM创建虚拟机
KVM详解(三)——KVM创建虚拟机
163 6
|
2月前
|
KVM 虚拟化
kvm虚拟机快照
这篇文章主要介绍了KVM虚拟机快照的创建、管理、恢复以及删除的详细步骤,包括查看快照信息、创建快照、模拟系统破坏后基于快照恢复虚拟机、使用快照的注意事项以及如何删除快照。
60 2
|
6月前
|
Linux KVM 数据库
服务器数据恢复—服务器误删除KVM虚拟机数据恢复案例
服务器数据恢复环境: 一台服务器安装Linux操作系统+EXT4文件系统。服务器上运行数台KVM虚拟机,每台虚拟机包含一个qcow2格式的磁盘文件和一个raw格式的磁盘文件。 服务器故障: 工作人员操作失误删除了服务器上的3台KVM虚拟机,虚拟机中运行数据库,需恢复误删除虚拟机中raw格式的磁盘文件。
服务器数据恢复—服务器误删除KVM虚拟机数据恢复案例
|
2月前
|
KVM 虚拟化
KVM虚拟机的桥接网络
文章主要介绍了KVM虚拟机的NAT和桥接网络类型的工作原理、配置方法以及如何进行网络模式的切换。
45 3
KVM虚拟机的桥接网络
|
2月前
|
KVM 虚拟化
KVM虚拟机的克隆
这篇文章介绍了如何使用KVM虚拟机进行完整克隆和链接克隆,包括手动克隆和使用virt-clone工具克隆的方法,以及如何编写脚本来实现自动化克隆和删除虚拟机。
69 3
KVM虚拟机的克隆
|
2月前
|
KVM 虚拟化
KVM虚拟机的热迁移
这篇文章详细介绍了KVM虚拟机的热迁移过程,包括临时迁移和永久迁移的步骤,以及可能遇到的故障和解决方案。
118 1
KVM虚拟机的热迁移
|
2月前
|
KVM 虚拟化
kvm虚拟机磁盘管理
文章详细介绍了KVM虚拟机磁盘管理,包括磁盘格式概述、创建虚拟机时如何指定磁盘格式、以及磁盘工具的常用命令,旨在帮助用户更好地理解和操作KVM虚拟机的磁盘管理。
92 1
kvm虚拟机磁盘管理
|
2月前
|
KVM 虚拟化 数据安全/隐私保护
KVM虚拟机安装实战
本文讲述了如何创建并使用VNC连接KVM虚拟机的详细教程,包括安装图解和命令行参数说明。
118 8
|
2月前
|
KVM 虚拟化
KVM虚拟机的冷迁移
这篇文章详细描述了KVM虚拟机的冷迁移过程,包括无依赖环境迁移、有链接克隆虚拟机迁移、多块磁盘迁移的案例,以及可能遇到的错误和解决方案。
103 3
|
3月前
|
Linux KVM 数据库
虚拟机数据恢复—Linux系统下误删除KVM虚拟机的数据恢复案例
虚拟机数据恢复环境: Linux操作系统服务器,EXT4文件系统。服务器中有数台KVM虚拟机。 虚拟机故障: KVM虚拟机被删除,需要恢复raw格式的磁盘文件。
虚拟机数据恢复—Linux系统下误删除KVM虚拟机的数据恢复案例