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 serviceservice 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 4Apr 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=505625Everytime the virGetCapabilities() method is run, it destroys the existingvirCapsPtr object and creates it again....without any of the selinux info.virt-manager runs this method. so once virt-manager has run, subsequent callsto get the security info willgive the crash you see.
二、有关网络http://wiki.libvirt.org/page/Networking1、一般网络(又名NAT):guest可以访问外网,外网不能访问guest。安装了libvirt后,一个NAT网络即可用。host被设置为192.168.122.1(virbr0),所有的guest将被分配为192.168.122.x如果看不到virbr0或者在virsh start <Name of KVM>时出现下面的错误:Apr 22 08:50:37 srv4 libvirtd: 08:50:37.839: error : internal error Failed to add tap interface 'vnet%d' to bridge 'virbr0' : No such device
查看/var/log/message.logApr 22 08:57:10 srv4 dnsmasq[26000]: failed to open pidfile /var/run/libvirt/network/default.pid: Permission deniedApr 22 08:57:10 srv4 dnsmasq[26000]: FAILED to start up
手动启动default networkvirsh net-start defaulterror: Failed to start network defaulterror: internal error '/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --listen-address 192.168.122.1 --except-interface lo --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-lease-max=253'exited with non-zero status 3 and signal 0: dnsmasq: failed to open pidfile /var/run/libvirt/network/default.pid: Permission denied解决办法:我的当前系统:selinux-policy.noarch 2.4.6-203.el5 yum updata selinux-policy.noarchselinux-policy.noarch 2.4.6-279.el5_5.2 service libvirtd restart注:需要重启host,上面写了原因
# ifconfig virbr0
virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
2、Bridge网络(又名:共享物理网卡):guest可以访问外网,外网也可以访问guest# cd /etc/sysconfig/network-scripts/# cp ifcfg-eth0 ifcfg-br0 两个配置文件内容分别为:/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=br0
/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=221.193.136.121
NETMASK=255.255.255.0
ONBOOT=yes
The NM_CONTROLLED=no option was added because both device should not be controlled by the Network Manager for bridge to work. 重启network(当前连接会丢失,确保你总是可以访问host,否则要格外小心)service network restart
关于错误:Bringing up interface eth0: tg3 device eth0 does not seem to be present, delaying initialization.原因:br0里没有加配置 TYPE=Bridge
对于rhel6和centos6,需要关闭NetworkManager service NetworkManager stopchkconfig --level 35 NetworkManager offDisable Netfilter processing in the bridged traffic.在/etc/sysctl.conf文件中添加:
7、有关OSx86架构: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 toRedhat:
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 fullyvirtualized 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
补充:可以定义多个磁盘,其他可行的磁盘定义:Logical volume device:
默认分配192.168.122.x/24的地址,也可以手动指定。网关为192.168.122.1
使用virtio:采用普通的驱动,即硬盘和网卡都采用默认配置情况下,硬盘是ide 模式,而网卡工作在 模拟的rtl 8139 网卡下,速度为100M 全双工。采用 virtio 驱动后,网卡工作在 1000M 的模式下,硬盘工作是SCSI模式下。rhel5.6 guest with virtio interface can not boot successfully if the system installation would use the ide interfacehttps://bugzilla.redhat.com/show_bug.cgi?id=647387
16、定义与guset交互的图形设备。在这个例子中,使用vnc协议。listen的地址为host的地址。prot为-1,表示自动分配端口号,通过以下的命令查找端口号:virsh vncdisplay <KVM Guest Name> 注意:是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.