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