Bug 496579 - libvirt: cannot delete storage pool
Summary: libvirt: cannot delete storage pool
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: libvirt
Version: 5.4
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Laine Stump
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 525073
TreeView+ depends on / blocked
 
Reported: 2009-04-20 07:04 UTC by Nan Zhang
Modified: 2010-03-30 08:10 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 525073 (view as bug list)
Environment:
Last Closed: 2010-03-30 08:10:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
python script for deleting storage pool (533 bytes, text/plain)
2009-04-20 07:04 UTC, Nan Zhang
no flags Details
patch to fix the problem (711 bytes, patch)
2009-12-12 07:10 UTC, Laine Stump
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2010:0205 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2010-03-29 12:27:37 UTC

Description Nan Zhang 2009-04-20 07:04:21 UTC
Created attachment 340293 [details]
python script for deleting storage pool

Description of problem:
An exception throw when delete an inactive storage pool.

Version-Release number of selected component (if applicable):
rhel5u3: 2.6.18-128.1.6.el5xen
libvirt-0.6.2-1.el5

How reproducible:
Always

Steps to Reproduce:
1. Create a storage pool
2. Inactive the pool
3. Remove the pool
  
Actual results:
# python storage_pooldelete.py test
libvir: Storage error : cannot unlink path '/pool': Is a directory
-- OR --
# virsh pool-delete test
error: Failed to delete pool test
error: cannot unlink path '/pool': Is a directory

Expected results:
storage pool can be deleted successfully.

Additional info:

Comment 1 Alex Jia 2009-06-10 02:13:04 UTC
this issue is still existent with libvirt-0.6.3-6.el5 on rhel5.4

[root@dhcp-66-70-18 libvirt]# uname -r
2.6.18-151.el5xen
[root@dhcp-66-70-18 libvirt]# rpm -qa|grep libvirt
libvirt-debuginfo-0.6.3-6.el5
libvirt-cim-0.5.5-1.el5
libvirt-0.6.3-6.el5
libvirt-devel-0.6.3-6.el5
libvirt-python-0.6.3-6.el5

Comment 2 Daniel Berrangé 2009-10-29 17:19:24 UTC
Can you provide the XML config of the storage pool you are trying to delete. This sounds like a real bug to me, we just need to figure out which particular scenario this is hitting in

Comment 3 Alex Jia 2009-10-30 02:43:23 UTC
Hi,Daniel

nfs storage pool config is as following:

<?xml version='1.0' encoding='UTF-8'?>
<pool type='netfs'>
  <name>nfspool</name>
  <source>
    <host name='10.66.71.226'/>
    <dir path='/vol/libvirt1/auto'/>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
  </target>
</pool>




additional information:

[root@dhcp-66-70-97 xml]# rpm -qa|grep libvirt
libvirt-0.6.3-20.1.el5_4
libvirt-devel-0.6.3-20.1.el5_4
libvirt-0.6.3-20.1.el5_4
libvirt-python-0.6.3-20.1.el5_4
libvirt-cim-0.5.5-2.el5
libvirt-devel-0.6.3-20.1.el5_4
[root@dhcp-66-70-97 xml]# uname -a
Linux dhcp-66-70-97.nay.redhat.com 2.6.18-164.2.1.el5xen #1 SMP Mon Sep 21 04:45:50 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@dhcp-66-70-97 xml]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open(None)
>>> print conn.getCapabilities()
<capabilities>

  <host>
    <cpu>
      <arch>x86_64</arch>
      <features>
        <vmx/>
      </features>
    </cpu>
    <migration_features>
      <live/>
      <uri_transports>
        <uri_transport>xenmigr</uri_transport>
      </uri_transports>
    </migration_features>
    <topology>
      <cells num='1'>
        <cell id='0'>
          <cpus num='2'>
            <cpu id='0'/>
            <cpu id='1'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>

  <guest>
    <os_type>xen</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <machine>xenpv</machine>
      <domain type='xen'>
      </domain>
    </arch>  </guest>

  <guest>
    <os_type>xen</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <machine>xenpv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <pae/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <loader>/usr/lib/xen/boot/hvmloader</loader>
      <machine>xenfv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <pae/>
      <nonpae/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='yes'/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <loader>/usr/lib/xen/boot/hvmloader</loader>
      <machine>xenfv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='yes'/>
    </features>
  </guest>
</capabilities>

>>> fp = open("netfspool.xml")
>>> stgxml = fp.read()
>>> print stgxml
<?xml version='1.0' encoding='UTF-8'?>
<pool type='netfs'>
  <name>nfspool</name>
  <source>
    <host name='10.66.71.226'/>
    <dir path='/vol/libvirt1/auto'/>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
  </target>
</pool>

>>> stg = conn.storagePoolDefineXML(stgxml, 0)
>>> dir(stg)
['UUID', 'UUIDString', 'XMLDesc', '__del__', '__doc__', '__init__',
'__module__', '_conn', '_o', 'autostart', 'build', 'connect', 'create',
'createXML', 'delete', 'destroy', 'info', 'listVolumes', 'name',
'numOfVolumes', 'ref', 'refresh', 'setAutostart', 'storageVolLookupByName',
'undefine']
>>> stg.info()
[0, 0L, 0L, 0L]
>>> conn.listDefinedStoragePools()
['nfspool']
>>> stg.delete(0)
libvir: Storage error : cannot unlink path '/var/lib/libvirt/images': Is a
directory
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/site-packages/libvirt.py", line 748, in delete
    if ret == -1: raise libvirtError ('virStoragePoolDelete() failed',
pool=self)
libvirt.libvirtError: cannot unlink path '/var/lib/libvirt/images': Is a
directory

Comment 4 Nan Zhang 2009-10-30 07:32:23 UTC
This is the XML config of the pool which I trying to delete:

<pool type="dir">
  <name>test-dir</name>
  <target>
    <path>/var/lib/xen/images</path>
  </target>
</pool>

Comment 5 Laine Stump 2009-12-12 07:10:18 UTC
Created attachment 377844 [details]
patch to fix the problem

The equivalent patch has also been posted upstream, but not yet ACKed or committed:

https://www.redhat.com/archives/libvir-list/2009-December/msg00283.html

Explanation: unlink() will not remove a directory, rmdir() is the proper function to call. The error message has also been made slightly more informative. Note that it's intentional that the contents of the directory aren't deleted automatically - this has the effect of requiring that all volumes in the pool be deleted before the pool itself can be deleted.

Comment 6 Daniel Veillard 2009-12-15 15:49:16 UTC
libvirt-0.6.3-25.el5 has been built in dist-5E-qu-candidate with the fix,

Daniel

Comment 8 Alex Jia 2009-12-16 08:56:48 UTC
This bug has been verified with libvirt 0.6.3-25.el5 on RHEL-5.4.but I haven't permission change bug status to verified.

Comment 9 Alex Jia 2009-12-16 10:39:10 UTC
Additional information:

[root@dhcp-66-70-91 xml]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open(None)
>>> print conn.getCapabilities()
<capabilities>

  <host>
    <cpu>
      <arch>x86_64</arch>
      <features>
        <vmx/>
      </features>
    </cpu>
    <migration_features>
      <live/>
      <uri_transports>
        <uri_transport>xenmigr</uri_transport>
      </uri_transports>
    </migration_features>
    <topology>
      <cells num='1'>
        <cell id='0'>
          <cpus num='2'>
            <cpu id='0'/>
            <cpu id='1'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>

  <guest>
    <os_type>xen</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <machine>xenpv</machine>
      <domain type='xen'>
      </domain>
    </arch>
  </guest>

  <guest>
    <os_type>xen</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <machine>xenpv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <pae/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <loader>/usr/lib/xen/boot/hvmloader</loader>
      <machine>xenfv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <pae/>
      <nonpae/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='yes'/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
      <loader>/usr/lib/xen/boot/hvmloader</loader>
      <machine>xenfv</machine>
      <domain type='xen'>
      </domain>
    </arch>
    <features>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='yes'/>
    </features>
  </guest>

</capabilities>

>>> fp = open("nfspool.xml")
>>> stgxml = fp.read()
>>> print stgxml
<?xml version='1.0' encoding='UTF-8'?>
<pool type='netfs'>
  <name>nfspool</name>
  <source>
    <host name='10.66.90.115'/>
    <dir path='/vol/libvirt1/auto'/>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
  </target>
</pool>


>>> stg = conn.storagePoolDefineXML(stgxml, 0)
>>> stg.info()
[0, 0L, 0L, 0L]
>>> stg.delete(0)
0

Comment 10 Nan Zhang 2009-12-16 11:15:32 UTC
Verified with libvirt 0.6.3-25.el5 on RHEL-5.4, it's already fixed.

# virsh pool-define dir.xml
Pool test-dir defined from dir.xml

# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
pool-mig             inactive   no        
pool-migration       inactive   no        
test-dir             inactive   no        

# virsh pool-delete test-dir
Pool test-dir deleted

Comment 16 errata-xmlrpc 2010-03-30 08:10:57 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0205.html


Note You need to log in before you can comment on or make changes to this bug.