Hide Forgot
Description of problem: when creating vol with owner!=root and vol's allocation_size > pool's available_size, libvirt still created that vol even if an error produced. Version-Release number of selected component (if applicable): kernel-3.10.0-350.el7.x86_64 qemu-kvm-rhev-2.3.0-31.el7_2.7 libvirt-1.3.1-1.el7 How reproducible: 100% steps to reproduce: 1. having a dir pool as follow: # virsh pool-dumpxml test-pool <pool type='dir'> <name>test-pool</name> <uuid>849399e0-3f8b-4652-b003-8a421ad50c08</uuid> <capacity unit='bytes'>42141450240</capacity> <allocation unit='bytes'>31223828480</allocation> <available unit='bytes'>10917621760</available> <source> </source> <target> <path>/tmp/pool</path> <permissions> <mode>0755</mode> <owner>0</owner> <group>0</group> <label>unconfined_u:object_r:user_tmp_t:s0</label> </permissions> </target> </pool> # virsh pool-info test-pool Name: test-pool UUID: 849399e0-3f8b-4652-b003-8a421ad50c08 State: running Persistent: no Autostart: no Capacity: 39.25 GiB Allocation: 29.08 GiB Available: 10.17 GiB <=== left space is 10G 2. prepare a vol xml as follow, set the owner&group to 0 (root), and make sure the vol's allocation size is greater that the pool's available size: # cat 200G_alloc_raw_root.vol <volume type='file'> <name>200G_alloc.img</name> <source> </source> <capacity>214748364800</capacity> <allocation>214748364800</allocation> <!-- 200G --> <target> <path>/tmp/pool/200G_alloc.img</path> <format type='raw'/> <permissions> <mode>0600</mode> <owner>0</owner> <!-- root --> <group>0</group> <label>system_u:object_r:virt_image_t:s0</label> </permissions> </target> </volume> 3. create vol with xml 200G_alloc_raw_root.vol # virsh vol-create test-pool 200G_alloc_raw_root.vol error: Failed to create vol from 200G_alloc_raw_root.vol error: cannot allocate 214748364800 bytes in file '/tmp/pool/200G_alloc.img': No space left on device 4. check the vol in the test-pool # virsh pool-refresh test-pool; virsh vol-list test-pool Pool test-pool refreshed Name Path ------------------------------------------------------------------------------ <==== nothing created as expected. 5. prepare anohter xml as follow and set the owner&group to 107(qemu), and make sure the vol's allocation size is greater that the pool's available size: # cat 200G_alloc_raw_qemu.vol <volume type='file'> <name>200G_alloc.img</name> <source> </source> <capacity>214748364800</capacity> <allocation>214748364800</allocation> <target> <path>/tmp/pool/200G_alloc.img</path> <format type='raw'/> <permissions> <mode>0600</mode> <owner>107</owner> <!-- qemu --> <group>107</group> <label>system_u:object_r:virt_image_t:s0</label> </permissions> </target> </volume> 6. try to create vol with xml 200G_alloc_raw_qemu.vol # virsh vol-create test-pool 200G_alloc_raw_qemu.vol error: Failed to create vol from 200G_alloc_raw_qemu.vol error: cannot allocate 214748364800 bytes in file '/tmp/pool/200G_alloc.img': No space left on device 7. check the vol-list of test-pool # virsh pool-refresh test-pool; virsh vol-list test-pool Pool test-pool refreshed Name Path ------------------------------------------------------------------------------ 200G_alloc.img /tmp/pool/200G_alloc.img <=== even if step 6 failed, img partially created. # du -h /tmp/pool/200G_alloc.img 11G /tmp/pool/200G_alloc.img <=== even if step 6 failed, img partially created. Actually result: Step 6 created a img file. Expected result: Step 6 should not create img file as step 3 did. Note: The only difference of step 3 and step 6 is that the owner/group in the vols' xml files changed. (root vs. qemu)
It may not seems to be a duplicate, but it uses the same function to remove file if something goes wrong. *** This bug has been marked as a duplicate of bug 1260356 ***