[Libguestfs] [PATCH] lib: Autodetect backing format and specify it explicitly.

Peter Krempa pkrempa at redhat.com
Mon Mar 9 11:09:15 UTC 2020


On Mon, Mar 09, 2020 at 10:40:46 +0000, Richard W.M. Jones wrote:
> On Mon, Mar 09, 2020 at 11:07:20AM +0100, Pino Toscano wrote:
> > On Thursday, 6 February 2020 18:20:19 CET Richard W.M. Jones wrote:

[...]

> > > @@ -302,6 +303,18 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
> > >      }
> > >    }
> > >  
> > > +  /* With libvirt >= 6.0 the backing format must be specified. */
> > > +  if (backingfile != NULL && backingformat == NULL) {
> > > +    backingformat = backingformat_free = guestfs_disk_format (g, backingfile);
> > > +    if (!backingformat)
> > > +      return -1;
> > > +    if (STREQ (backingformat, "unknown")) {
> > > +      error (g, _("could not auto-detect the format of the backing file %s"),
> > > +             backingfile);
> > > +      return -1;
> > > +    }
> > > +  }
> > 
> > I see this patch was pushed, even if it was not reviewed, and in
> > general the problem was more (not totally) on libvirt side.
> > 
> > Was it intentional?
> 
> Yes, I pushed it intentionally.  Peter has a partial fix on the
> libvirt side, but it seems to me they are heading in the direction of
> requiring that the format of backing files in the chain being
> specified.  Since our API specifies that a NULL backing format means
> the format will be autodetected (but not by what), I moved the
> detection to here.

Just a note. The reason I actually started re-thinking the issue was
that offloading the detection would make users come up with their own
and get it wrong. This patch is an example of when the detection is done
in a way which allows insecure behaviour.

See the 'Important' part here:

https://libvirt.org/kbase/backing_chains.html#troubleshooting




More information about the Libguestfs mailing list