Bug 835782 - when create the netfs pool, virsh pool-create-as do not remount the target dir which is mounted for another device firstly.
when create the netfs pool, virsh pool-create-as do not remount the target di...
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
x86_64 Linux
medium Severity high
: rc
: ---
Assigned To: Osier Yang
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2012-06-27 02:13 EDT by Daisy Wu
Modified: 2017-08-30 03:51 EDT (History)
13 users (show)

See Also:
Fixed In Version: libvirt-0.9.13-3.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-02-21 02:18:08 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 16:18:26 EST

  None (edit)
Description Daisy Wu 2012-06-27 02:13:37 EDT
Description of problem:
virsh pool-create-as do not remount the target dir which is mounted for another device firstly.

Version-Release number of selected component (if applicable):

# uname -a
Linux jwu.redhat.com 2.6.32-278.el6.x86_64 #1 SMP Fri Jun 1 14:17:12 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

How reproducible:

Steps to Reproduce:
1. Make sure the dir "/mnt" on the host is mounted for another device firstly, just like
#mount /dev/sda7 /mnt
/dev/sda7 on /mnt type ext4 (rw)

2. create a netfs pool and make sure the target is "/mnt", just like
#virsh pool-create-as pool-nfs --type netfs --source-host --source-path /tmp/libvirt --target /mnt/
Pool pool-nfs created

3. check the status of pool-nfs, it is active.
# virsh pool-list --all
Name                 State      Autostart 
pool-nfs             active     no        

# virsh pool-dumpxml pool-nfs
<pool type='netfs'>
  <capacity unit='bytes'>61926887424</capacity>
  <allocation unit='bytes'>39120146432</allocation>
  <available unit='bytes'>22806740992</available>
    <host name=''/>
    <dir path='/tmp/libvirt'/>
    <format type='auto'/>

4. check the host, the /mnt is not remounted for netfs, it is still mount for /dev/sda7
/dev/sda7 on /mnt type ext4 (rw)

Actual results:
As above.

Expected results:
The /mnt should be remounted for netfs, just like:
/dev/sda7 on /mnt type ext4 (rw) on /mnt type nfs (rw,vers=4,addr=,clientaddr=

Additional info:
1. after step 4,pool-destroy will umount the existing nfs which is not related to the fs pool.

# virsh pool-destroy pool-nfs
Pool pool-nfs destroyed

# mount
no "/dev/sda7 on /mnt type ext4 (rw)" exist.

2. If the /mnt is not mounted for another device firstly, virsh pool-create-as works well.
Comment 2 Osier Yang 2012-06-27 10:33:00 EDT
patch posted upstream.

Comment 3 Osier Yang 2012-06-27 23:56:26 EDT
(In reply to comment #2)
> patch posted upstream.
> https://www.redhat.com/archives/libvir-list/2012-June/msg01252.html

pushed upstream, move to POST.
Comment 5 Daniel Veillard 2012-07-20 02:46:07 EDT
upstream commit:
8116529409357c82824fb280165ea0ee6f2d6277   2012-06-28 11:53:40

Comment 7 Huang Wenlong 2012-07-23 22:46:30 EDT
Verify this bug with : 

#mount /dev/sda3 /mnt/mig 

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              40G  8.0G   30G  22% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda3             9.7G  150M  9.0G   2% /mnt/mig

2) # virsh pool-create-as netfs --type netfs --source-host --source-path /mnt/data/images/ --target /mnt/mig
error: Failed to create pool netfs
error: Requested operation is not valid: Target '/mnt/mig' is already mounted

Report error as expected
Comment 8 errata-xmlrpc 2013-02-21 02:18:08 EST
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.

Comment 9 yalzhang@redhat.com 2016-06-30 02:28:25 EDT
Hi Osier,

The performance of libvirt 1.2.17 is the same. 
But after update libvirt to 1.3.5 currently, the performance changed. 
Not sure if there is any risk.
Please help to check,thank you very much!

Description of problem:
when create the netfs pool, virsh pool-create-as will remount the target dir which is mounted for another device firstly. 
And umount the origin one. After destroy the pool, the local dir will mount again.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
# mount /dev/sda3 /mnt

2. Write something in the /dev/sda3
# ls /mnt
test  test1 lost+found
# mount
/dev/sda3                946M  2.5M  878M   1% /mnt

3. Create a netfs pool mount on /mnt, it will succeed, which is different from before.
# virsh pool-create-as netfs --type netfs --source-host --source-path /tmp/nfs --target /mnt
Pool netfs created
# mount
/dev/sda3 on /mnt type ext4 (rw,relatime,seclabel,data=ordered) on /mnt type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=,local_lock=none,addr=
# ls /mnt
aaa.img  al  rhel6u1-fv-nfs-pool.raw
# df -a
/dev/sda3                       -        -         -    - /mnt      419225600 59729920 359495680  15% /mnt

# virsh destroy netfs
Pool netfs destroyed
# df -a 
/dev/sda3                  967864    2472    899008   1% /mnt
# ls /mnt
test  test1 lost+found
Comment 10 yalzhang@redhat.com 2016-07-20 00:54:43 EDT
It is a kernel feature change.

# mount /dev/sda3 /mnt
# touch /mnt/sda3
# mount /dev/sda4 /mnt ===> the mount will succeed
# touch /mnt/sda4

# mount ====> list historical mounted info
/dev/sda3 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sda4 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)

# df -lh ====> list current mounted info
Filesystem               Size  Used Avail Use% Mounted on
/dev/sda4                 17G   45M   16G   1% /mnt

# umount /mnt  ===>/dev/sda4 will be umounted, and /dev/sda3 will recover

# df -lh
Filesystem               Size  Used Avail Use% Mounted on
/dev/sda3                9.1G   37M  8.6G   1% /mnt
# ll /mnt
total 16
drwx------. 2 root root 16384 Jul 20 12:39 lost+found
-rw-r--r--. 1 root root     0 Jul 20 12:49 sda3

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