f23d4bb storage: Fix implementation of no-overwrite for file system backend

Authored and Committed by John Ferlan 7 years ago
    storage: Fix implementation of no-overwrite for file system backend
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1363586
    
    Commit id '27758859' introduced the "NO_OVERWRITE" flag check for
    file system backends; however, the implementation, documentation,
    and algorithm was inconsistent. For the "flag" description for the
    API the flag was described as "Do not overwrite existing pool";
    however, within the storage backend code the flag is described
    as "it probes to determine if filesystem already exists on the
    target device, renurning an error if exists".
    
    The code itself was implemented using the paradigm to set up the
    superblock probe by creating a filter that would cause the code
    to only search for the provided format type. If that type wasn't
    found, then the algorithm would return success allowing the caller
    to format the device. If the format type already existed on the
    device, then the code would fail indicating that the a filesystem
    of the same type existed on the device.
    
    The result is that if someone had a file system of one type on the
    device, it was possible to overwrite it if a different format type
    was specified in updated XML effectively trashing whatever was on
    the device already.
    
    This patch alters what NO_OVERWRITE does for a file system backend
    to be more realistic and consistent with what should be expected when
    the caller requests to not overwrite the data on the disk.
    
    Rather than filter results based on the expected format type, the
    code will allow success/failure be determined solely on whether the
    blkid_do_probe calls finds some known format on the device. This
    adjustment also allows removal of the virStoragePoolProbeResult
    enum that was under utilized.
    
    If it does find a formatted file system different errors will be
    generated indicating a file system of a specific type already exists
    or a file system of some other type already exists.
    
    In the original virsh support commit id 'ddcd5674', the description
    for '--no-overwrite' within the 'pool-build' command help output
    has an ambiguous "of this type" included in the short description.
    Compared to the longer description within the "Build a given pool."
    section of the virsh.pod file it's more apparent that the meaning
    of this flag would cause failure if a probe of the target already
    has a filesystem.
    
    So this patch also modifies the short description to just be the
    antecedent of the 'overwrite' flag, which matches the API description.
    This patch also modifies the grammar in virsh.pod for no-overwrite
    as well as reworking the paragraph formats to make it easier to read.
    
    Signed-off-by: John Ferlan <jferlan@redhat.com>
    
        
file modified
+30 -38
file modified
+1 -1
file modified
+18 -14