RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1244080 - Fail to create dir pool from virt-manager when the target path already exist
Summary: Fail to create dir pool from virt-manager when the target path already exist
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-17 03:35 UTC by tingting zheng
Modified: 2015-11-19 06:48 UTC (History)
10 users (show)

Fixed In Version: libvirt-1.2.17-3.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 06:48:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description tingting zheng 2015-07-17 03:35:22 UTC
Description:
Fail to create dir pool from virt-manager when the target path already exist

Version:
libvirt-python-1.2.17-1.el7.x86_64
libvirt-1.2.17-2.el7.x86_64
virt-manager-1.2.1-2.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1.Create a directory,eg:/var/lib/libvirt/images/test

2.Launch virt-manager,create a dir pool named test,set the "Target Path" as an already existing directory,eg:the directory created in step 1.
Error shows:
Error creating pool: Could not build storage pool: failed to create directory '/var/lib/libvirt/images/test': File exists

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 89, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createpool.py", line 446, in _async_pool_create
    poolobj = self._pool.install(create=True, meter=meter, build=build)
  File "/usr/share/virt-manager/virtinst/storage.py", line 533, in install
    raise RuntimeError(errmsg)
RuntimeError: Could not build storage pool: failed to create directory '/var/lib/libvirt/images/test': File exists

3.The same error shows when I use pool-build to build a pool with already exist directory.
# cat test.xml
<pool type='dir'>
  <name>test</name>
  <source>
  </source>
  <target>
    <path>/var/lib/libvirt/images/test</path>
    <permissions>
      <mode>0711</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>

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

# virsh pool-build test
error: Failed to build pool test
error: internal error: child failed to create '/var/lib/libvirt/images/test': exit status 17

Actual results:
As description.

Expected results:
Virt-manager can create pool with existing target path.

Additional info:
https://www.redhat.com/archives/libvir-list/2015-July/msg00602.html

Comment 2 Christophe Fergeau 2015-07-17 08:29:29 UTC
https://www.redhat.com/archives/libvir-list/2015-July/msg00627.html should hopefully fix that.

Comment 3 John Ferlan 2015-07-21 13:25:00 UTC
A patch was pushed upstream:

$ git show 60d5ed8c520462fd8fbc2d8dfac7b7c16ae5eb51
commit 60d5ed8c520462fd8fbc2d8dfac7b7c16ae5eb51
Author: Christophe Fergeau <cfergeau>
Date:   Fri Jul 17 10:02:20 2015 +0200

    storage: Fix pool building when directory already exists
    
    Currently, when trying to virsh pool-define/virsh pool-build a new
    'dir' pool, if the target directory already exists, virsh
    pool-build/virStoragePoolBuild will error out. This is a change of
    behaviour compared to eg libvirt 1.2.13
    
    This is caused by the wrong type being used for the dir_create_flags
    variable in virStorageBackendFileSystemBuild , it's defined as a bool
    but is used as a flag bit field so should be unsigned int (this matches
    the type virDirCreate expects for this variable).
    
    This should fix https://bugzilla.gnome.org/show_bug.cgi?id=752417 (GNOME
    Boxes) and https://bugzilla.redhat.com/show_bug.cgi?id=1244080
    (downstream virt-manager).
$ git describe 60d5ed8c520462fd8fbc2d8dfac7b7c16ae5eb51
v1.2.17-124-g60d5ed8
$

Comment 6 yisun 2015-08-25 06:29:30 UTC
test on:
libvirt-1.2.17-6.el7.x86_64
virt-manager-1.2.1-6.el7

VERIFIED. 


Steps:
pure libvirt:
1. # cat dir.pool 
<pool type='dir'>
  <name>test</name>
  <source>
  </source>
  <target>
    <path>/var/lib/libvirt/images/</path>
    <permissions>
      <mode>0711</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>

2. # ll /var/lib/libvirt/images
total 3649748
-rw-r--r--. 1 qemu qemu     197120 Aug  5 16:14 1.qcow2
-rw-r--r--. 1 root root    1048576 Aug 19 21:25 cdrom.img

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

4. # virsh pool-build test
Pool test built

5. # virsh pool-start test
Pool test started

6. # virsh vol-list test
 Name                 Path                                    
------------------------------------------------------------------------------
 1.qcow2              /var/lib/libvirt/images/1.qcow2         
 cdrom.img            /var/lib/libvirt/images/cdrom.img    


virt-manager:
1.Create a directory,/mnt
2.Click "Add Pool" button during creating new VM
3.Target path set to "/mnt"
4.Click OK and pool successfully created.

Comment 8 errata-xmlrpc 2015-11-19 06:48:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


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