[Libguestfs] [PATCH v2 7/7] lib/canonical-name.c: Hide errors.

Richard W.M. Jones rjones at redhat.com
Thu Sep 17 11:59:23 UTC 2020


On Thu, Sep 17, 2020 at 12:12:43PM +0200, Pino Toscano wrote:
> On Monday, 7 September 2020 11:44:00 CEST Richard W.M. Jones wrote:
> > Fixes “XXX” comment.  This turns out to be necessary in order to
> > suppress a warning when inspecting Windows BitLocker-encrypted guests.
> > 
> > The warning (which still appears in debugging output even with this
> > patch) is:
> > 
> >   libguestfs: error: lvm_canonical_lv_name: /dev/mapper/cryptsda2: not a logical volume
> > ---
> >  lib/canonical-name.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/canonical-name.c b/lib/canonical-name.c
> > index 052bbf12c..11cf6fed6 100644
> > --- a/lib/canonical-name.c
> > +++ b/lib/canonical-name.c
> > @@ -46,8 +46,9 @@ guestfs_impl_canonical_device_name (guestfs_h *g, const char *device)
> >    }
> >    else if (STRPREFIX (device, "/dev/mapper/") ||
> >             STRPREFIX (device, "/dev/dm-")) {
> > -    /* XXX hide errors */
> > +    guestfs_push_error_handler (g, NULL, NULL);
> >      ret = guestfs_lvm_canonical_lv_name (g, device);
> > +    guestfs_pop_error_handler (g);
> 
> Instead of ignoring all the errors from lvm_canonical_lv_name, isn't
> there a way to avoid getting into this situation in the first place?
> Right now it is not ignored, so if anything fails we can immediately
> notice it, which won't happen anymore with the proposed change.

Yes I think we can actually solve this better by returning a known
errno from the underlying lvm_canonical_lv_name API in this case.
That will be in the next version.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list