[libvirt] [PATCH v2 4/4] storage: Report error from VolOpen if proper flag is passed

Daniel P. Berrange berrange at redhat.com
Mon Mar 31 19:08:15 UTC 2014


On Mon, Mar 31, 2014 at 02:50:48PM -0400, Cole Robinson wrote:
> diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
> index e02d17f..4d44897 100644
> --- a/src/storage/storage_backend_fs.c
> +++ b/src/storage/storage_backend_fs.c
> @@ -904,8 +907,9 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
>                   * have logged a similar message for the same problem, but only
>                   * if AUTO format detection was used. */
>                  virReportError(VIR_ERR_INTERNAL_ERROR,
> -                               _("cannot probe backing volume info: %s"),
> -                               vol->backingStore.path);
> +                               _("cannot probe backing volume path '%s': %s"),
> +                               vol->backingStore.path,
> +                               virGetLastErrorMessage());

[snip]

> diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
> index 4c2484d..51404ff 100644
> --- a/src/storage/storage_backend_scsi.c
> +++ b/src/storage/storage_backend_scsi.c
> @@ -202,8 +202,8 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
>      if (virStorageBackendUpdateVolInfo(vol, true, true,
>                                         VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("Failed to update volume for '%s'"),
> -                       devpath);
> +                       _("Failed to update volume for '%s': %s"),
> +                       devpath, virGetLastErrorMessage());
>          retval = -1;
>          goto free_vol;

The fact that you can call virGetLastErrorMessage() here is showing that
we're overwriting earlier errors. IMHO use of virGetLastErrorMessage()
is exclusivly for client applicatons / test suites.  We should just not
overwrite the original errors here.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list