Bug 1366460
| Summary: | When "pool-build --overwrite" a block device as a whole partition with filesystem=ext2/ext3/ext4/vfat, it will fail because libvirt call "mkfs" command without "-F/-I"(Force) | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | yisun |
| Component: | libvirt | Assignee: | John Ferlan <jferlan> |
| Status: | CLOSED ERRATA | QA Contact: | Pei Zhang <pzhang> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.3 | CC: | dyuan, jferlan, rbalakri, xuzhang, yanyang, yisun |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-2.5.0-1.el7 | Doc Type: | No Doc Update |
| Doc Text: |
undefined
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-08-01 17:11:42 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Now pushed:
$ git show
commit 135e77d32fe9e7299f5c82757563e5a6d28e2f3c
Author: John Ferlan <jferlan>
Date: Tue Nov 15 15:29:47 2016 -0500
fs: Add proper switch to create filesystem with overwrite
...
When using the --overwrite switch on a pool-build or pool-create, the
The mkfs.ext{2|3|4} commands use mke2fs which requires using the '-F' switch
in order to force overwriting the current filesystem on the whole disk.
Likewise, the mkfs.vfat command uses mkfs.fat which requires using the '-I'
switch in order to force overwriting the current filesystem on the whole disk.
$ git describe 135e77d32fe9e7299f5c82757563e5a6d28e2f3c
v2.4.0-154-g135e77d
$
Version :
libvirt-3.0.0-2.el7.x86_64
qemu-kvm-rhev-2.8.0-4.el7.x86_64
Verified steps :
1. Prepare a disk
# lsscsi
[15:0:0:0] disk LIO-ORG target4 4.0 /dev/sdb
2. make the sdb as xfs file system.
# mkfs.xfs /dev/sdb -f
3.Prepare a pool's xml with format type is ext4 :
# cat fspool.xml
<pool type='fs'>
<name>fs</name>
<uuid>5c7433cf-acf3-4c36-8300-65d5b2a18d01</uuid>
<capacity unit='bytes'>0</capacity>
<allocation unit='bytes'>0</allocation>
<available unit='bytes'>0</available>
<source>
<device path='/dev/sdb'/>
<format type='ext4'/>
</source>
<target>
<path>/var/lib/libvirt/images/fs</path>
</target>
</pool>
4. Define the pool
# virsh pool-define fspool.xml
Pool fs defined from fspool.xml
5. Build the pool with --overwrite, build successfully
# virsh pool-build fs --overwrite
Pool fs built
6. Check the block device, the file system was changed tp ext4 successfully.
# parted /dev/sdb p
......
Number Start End Size File system Flags
1 0.00B 32.2GB 32.2GB ext4
7. using pool-edit gto change the format to ext3
# virsh pool-edit fs
Pool fs XML configuration edited.
8. build agian with --overwrite
# virsh pool-build fs --overwrite
Pool fs built
9. Check the block device, the file system was changed to ext3 successfully
# parted /dev/sdb p
......
Number Start End Size File system Flags
1 0.00B 32.2GB 32.2GB ext3
10. Trying to change format to ext2/vfat. They also can be changed successfully.
As above, move this bug to verified.
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://access.redhat.com/errata/RHEA-2017:1846 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://access.redhat.com/errata/RHEA-2017:1846 |
Description: When "pool-build --overwrite" a block device as a whole partition with filesystem=ext2/ext3/ext4/vfat, it will fail because libvirt call "mkfs" command without "-F/-I"(Force) Versions: libvirt-2.0.0-5.el7.x86_64 How reproducible: 100% Steps: please note, the "Force" option for mkfs.vfat is "-I", for mkfs.ext2/3/4 is "-F" and for mkfs.xfs is "-f" 1. I used a usb disk in my test. # lsscsi [7:0:0:0] disk SanDisk Cruzer Blade 1.26 /dev/sdg 2. mkfs the sdg as xfs file system. # mkfs.xfs /dev/sdg -f 3. prepare a pool's xml as follow: # cat fs.pool <pool type='fs'> <name>fs</name> <uuid>5c7433cf-acf3-4c36-8300-65d5b2a18d01</uuid> <capacity unit='bytes'>0</capacity> <allocation unit='bytes'>0</allocation> <available unit='bytes'>0</available> <source> <device path='/dev/sdg'/> <format type='ext4'/> <======= here can be ext4/ext3/ext2/vfat </source> <target> <path>/var/lib/libvirt/images/fs</path> </target> </pool> 4. Define the pool # virsh pool-define fs.pool Pool fs defined from fs.pool 5. try to build the pool with --overwrite # virsh pool-build fs --overwrite error: Failed to build pool fs error: Failed to make filesystem of type 'ext4' on device '/dev/sdg': Success 6. now, in libvirtd.log, we can see libvirt try to use "/usr/sbin/mkfs -t ext4 /dev/sdg" #cat /var/log/libvirtd-debug.log ... 2016-08-11 11:15:16.932+0000: 3819: debug : virCommandRunAsync:2429 : About to run /usr/sbin/mkfs -t ext4 /dev/sdg ... 7. check the /dev/sdg # parted /dev/sdg p Model: SanDisk Cruzer Blade (scsi) Disk /dev/sdg: 8004MB Sector size (logical/physical): 512B/512B Partition Table: loop Disk Flags: Number Start End Size File system Flags 1 0.00B 8004MB 8004MB xfs <==== still xfs Expected result: with --overwrite option, pool-build should successfully mkfs the whole block device. As above step 6, if libvirt use "/usr/sbin/mkfs -t ext3 -F /dev/sdg" (a "-F" added"), the pool-build should be successful. Actual result: pool-build failed (and error message is strange with a "Success") Additional info: pool-build --overwrite a xfs pool is ok because the mkfs cmd has a "-f" # tailf /var/log/libvirtd-debug.log | grep xfs 2016-08-11 10:55:11.520+0000: 3819: debug : virStorageBackendMakeFileSystem:763 : source device: '/dev/sdg' format: 'xfs' 2016-08-11 10:55:11.520+0000: 3819: debug : virCommandRunAsync:2429 : About to run /usr/sbin/mkfs -t xfs -f /dev/sdg