QEMU3.1.0版本编译升级

qemu-system-x86_64创建虚拟机时报错:

(process:577): GLib-WARNING **: 22:52:20.197: gmem.c:489: custom memory allocation vtable not supported
qemu-system-x86_64: -hda /gao/kvm-fw1.qcow2: could not open disk image /gao/kvm-fw1.qcow2: Could not open ‘/gao/kvm-fw1.qcow2’: No such file or directory

连查看QEMU版本2.0.0都报错:

[root@localhost ~]# qemu-system-x86_64 --version
(process:634): GLib-WARNING **: 22:53:58.680: gmem.c:489: custom memory allocation vtable not supported
QEMU emulator version 2.0.0, Copyright © 2003-2008 Fabrice Bellard
[root@localhost ~]#

问题原因是:
qemu版本低,跟glibc的版本不兼容导致问题,解决的思路大致有两个:
1、downgradding glibc,但是可能会对系统造成影响,导致向下兼容的一些新版本软件可能存在问题
2、使用新版本的qemu,从qemu2.0更新到qemu2.7以上,patch这个漏洞;

我们采取第二种方法,升级QEMU,操作步骤如下:

1、卸载原有的QEMU:

[root@localhost /]# yum -y remove qemu-kvm

由于有依赖的关系,除了卸掉qemu-kvm,还卸掉相关的一些东西

2、依赖的一些安装包:

[root@localhost /]# yum install gcc gcc-c+ automake libtool zlib-devel glib2-devel bzip2-devel libuuid-devel spice-protocol spice-server-devel usbredir-devel libaio-devel

3、源码下载及编译安装:

[root@localhost /]# wget https://download.qemu.org/qemu-3.1.0.tar.xz
[root@localhost /]# tar -xvf qemu-3.1.0.tar.xz
[root@localhost /]# cd /qemu-3.1.0
[root@localhost qemu-3.1.0/]# ./configure //prefix可设置安装路径,默认路径为/usr/local
[root@localhost qemu-3.1.0/]# make
[root@localhost qemu-3.1.0/]# make install

由于前面默认路径安装qemu时,没有进行prefix设定,它会默认装在/usr/local下:

[root@localhost qemu-3.1.0]# ls -l /usr/local/
total 4
drwxr-xr-x. 2 root root 4096 Apr 19 23:16 bin
drwxr-xr-x. 2 root root 6 Nov 5 2016 etc
drwxr-xr-x. 2 root root 6 Nov 5 2016 games
drwxr-xr-x. 2 root root 6 Nov 5 2016 include
drwxr-xr-x. 2 root root 6 Nov 5 2016 lib
drwxr-xr-x. 2 root root 6 Nov 5 2016 lib64
drwxr-xr-x. 2 root root 32 Apr 19 23:15 libexec
drwxr-xr-x. 2 root root 6 Nov 5 2016 sbin
drwxr-xr-x. 6 root root 61 Apr 19 23:11 share
drwxr-xr-x. 2 root root 6 Nov 5 2016 src
drwxr-xr-x. 3 root root 17 Apr 19 23:11 var

4、创建链接:
qemu-system-x86_64等可执行程序都在/usr/local/bin下,原版本程序在/usr/bin下,可以删除后重新做软连接,也可以删除后全部拷贝覆盖:

[root@localhost /]# ln -s /usr/local/bin/qemu-system-x86_64 /usr/bin/qemu-system-x86_64
[root@localhost /]# ln -s /usr/local/bin/qemu-img /usr/bin/qemu-img

5、版本验证:

[root@localhost qemu-3.1.0]# qemu-system-x86_64 --version
QEMU emulator version 3.1.0
Copyright © 2003-2018 Fabrice Bellard and the QEMU Project developers

Qemu 1.0.1 Windows QEMU emulator version 1.0.1, Copyright (c) 2003-2008 Fabrice Bellard usage: qemu [options] [disk_image] 'disk_image' is a raw hard disk image for IDE hard disk 0 Standard options: -h or -help display this help and exit -version display version information and exit -machine [type=]name[,prop[=value][,...]] selects emulated machine (-machine ? for list) property accel=accel1[:accel2[:...]] selects accelerator supported accelerators are kvm, xen, tcg (default: tcg) -cpu cpu select CPU (-cpu ? for list) -smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets] set the number of CPUs to 'n' [default=1] maxcpus= maximum number of total cpus, including offline CPUs for hotplug, etc cores= number of CPU cores on one socket threads= number of threads on one CPU core sockets= number of discrete sockets in the system -numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node] -fda/-fdb file use 'file' as floppy disk 0/1 image -hda/-hdb file use 'file' as IDE hard disk 0/1 image -hdc/-hdd file use 'file' as IDE hard disk 2/3 image -cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] [,cache=writethrough|writeback|none|directsync|unsafe][,format=f] [,serial=s][,addr=A][,id=name][,aio=threads|native] [,readonly=on|off] use 'file' as a drive image -set group.id.arg=value set parameter for item of type i.e. -set drive.$id.file=/path/to/image -global driver.property=value set a global default for a driver property -mtdblock file use 'file' as on-board Flash memory image -sd file use 'file' as SecureDigital card image -pflash file use 'file'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值