免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6112 | 回复: 7
打印 上一主题 下一主题

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

论坛徽章:
0
跳转到指定楼层
1 [收藏(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
2 [报告]
发表于 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
3 [报告]
发表于 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
4 [报告]
发表于 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
5 [报告]
发表于 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
6 [报告]
发表于 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
7 [报告]
发表于 2017-05-11 16:40 |只看该作者
为什么自己发的回复贴有的显示,有的不显示啊

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 10:16:53
8 [报告]
发表于 2017-05-26 19:09 |只看该作者
回复 1# lanfeng356

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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP