virt-install could not open disk image

来源:互联网 发布:vue.js blog 编辑:程序博客网 时间:2024/05/26 02:55

简介

本文介绍如何解决因qemu的用户和组配置错误导致virt-install无法读取磁盘映像问题。

问题描述

在使用virt-install安装虚拟机时,出现无法读取ISO磁盘映像问题,日志如下:
[plain] view plain copy
  1. [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  
  2.   
  3. Starting install...  
  4. Creating storage file centos65.img                                                                           |  10 GB     00:00       
  5. ERROR    internal error Process exited while reading console log output: char device redirected to /dev/pts/4  
  6. 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  
  7.   
  8. Domain installation does not appear to have been successful.  
  9. If it was, you can restart your domain by running:  
  10.   virsh --connect qemu:///system start centos65  
  11. otherwise, please restart your installation.  

问题分析与解决方案

上述“Permission denied”问题,属于用户权限问题,查看/etc/libvirt/qemu.conf配置文件,查找到如下相关的配置项:
[plain] view plain copy
  1. # The user for QEMU processes run by the system instance. It can be  
  2. # specified as a user name or as a user id. The qemu driver will try to  
  3. # parse this value first as a name and then, if the name doesn't exist,  
  4. # as a user id.  
  5. #  
  6. # Since a sequence of digits is a valid user name, a leading plus sign  
  7. # can be used to ensure that a user id will not be interpreted as a user  
  8. # name.  
  9. #  
  10. # Some examples of valid values are:  
  11. #  
  12. #       user = "qemu"   # A user named "qemu"  
  13. #       user = "+0"     # Super user (uid=0)  
  14. #       user = "100"    # A user named "100" or a user with uid=100  
  15. #  
  16. #user = "root"  
  17.   
  18. # The group for QEMU processes run by the system instance. It can be  
  19. # specified in a similar way to user.  
  20. #group = "root"  
需要配置qemu进程的用户和组相关配置,可根据自己的实际情况进行修改,作者将user和group都设置成root:
[plain] view plain copy
  1. # The user for QEMU processes run by the system instance. It can be  
  2. # specified as a user name or as a user id. The qemu driver will try to  
  3. # parse this value first as a name and then, if the name doesn't exist,  
  4. # as a user id.  
  5. #  
  6. # Since a sequence of digits is a valid user name, a leading plus sign  
  7. # can be used to ensure that a user id will not be interpreted as a user  
  8. # name.  
  9. #  
  10. # Some examples of valid values are:  
  11. #  
  12. #       user = "qemu"   # A user named "qemu"  
  13. #       user = "+0"     # Super user (uid=0)  
  14. #       user = "100"    # A user named "100" or a user with uid=100  
  15. #  
  16. user = "root"  
  17.   
  18. # The group for QEMU processes run by the system instance. It can be  
  19. # specified in a similar way to user.  
  20. group = "root"  
配置修改完成后,需要重启libvirtd服务
[plain] view plain copy
  1. [root@CentOS65 ~]# service libvirtd restart  
原创粉丝点击