Bug 781515

Summary: virsh vol-path can't correctly display which pool a volume belongs to
Product: [Community] Virtualization Tools Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: high    
Version: unspecifiedCC: crobinso, cwei, dyuan, jtomko, mzhan, pkrempa, rbalakri, xen-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-16 17:04:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2012-01-13 16:20:20 UTC
Description of problem:
As summary. 

Version-Release number of selected component (if applicable):
# rpm -q libvirt
libvirt-0.9.9-1.el6.x86_64

How reproducible:
always

Steps to Reproduce:

# cat /tmp/pool-dir.xml 
<pool type="dir">
  <name>pool-dir</name>
  <source/>
  <target>
    <path>/var/lib/libvirt/images/pool-dir</path>
  </target>
</pool>

# virsh pool-define /tmp/pool-dir.xml 
Pool pool-dir defined from /tmp/pool-dir.xml

# virsh pool-build pool-dir
Pool pool-dir built

# virsh pool-start pool-dir
Pool pool-dir started

# virsh pool-list
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
pool-dir             active     no        

# qemu-img create /var/lib/libvirt/images/foo.img 10M
Formatting '/var/lib/libvirt/images/foo.img', fmt=raw size=10485760

# virsh pool-refresh default
Pool default refreshed

# virsh vol-list default
Name                 Path                                    
-----------------------------------------
foo.img              /var/lib/libvirt/images/foo.img         
pool-dir             /var/lib/libvirt/images/pool-dir        

# virsh vol-list pool-dir
Name                 Path                                    
-----------------------------------------


# virsh vol-path --pool default /var/lib/libvirt/images/foo.img
/var/lib/libvirt/images/foo.img

# virsh vol-path --pool pool-dir /var/lib/libvirt/images/foo.img
/var/lib/libvirt/images/foo.img

Note, in fact, pool-dir is a empty pool, but vol-path thinks volume foo.img belongs to it.
  
Actual results:
virsh vol-path says empty pool has a volume path /var/lib/libvirt/images/foo.img.

Expected results:
fix it.

Additional info:

Comment 3 Ján Tomko 2015-03-16 17:04:59 UTC
commit 6ef0b03483281659f2e1e321da9c56c97e05a305
Author:     Peter Krempa <pkrempa>
AuthorDate: 2014-05-30 14:44:55 +0200
Commit:     Peter Krempa <pkrempa>
CommitDate: 2014-06-02 10:56:49 +0200

    virsh: Check whether found volume is member of the specified storage pool
    
    When looking up storage volumes virsh uses multiple lookup steps. Some
    of the steps don't require a pool name specified. This resulted into a
    possibility that a volume would be part of a different pool than the
    user specified:
    
    Let's have a /var/lib/libvirt/images/test.qcow image in the 'default'
    pool and a second pool 'emptypool':
    
    Currently we'd return:
      $ virsh vol-info --pool emptypool /var/lib/libvirt/images/test.qcow
      Name:           test.qcow
      Type:           file
      Capacity:       100.00 MiB
      Allocation:     212.00 KiB
    
    After the fix:
     $ tools/virsh vol-info --pool emptypool /var/lib/libvirt/images/test.qcow
     error: Requested volume '/var/lib/libvirt/images/test.qcow' is not in pool 'emptypool'
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1088667

git describe: v1.2.5-3-g6ef0b03 contains: v1.2.6-rc1~239