[libvirt] [PATCH 1/3] storage: Alter logic when both BLKID and PARTED unavailable

Peter Krempa pkrempa at redhat.com
Fri Jan 13 15:01:09 UTC 2017


On Fri, Jan 13, 2017 at 07:59:08 -0500, John Ferlan wrote:
> If neither BLKID or PARTED is available and we're not writing, then
> just return 0 which allows the underlying storage pool to generate
> a failur. If both are unavailable and we're writing, then generate

failure

> a more generic error message.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/storage/storage_backend.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index 18433e9..6bdfbf1 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -2842,9 +2842,6 @@ virStorageBackendBLKIDFindEmpty(const char *device ATTRIBUTE_UNUSED,
>                                  const char *format ATTRIBUTE_UNUSED,
>                                  bool writelabel ATTRIBUTE_UNUSED)
>  {
> -    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> -                   _("probing for filesystems is unsupported "
> -                     "by this build"));
>      return -2;
>  }
>  
> @@ -2868,11 +2865,10 @@ virStorageBackendPARTEDValidLabel(const char *device ATTRIBUTE_UNUSED,
>                                    const char *format ATTRIBUTE_UNUSED,
>                                    bool writelabel ATTRIBUTE_UNUSED)
>  {
> -    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> -                   _("PARTED is unsupported by this build"));
> -    return -1;
> +    return -2;
>  }
>  
> +
>  #endif /* #if WITH_STORAGE_DISK */
>  
>  
> @@ -2898,5 +2894,17 @@ virStorageBackendDeviceIsEmpty(const char *devpath,
>                                                 writelabel)) == -2)
>          ret = virStorageBackendPARTEDValidLabel(devpath, format, writelabel);
>  
> +    /* Neither BLKID nor PARTED available, but we're not writing,
> +     * so no mechanism to check, so allow a lower layer to reject. */

I think you removed too many words here when compared to the commit
message so it stopped making sense.

> +    if (ret == -2 && !writelabel)
> +        return 0;
> +
> +    if (ret == -2) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       _("Unable to probe '%s' for existing data, "
> +                         "requires create/build using overwrite"),

I'd state "forced overwrite is necessary" or something along that points
to the flag even for direct API users.

ACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170113/5298ce18/attachment-0001.sig>


More information about the libvir-list mailing list