<div dir="ltr">Just following up, this is indeed an apparmor issue. The attachment work with apparmor disabled. This is a libvirt bug: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1361592">https://bugzilla.redhat.com/show_bug.cgi?id=1361592</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 22, 2016 at 2:26 PM, Erlon Cruz <span dir="ltr"><<a href="mailto:sombrafam@gmail.com" target="_blank">sombrafam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If that was the case I wouldn't be able to attach a volume without snapshots. But just in case I did the following test, before attaching the file, I copied all the file to a local folder and changed the path in XML with the new paths. The problem repeats: <div><br></div><div><b>2016-08-22 17:14:19.795+0000: 3799: info : qemuMonitorIOProcess:423 : QEMU_MONITOR_IO_PROCESS: mon=0x7f68f800c4c0 buf={"return": "Could not open backing file: Could not open '/home/ubuntu/volumes/volume-<wbr>d81f7e7e-4215-4433-aad2-<wbr>50adcd31b29d.7a9ea169-a3ab-<wbr>48bd-bd9d-e7585860abe4': Permission denied\r\n", "id": "libvirt-30"}</b><br></div><div><b><br></b></div><div>But, if I use the top backing file with same permissions (/home/ubuntu/volumes/volume-<wbr>d81f7e7e-4215-4433-aad2-<wbr>50adcd31b29d), the operation suceeds. Can this be a libvirt/QEMU bug?</div><div><br></div><div>Han, can you tell me more details about the commands you used and the versions of or libvirt/qemu? I couldn't reproduce from the steps you outlined.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 19, 2016 at 12:02 AM, Han Han <span dir="ltr"><<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Erlon,<br>
Since you say you got Permission denied error while the ACL mode is 777, I guess it is due to security system like selinux or apparmor.<br>
As I know, selinux defaultly will disable qemu to use volume based on NFS. We need to use 'setsebool virt_use_nfs 1' to enable it.<br>
Well, your OS is ubuntu, so I think apparmor causes the permission problem. Try to find a way to enable virt_use_nfs or disable apparmor. Then check if the problem can be reproduced.<br>
<span><br>
Han<br>
<br>
----- Original Message -----<br>
From: "Erlon Cruz" <<a href="mailto:sombrafam@gmail.com" target="_blank">sombrafam@gmail.com</a>><br>
</span><span>To: "Han Han" <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>><br>
Cc: "Yang Yang" <<a href="mailto:yanyang@redhat.com" target="_blank">yanyang@redhat.com</a>>, "Yuan Dan" <<a href="mailto:dyuan@redhat.com" target="_blank">dyuan@redhat.com</a>>, "Xuesong Zhang" <<a href="mailto:xuzhang@redhat.com" target="_blank">xuzhang@redhat.com</a>>, <a href="mailto:libvirt-users@redhat.com" target="_blank">libvirt-users@redhat.com</a><br>
Sent: Thursday, 18 August, 2016 12:44:36 PM<br>
Subject: Re: [libvirt-users] Attaching disks with external snapshots<br>
<br>
Hi Han,<br>
<br>
Any update on this?<br>
<br>
Erlon<br>
<br>
On Wed, Aug 17, 2016 at 9:58 AM, Erlon Cruz <<a href="mailto:sombrafam@gmail.com" target="_blank">sombrafam@gmail.com</a>> wrote:<br>
<br>
> Han,<br>
><br>
> Did the same test again with libvirt debug enabled. This time I added the<br>
> disk[1] without snaps (OK), and then added the disk[2] with snapshots. The<br>
> libvirt log[3] (line 320) says:<br>
><br>
</span>> *Could not open<br>
> '/opt/stack/data/nova/mnt/a3b4<wbr>c6ddd9bf82edd4f726872be58d05/<wbr>volume-a75b42e8-8175-4516-b724<wbr>-43ee6f3d2520':<br>
> Permission denied\r\n", "id": "libvirt-33"}]*<br>
<div><div>><br>
> But this file has 777 permissions. I can access it with any user I<br>
> tried[4]. Tough its mounted over NFS, the permissions seems to be right.<br>
><br>
> Erlon<br>
><br>
> [1]  <a href="http://paste.openstack.org/show/556055/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556055/</a><br>
> [2]  <a href="http://paste.openstack.org/show/556056/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556056/</a><br>
> [3]  <a href="http://pastebin.com/CCFcKq5b" rel="noreferrer" target="_blank">http://pastebin.com/CCFcKq5b</a><br>
> [4]  <a href="http://paste.openstack.org/show/559018/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/559018/</a><br>
><br>
><br>
> On Tue, Aug 16, 2016 at 2:41 PM, Erlon Cruz <<a href="mailto:sombrafam@gmail.com" target="_blank">sombrafam@gmail.com</a>> wrote:<br>
><br>
>> Hi Han,<br>
>><br>
>> Thanks for helping. What is the XML before the snapshot is created? Can<br>
>> you post the XML files you used too? The files are in the links pointed by<br>
>> the numbers [1], [2] etc.<br>
>><br>
>> The versions are:<br>
>> qemu-system-x86_64 --version<br>
>> QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.4), Copyright<br>
>> (c) 2003-2008 Fabrice Bellard<br>
>><br>
>> libvirtd --version<br>
>> libvirtd (libvirt) 1.3.1<br>
>><br>
>><br>
>><br>
>> Erlon<br>
>><br>
>> On Mon, Aug 15, 2016 at 12:56 AM, Han Han <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>> wrote:<br>
>><br>
>>> Hi,Erlon<br>
>>> I was not able to reproduce your problem. It is ok to attach disk with<br>
>>> external snapshot.<br>
>>> I did it with following steps:<br>
>>> # qemu-img create /tmp/vdb 100M<br>
>>> Formatting '/tmp/vdb', fmt=raw size=104857600<br>
>>> # virsh start snap<br>
>>> Domain snap started<br>
>>> # virsh snapshot-create-as snap s1 --disk-only --diskspec<br>
>>> vdb,file=/tmp/vdb.s1 --quiesce<br>
>>> Domain snapshot s1 created<br>
>>> # virsh dumpxml snap|awk '/<disk/,/<\/disk/'<br>
>>>     <disk type='file' device='disk'><br>
>>>       <driver name='qemu' type='qcow2' cache='none'/><br>
>>>       <source file='/var/lib/libvirt/images/<wbr>snap.s1'/><br>
>>>       <backingStore type='file' index='1'><br>
>>>         <format type='qcow2'/><br>
>>>         <source file='/var/lib/libvirt/images/<wbr>snap.qcow2'/><br>
>>>         <backingStore/><br>
>>>       </backingStore><br>
>>>       <target dev='vda' bus='virtio'/><br>
>>>       <alias name='virtio-disk0'/><br>
>>>       <address type='pci' domain='0x0000' bus='0x00' slot='0x07'<br>
>>> function='0x0'/><br>
>>>     </disk><br>
>>>     <disk type='file' device='disk'><br>
>>>       <driver name='qemu' type='qcow2'/><br>
>>>       <source file='/tmp/vdb.s1'/><br>
>>>       <backingStore type='file' index='1'><br>
>>>         <format type='raw'/><br>
>>>         <source file='/tmp/vdb'/><br>
>>>         <backingStore/><br>
>>>       </backingStore><br>
>>>       <target dev='vdb' bus='virtio'/><br>
>>>       <alias name='virtio-disk1'/><br>
>>>       <address type='pci' domain='0x0000' bus='0x00' slot='0x0c'<br>
>>> function='0x0'/><br>
>>>     </disk><br>
>>><br>
>>> Save the dumped vdb's xml to /tmp/vdb.xml<br>
>>> # virsh detach-device snap /tmp/vdb.xml<br>
>>> Device detached successfully<br>
>>> # virsh attach-device snap /tmp/vdb.xml<br>
>>> Device attached successfully<br>
>>> # virsh dumpxml snap|awk '/<disk/,/<\/disk/'<br>
>>>     <disk type='file' device='disk'><br>
>>>       <driver name='qemu' type='qcow2' cache='none'/><br>
>>>       <source file='/var/lib/libvirt/images/<wbr>snap.s1'/><br>
>>>       <backingStore type='file' index='1'><br>
>>>         <format type='qcow2'/><br>
>>>         <source file='/var/lib/libvirt/images/<wbr>snap.qcow2'/><br>
>>>         <backingStore/><br>
>>>       </backingStore><br>
>>>       <target dev='vda' bus='virtio'/><br>
>>>       <alias name='virtio-disk0'/><br>
>>>       <address type='pci' domain='0x0000' bus='0x00' slot='0x07'<br>
>>> function='0x0'/><br>
>>>     </disk><br>
>>>     <disk type='file' device='disk'><br>
>>>       <driver name='qemu' type='qcow2'/><br>
>>>       <source file='/tmp/vdb.s1'/><br>
>>>       <backingStore type='file' index='1'><br>
>>>         <format type='raw'/><br>
>>>         <source file='/tmp/vdb'/><br>
>>>         <backingStore/><br>
>>>       </backingStore><br>
>>>       <target dev='vdb' bus='virtio'/><br>
>>>       <alias name='virtio-disk1'/><br>
>>>       <address type='pci' domain='0x0000' bus='0x00' slot='0x0c'<br>
>>> function='0x0'/><br>
>>>     </disk><br>
>>><br>
>>> So I managed to attach disks with snapshot.<br>
>>> I want to know what is your libvirt and qemu-kvm version?<br>
>>> And can you provide your files: /tmp/disk.xml[1],<br>
>>> /tmp/snap-from-disk.xml[2], /tmp/disk-with-snap.xml[4],<br>
>>> /tmp/disk-with-snap.xml . I need more details.<br>
>>><br>
>>> Han Han<br>
>>><br>
>>> ----- Original Message -----<br>
>>> From: "Erlon Cruz" <<a href="mailto:sombrafam@gmail.com" target="_blank">sombrafam@gmail.com</a>><br>
>>> To: <a href="mailto:libvirt-users@redhat.com" target="_blank">libvirt-users@redhat.com</a><br>
>>> Sent: Friday, August 12, 2016 10:23:24 AM<br>
>>> Subject: [libvirt-users] Attaching disks with external snapshots<br>
>>><br>
>>> Hi folks,<br>
>>><br>
>>> I'm trying to to attach a disk to an instance using libvirt. The problem<br>
>>> is, this disk has external snapshots. The process tried was:<br>
>>><br>
>>> 1 - Attach a disk in the domain:<br>
>>> virsh# attach-device instance-00000006 /tmp/disk.xml[1] --live<br>
>>><br>
>>> 2 - Snapshot the disk[2]:<br>
>>> virsh# snapshot-create instance-00000006 --quiesce --xmlfile<br>
>>> /tmp/snap-from-disk.xml[2] --disk-only<br>
>>><br>
>>> 3 - Dump the domain XML and create a new disk file from it:<br>
>>> virsh# dumpxml instance-00000006<br>
>>> ... [3]<br>
>>><br>
>>> 4 - Dettach the device and re-add it using the new disk file:<br>
>>> virsh# detach-device instance-00000006 /tmp/disk-with-snap.xml[4]<br>
>>> Device detached successfully<br>
>>> virsh# attach-device instance-00000006 /tmp/disk-with-snap.xml<br>
>>> error: Failed to attach device from /tmp/disk-with-snap.xml<br>
>>> error: internal error: unable to execute QEMU command 'device_add':<br>
>>> Property 'virtio-blk-device.drive' can't find value 'drive-virtio-disk1'<br>
>>><br>
>>> Question, is this operation supported? If yes, how is the correct<br>
>>> procedure?<br>
>>><br>
>>> Erlon<br>
>>><br>
>>><br>
>>> [1] <a href="http://paste.openstack.org/show/556055/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556055/</a><br>
>>> [2] <a href="http://paste.openstack.org/show/556056/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556056/</a><br>
>>> [3] <a href="http://paste.openstack.org/show/556063/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556063/</a><br>
>>> [4] <a href="http://paste.openstack.org/show/556064/" rel="noreferrer" target="_blank">http://paste.openstack.org/sho<wbr>w/556064/</a><br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> libvirt-users mailing list<br>
>>> <a href="mailto:libvirt-users@redhat.com" target="_blank">libvirt-users@redhat.com</a><br>
>>> <a href="https://www.redhat.com/mailman/listinfo/libvirt-users" rel="noreferrer" target="_blank">https://www.redhat.com/mailman<wbr>/listinfo/libvirt-users</a><br>
>>><br>
>><br>
>><br>
><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>