简介
本文介绍如何解决因qemu的用户和组配置错误导致virt-install无法读取磁盘映像问题。
问题描述
在使用virt-install安装虚拟机时,出现无法读取ISO磁盘映像问题,日志如下:
- [root@CentOS65 ~]# virt-install --name=centos65 --ram=2048 --vcpu=1 --os-type=linux --hvm --cdrom=/root/CentOS-6.5-x86_64-minimal.iso --file=/home/kvm/centos65.img --file-size=10 --bridge=br0 --vnc --vncport=5920
- Starting install...
- Creating storage file centos65.img | 10 GB 00:00
- ERROR internal error Process exited while reading console log output: char device redirected to /dev/pts/4
- 2016-01-27T08:56:58.986952Z qemu-kvm: -drive file=/root/CentOS-6.5-x86_64-minimal.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /root/CentOS-6.5-x86_64-minimal.iso: Permission denied
- Domain installation does not appear to have been successful.
- If it was, you can restart your domain by running:
- virsh --connect qemu:///system start centos65
- otherwise, please restart your installation.
问题分析与解决方案
上述“Permission denied”问题,属于用户权限问题,查看/etc/libvirt/qemu.conf配置文件,查找到如下相关的配置项:
- # The user for QEMU processes run by the system instance. It can be
- # specified as a user name or as a user id. The qemu driver will try to
- # parse this value first as a name and then, if the name doesn't exist,
- # as a user id.
- #
- # Since a sequence of digits is a valid user name, a leading plus sign
- # can be used to ensure that a user id will not be interpreted as a user
- # name.
- #
- # Some examples of valid values are:
- #
- # user = "qemu" # A user named "qemu"
- # user = "+0" # Super user (uid=0)
- # user = "100" # A user named "100" or a user with uid=100
- #
- #user = "root"
- # The group for QEMU processes run by the system instance. It can be
- # specified in a similar way to user.
- #group = "root"
- # The user for QEMU processes run by the system instance. It can be
- # specified as a user name or as a user id. The qemu driver will try to
- # parse this value first as a name and then, if the name doesn't exist,
- # as a user id.
- #
- # Since a sequence of digits is a valid user name, a leading plus sign
- # can be used to ensure that a user id will not be interpreted as a user
- # name.
- #
- # Some examples of valid values are:
- #
- # user = "qemu" # A user named "qemu"
- # user = "+0" # Super user (uid=0)
- # user = "100" # A user named "100" or a user with uid=100
- #
- user = "root"
- # The group for QEMU processes run by the system instance. It can be
- # specified in a similar way to user.
- group = "root"
配置修改完成后,需要重启libvirtd服务
- [root@CentOS65 ~]# service libvirtd restart