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 1186969 - Libvirt passes wrong cifs service syntax to mount.cifs when starting netfs pool using cifs format type
Summary: Libvirt passes wrong cifs service syntax to mount.cifs when starting netfs po...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-01-29 02:01 UTC by Yang Yang
Modified: 2015-11-19 06:09 UTC (History)
8 users (show)

Fixed In Version: libvirt-1.2.17-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 06:09:11 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 Yang Yang 2015-01-29 02:01:37 UTC
Description of problem:
Netfs pool using cifs format startup issues 'mount -t cifs 
$service $mount-point'. Libvirt passes 'server:/shareDir' 
as the cifs service pattern. However, mount.cifs can Not 
parse that pattern, it requires '//server/shareDir'
syntax.

Version-Release number of selected component (if applicable):
libvirt-1.2.8-15.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
Prepare a samba server as following
# smbclient -L //10.66.84.12/samba_share
Enter root's password:
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.12]

        Sharename       Type      Comment
        ---------       ----      -------
        samba_share     Disk      Samba share
        IPC$            IPC       IPC Service (Samba Server Version 4.1.12)
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.12]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

1. define a netfs pool using cifs format
# cat nfs-cifs-pool.xml
 <pool type="netfs">
        <name>netfs-cifs</name>
        <source>
          <host name="10.66.84.12"/>
          <dir path="/samba_share"/>
          <format type='cifs'/>
        </source>
        <target>
          <path>/mnt/cifs</path>
        </target>
      </pool>

#virsh pool-define nfs-cifs-pool.xml

2. build the pool
#virsh pool-build netfs-cifs

3. start the pool
# virsh pool-start netfs-cifs
error: Failed to start pool netfs-cifs
error: internal error: Child process (/usr/bin/mount -t cifs 10.66.84.12:/samba_share /mnt/cifs) unexpected exit status 1: 2015-01-28 09:13:37.994+0000: 27911: debug : virFileClose:99 : Closed fd 25
2015-01-28 09:13:37.994+0000: 27911: debug : virFileClose:99 : Closed fd 27
2015-01-28 09:13:37.994+0000: 27911: debug : virFileClose:99 : Closed fd 23
mount.cifs: bad UNC (10.66.84.12:/samba_share)

Actual results:


Expected results:
In step 3. mount.cifs requires '//10.66.84.12/samba_share' syntax
rather than '10.66.84.12:/samba_share'

Additional info:
Generally, user/password is needed when mounting samba server. However,
libvirt does not provides those attributes in netfs pool xml. So libvirt
has to mount samba server in anonymous mode. If so, it requires another
option '-o guest'.

Comment 1 Yang Yang 2015-01-29 02:04:42 UTC
# getsebool -a | grep virt_use_samba
virt_use_samba --> on

Comment 2 John Ferlan 2015-06-03 17:07:59 UTC
Posted a couple patches upstream to resolve:

http://www.redhat.com/archives/libvir-list/2015-June/msg00155.html

Comment 3 John Ferlan 2015-06-16 10:25:00 UTC
After a slight adjustment to original patch, see:

http://www.redhat.com/archives/libvir-list/2015-June/msg00693.html

Pushed upstream:

commit 29230951f1430c196420e8a3a5efbe5ea98f7184
Author: John Ferlan <jferlan>
Date:   Wed Jun 3 10:20:56 2015 -0400

    storage: Generate correct parameters for CIFS
       
    When generating the path to the dir for a CIFS/Samba driver, the code
    would generate a source path for the mount using "%s:%s" while the
    mount.cifs expects to see "//%s/%s". So check for the cifsfs and
    format the source path appropriately.
    
    Additionally, since there is no means to authenticate, the mount
    needs a "-o guest" on the command line in order to anonymously mount
    the Samba directory.


$ git describe 29230951f1430c196420e8a3a5efbe5ea98f7184
v1.2.16-164-g2923095
$

Comment 5 Yang Yang 2015-07-10 09:39:33 UTC
John,

Source dir started with slash. So 1 redundant slash after source hostname is provided in following code. The code generates //10.66.4.164//samba_share while mount.cifs expects //10.66.4.164/samba_share


if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
            if (virAsprintf(&src, "//%s/%s",
                            pool->def->source.hosts[0].name,
                            pool->def->source.dir) == -1)
               return -1;

e.g.
# virsh pool-start netfs-cifs
error: Failed to start pool netfs-cifs
error: internal error: Child process (/usr/bin/mount -t cifs //10.66.4.164//samba_share /tmp/cifs -o guest) unexpected exit status 32: 2015-07-10 09:21:30.082+0000: 29237: debug : virFileClose:102 : Closed fd 28
2015-07-10 09:21:30.082+0000: 29237: debug : virFileClose:102 : Closed fd 30
2015-07-10 09:21:30.082+0000: 29237: debug : virFileClose:102 : Closed fd 26
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Comment 6 Yang Yang 2015-07-10 09:48:41 UTC
Please ignore comment #5

Have a better look at patch, it says the path to the Samba share without the leading slash. I will test again.

Comment 7 Yang Yang 2015-07-10 10:32:21 UTC
Verified with libvirt-1.2.17-1.el7.x86_64

Steps
1. 1. define a netfs pool using cifs format
# cat nfs-cifs-pool.xml
 <pool type="netfs">
        <name>netfs-cifs</name>
        <source>
          <host name="10.66.4.164"/>
          <dir path="samba_share"/>
          <format type='cifs'/>
        </source>
        <target>
          <path>/tmp/cifs</path>
        </target>
      </pool>

#virsh pool-define nfs-cifs-pool.xml

2. build the pool
#virsh pool-build netfs-cifs

3. start the pool
# virsh pool-start netfs-cifs
Pool netfs-cifs started

Comment 8 John Ferlan 2015-07-10 13:33:40 UTC
Just a note that acknowledge I too had the same concern when developing - that is the "leading" slash; however, after researching usage of "relative" vs "absolute" directory path, I decided to follow the existing gluster example which requires the relative path since it felt like the cifs pool would be more alike that than perhaps some sort of "normal" (hah) file system pool.

Comment 10 errata-xmlrpc 2015-11-19 06:09:11 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.