忘记密码   免费注册 查看新帖 | 论坛精华区

ChinaUnix.net

  平台 论坛 博客 认证专区 大话IT HPC论坛 徽章 文库 沙龙 自测 下载 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 2568 | 回复: 7

[KVM] qemu-img 创建的image无法启动虚机 [复制链接]

论坛徽章:
0
发表于 2017-05-11 16:07 |显示全部楼层
使用命令qemu-img create -f qcow2 -o backing_file=/image/slave1.raw ubuntu-test.qcow2 40G



创建了一个虚拟机镜像,然后使用virsh start ubuntu-test的时候,报错

2017-05-11 07:56:15.700+0000: starting up libvirt version: 1.3.1, package: 1ubuntu10.8 (Christian Ehrhardt <christian.ehrhardt@canonical.com> Mon, 06 Feb 2017 14:30:46 +0100), qemu version: 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10., hostname: master
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -name ubuntu-test -S -machine pc-0.14,accel=kvm,usb=off -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 9f76ff69-122d-43a8-bf9a-f1e13afcf6c9 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-ubuntu-test/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -boot order=c,menu=on,strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/image/ubuntu-test.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,fd=26,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=fa:95:d4:1d:8c:d9,bus=pci.0,addr=0x3 -netdev tap,fd=28,id=hostnet1 -device rtl8139,netdev=hostnet1,id=net1,mac=52:54:d4:1d:8c:d9,bus=pci.0,addr=0x6 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 0.0.0.0:0 -k en-us -device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-iscsi.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-curl.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-rbd.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-dmg.so
Note: only modules from the same build can be loaded.
char device redirected to /dev/pts/1 (label charserial0)
2017-05-11T07:56:15.781909Z qemu-system-x86_64: -drive file=/image/ubuntu-test.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,cache=none: Could not open backing file: Could not open '/image/slave1.raw': Permission denied
2017-05-11 07:56:28.166+0000: shutting down

不知道为什么报Permission denied的错误,我把文件修改成777也不行。原始的slave1a.raw我是能启动起来的,新的ubuntu-test.qcow2就无法启动。有能帮忙分析一下吗?刚接触虚拟化,还请指导。

论坛徽章:
0
发表于 2017-05-11 16:12 |显示全部楼层
我的XML文件指定的disk格式是:

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/image/ubuntu-test.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
    </disk>

论坛徽章:
0
发表于 2017-05-11 16:13 |显示全部楼层
XML文件里指定的文件格式如下:

   <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/image/ubuntu-test.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
    </disk>

论坛徽章:
0
发表于 2017-05-11 16:36 |显示全部楼层
问题已经解决,应该是一个BUG导致的。
执行两条命令:
$ sudo apt-get install apparmor-profiles apparmor-utils$ sudo aa-complain /usr/lib/libvirt/virt-aa-helper
问题源地址:https://github.com/adrahon/vagrant-kvm/issues/163

BUG描述:
Ubuntu

Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm to fail with a permission error on vagrant up. It is a kernel bug with the AppArmor security framework. As a workaround, please run following command to disable access control for libvirt helper.

sudo aa-complain /usr/lib/libvirt/virt-aa-helper

论坛徽章:
0
发表于 2017-05-11 16:38 |显示全部楼层
Ubuntu

Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm to fail with a permission error on vagrant up. It is a kernel bug with the AppArmor security framework. As a workaround, please run following command to disable access control for libvirt helper.

sudo aa-complain /usr/lib/libvirt/virt-aa-helper

论坛徽章:
0
发表于 2017-05-11 16:39 |显示全部楼层
问题已经解决,应该是一个KVM的BUG
解决方法如下:
$ sudo apt-get install apparmor-profiles apparmor-utils
$ sudo aa-complain /usr/lib/libvirt/virt-aa-helper

引用原帖地址:https://github.com/adrahon/vagrant-kvm/issues/163

论坛徽章:
0
发表于 2017-05-11 16:40 |显示全部楼层
为什么自己发的回复贴有的显示,有的不显示啊

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 10:16:53
发表于 2017-05-26 19:09 |显示全部楼层
回复 1# lanfeng356

我一般是用virt-install把相关的系统做到qcow2中,然后把qcow2放OpenStack的nova去管理。
直接用virsh貌似是不行的,取消相关的驱动,无法驱动实例
您需要登录后才可以回帖 登录 | 注册

本版积分规则

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号 北京市公安局海淀分局网监中心备案编号:11010802020122
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP