[libvirt] [PATCH 01/11] storage: Introduce virStorageBackendDeviceProbeEmpty

Michal Privoznik mprivozn at redhat.com
Mon Jan 9 15:32:58 UTC 2017


On 12/15/2016 10:42 PM, John Ferlan wrote:
> Rename virStorageBackendFileSystemProbe and to virStorageBackendBLKIDProbe
> and move to the more common storage_backend module.
> 
> Create a shim virStorageBackendDeviceProbeEmpty which will make the call
> to the virStorageBackendBLKIDProbeFS and check the return value.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/storage/storage_backend.c    | 120 +++++++++++++++++++++++++++++++++++++++
>  src/storage/storage_backend.h    |   3 +
>  src/storage/storage_backend_fs.c |  90 +----------------------------
>  3 files changed, 124 insertions(+), 89 deletions(-)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index f2fc038..2432b54 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c

> +/* virStorageBackendDeviceProbeEmpty:
> + * @devpath: Path to the device to check
> + * @format: Desired format string
> + *
> + * Check if the @devpath has some sort of known file system using the
> + * BLKID API if available.
> + *
> + * Returns true if the probe deems the device has nothing valid on it
> + * and returns false if the probe finds something
> + */
> +bool
> +virStorageBackendDeviceProbeEmpty(const char *devpath,
> +                                  const char *format)
> +{
> +    if (virStorageBackendBLKIDProbeFS(devpath, format) ==
> +        FILESYSTEM_PROBE_NOT_FOUND)
> +        true;

return true; /* is what you want here. */

Or even better:

return virStorageBackendBLKIDProbeFS() == FILESYSTEM_PROBE_NOT_FOUND;

> +
> +    return false;
> +}

ACK with that change.

Michal




More information about the libvir-list mailing list