5、python-virtinst : Python modules and utilities for installing virtual machines
6、virt-manager : Virtual Machine Manager (GUI app, to install and configure VMs)
7、virt-viewer: Virtual Machine Viewer (another lightweight app to view VM console and/or install VMs)
9、bridge-utils : Utilities for configuring the Linux Ethernet bridge (this is recommended for KVM networking)
KVM Package GroupRHEL comes with KVM software group which includes full virtualization support with KVM. You can list all packages in the group as follows: # yum groupinfo KVM
2、Start the libvirtd daemon service service libvirtd start
关于错误:
注:该错误出现在centos5.4,libvirtd 0.6.3
重启libvirtd后,启动guest时会出现下面的问题。
Apr 22 09:16:20 srv4 kernel: libvirtd[27156]: segfault at 00000000444e3000 rip 0000003e5501e161 rsp 00000000444dfcd0 error 4
Apr 22 09:16:20 srv4 libvirtd: 09:16:20.739: error : internal error Unable to daemonize QEMU process
重启了host,问题解决
原因:https://bugzilla.redhat.com/show_bug.cgi?id=505625
Everytime the virGetCapabilities() method is run, it destroys the existing virCapsPtr object and creates it again....without any of the selinux info. virt-manager runs this method. so once virt-manager has run, subsequent calls to get the security info will give the crash you see.
也可以通过下面的命令查看桥接网络,可以看到eth0加到了桥接设备br0中: # brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
br0 8000.000e0cb30550 no eth0
三、创建KVM虚拟机的XML定义文件
关于KVM XML format http://libvirt.org/formatdomain.html
1.1 用于从磁盘启动的XML文件
1、kvm guest 定义开始
2、guest的short name。由字母和数字组成,不能包含空格
centosvm1
3、uuid,由命令行工具 uuidgen生成。
bdbb89fb-57d1-4d01-b3b7-ff33a9346ae6
4、在不reboot guest的情况下,guset可以使用的最大内存,以KB为单位
2048000
5、guest启动时内存,可以通过virsh setmem来调整内存,但不能大于最大可使用内存。
1024000
6、分配的虚拟cpu
2
7、有关OS
x86架构:i686
hvm:全虚拟化
kernel:指定guest使用的内核,如果使用ISO(安装时)或guset系统中(系统已经安装完成)的内核,不需要指定该项
initrd:指定guest使用的ram disk,如果使用ISO(安装时)或guest系统中(系统已经安装完成)的ram disk,不需要指定该项
注:kernel 和initrd文件位于RHEL系统光盘的images/pxeboot目录,拷贝这两个文件到本地磁盘,并指定路径。
注:这两个元素,如果是为了安装guset而指定,在安装完成以后即可以删除。
如果host开启了SELINUX,you also need to change the type of security context for the files to virt_image_t to allow libvirtd to access them for booting:
# chcon -t virt_image_t /tmp/vmlinuz-rhel54
# chcon -t virt_image_t /tmp/initrd-rhel54.img
After you change the security context, verify that the correct security context is assigned to them as shown in the following example:
A Note About Virtio Drivers Virtio is paravirtualized drivers for kvm/Linux. With this you can can run multiple virtual machines running unmodified Linux or Windows VMs. Each virtual machine has private virtualized hardware a network card, disk, graphics adapter, etc. According to Redhat:
Para-virtualized drivers enhance the performance of fully virtualized guests. With the para-virtualized drivers guest I/O latency decreases and throughput increases to near bare-metal levels. It is recommended to use the para-virtualized drivers for fully virtualized guests running I/O heavy tasks and applications.
关于cache=none
如果不加该参数,默认cache policy为write through。
kvm官方及IBM都推荐使用raw,设置cache为none,以关闭kvm磁盘的cache策略,让数据可以直接落在实体硬盘上(实体机上其实也有磁盘cache的,并不需要kvm为cache操心)
For the best storage performance on guest operating systems that use raw disk volumes or partitions,completely avoid the page cache on the host.
下面的帖子中有一段关于cache的内容:
http://www.linuxeden.com/forum/viewthread.php?tid=205581&extra=&page=3
rhel5.6 guest with virtio interface can not boot successfully if the system installation would use the ide interface
https://bugzilla.redhat.com/show_bug.cgi?id=647387
16、定义与guset交互的图形设备。在这个例子中,使用vnc协议。listen的地址为host的地址。prot为-1,表示自动分配端口号,通过以下的命令查找端口号:
virsh vncdisplay
注意:是passwd 而不是password
VNC is configured to listen on 127.0.0.1 by default. To make it listen on all public interfaces, edit /etc/libvirt/qemu.conf file.
错误:
在convert 或 create时,报错:
qemu-img could not open 磁盘文件
问题:当 qemu-img info 磁盘文件存在backing file 项时,会报这个错误。
backing file 来源:当使用qemu-img create创建磁盘时,会创建这个项
另外:当虚拟机正在使用该磁盘时,qemu-img info 磁盘文件时,也会出现这个错误。
关于qemu-img convert:
会创建新格式的磁盘,旧格式的磁盘仍然存在。
关于error: unknown OS type hvm
kernel没有加载模块,检查bios里是否开启了虚拟化
杂项:
1、关闭guest的磁盘监控
# service smartd stop # chkconfig --del smartd