前言:libvirt和qemu 在centos6 的版本太老,需要升级
一、libvirt rpm安装,相关包可以去url下载。(行尾提供)。另外,老外已经做了个repo 源,直接用也可以。
https://copr.fedorainfracloud.org/coprs/mclarkson/libvirt-1.2.18/
1
2
3
|
curl -o
/etc/yum
.repos.d
/libvirt-1
.2.18.repo \
https:
//copr
.fedoraproject.org
/coprs/mclarkson/libvirt-1
.2.18
/repo/epel-6/mclarkson-libvirt-1
.2.18-epel-6.repo
yum
install
libvirt-1.2.18
|
libvirt.repo
1
2
3
4
5
6
7
8
|
[mclarkson-libvirt-1.2.18]
name=Copr repo
for
libvirt-1.2.18 owned by mclarkson
baseurl=https:
//copr-be
.cloud.fedoraproject.org
/results/mclarkson/libvirt-1
.2.18
/epel-6-
$basearch/
skip_if_unavailable=True
gpgcheck=1
gpgkey=https:
//copr-be
.cloud.fedoraproject.org
/results/mclarkson/libvirt-1
.2.18
/pubkey
.gpg
enabled=1
enabled_metadata=1
|
rpm 下载URL:http://down.51cto.com/data/2196150
二、升级qemu版本
原因:升级libvirt后,启用虚拟机会报错,主要是qemu版本太低
报错:
unable to execute QEMU command 'qom-list'
qemu 需要编译安装
2.1 去官方下载qemu源码
编译前要安装依赖库
1
|
yum
install
glib-devel glibc-devel glib2-devel
|
1
2
3
4
5
6
|
wget http:
//wiki
.qemu-project.org
/download/qemu-1
.5.3.
tar
.bz2
tar
-jxf qemu-1.5.3.
tar
.bz2
cd
qemu-1.5.3
.
/configure
--
enable
-kvm --
enable
-user --
enable
-linux-user --
enable
-guest-base --
enable
-vnc --
enable
-guest-agent
make
-j 10
make
install
|
2.2 qemu编译参数说明:
只支持x86_64架构:--target-list=x86_64-softmmu
如果不添加,默认编译所有平台
参数可以通过命令查看 ./confiugre --help
多cpu同时编译 : make -j 10
2.3 软链命令
原因:从1.3开始,qemu-kvm功能全部整合到qemu。
1
|
ln
-s
/usr/local/bin/qemu-system-x86_64
/usr/libexec/qemu-kvm
|
2.4 如何兼容已有kvm:
centos本身自带的qemu已经修改了支持的机器类型:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
/usr/libexec/qemu-kvm
-M ?
Supported machines are:
pc RHEL 6.6.0 PC (
alias
of rhel6.6.0)
rhel6.6.0 RHEL 6.6.0 PC (default)
rhel6.5.0 RHEL 6.5.0 PC
rhel6.4.0 RHEL 6.4.0 PC
rhel6.3.0 RHEL 6.3.0 PC
rhel6.2.0 RHEL 6.2.0 PC
rhel6.1.0 RHEL 6.1.0 PC
rhel6.0.0 RHEL 6.0.0 PC
rhel5.5.0 RHEL 5.5.0 PC
rhel5.4.4 RHEL 5.4.4 PC
rhel5.4.0 RHEL 5.4.0 PC
|
但是自己编译的qemu 类型如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
/usr/libexec/qemu-kvm
-M ?
Supported machines are:
pc Standard PC (
alias
of pc-1.2)
pc-1.2 Standard PC (default)
pc-1.1 Standard PC
pc-1.0 Standard PC
pc-0.15 Standard PC
pc-0.14 Standard PC
pc-0.13 Standard PC
pc-0.12 Standard PC
pc-0.11 Standard PC, qemu 0.11
pc-0.10 Standard PC, qemu 0.10
isapc ISA-only PC
none empty machine
|
这要修改qemu的源码,去添加RHEL,否则旧有的kvm会启动报错
1
|
libvirtError: internal error: process exited
while
connecting to monitor: qemu-kvm: -machine rhel6.4.0,accel=kvm,usb=off: Unsupported machine
type
|
ps:本人技术有限,源码没找到哪里改。哪位大神能告知??
2.5 曲线救国
修改已有的kvm.xml,去掉machine='rhel****',或者替换为pc-1.2
1
|
<
type
arch=
'x86_64'
machine=
'pc-1.2'
>hvm<
/type
>
|
战狐