On 10/15/2013 01:25 AM, Fam Zheng wrote: > There is only one failure point: bdrv_change_backing_file in this > function, so we can drop the qlist and try to change the backing file > before deleting anything. > > This way bdrv_drop_intermediate is simplified while keeping the > operation transactional. A bonus is dropping an active BDS is supported > too by swapping the base and top. Although no caller uses this yet, the > comment is updated to reflect the change. > > Signed-off-by: Fam Zheng <f...@redhat.com> > > --- > v2: check for active, top and base being in a backing chain. (Jeff) > > Signed-off-by: Fam Zheng <f...@redhat.com> > --- > block.c | 103 > ++++++++++++++++++++------------------------------------- > block/commit.c | 1 + > 2 files changed, 37 insertions(+), 67 deletions(-) >
> > if (!top->drv || !base->drv) { > goto exit; > } So base->drv is non-NULL if we get here... > + if (active != top) { > + /* If there's an overlay, its backing_hd points to top's BDS now, > + * the top image is dropped but this BDS structure is kept and > swapped > + * with base, this way we keep the pointers valid after dropping top > */ > + overlay = bdrv_find_overlay(active, top); > + if (!overlay) { > + goto exit; > + } > + ret = bdrv_change_backing_file(overlay, base->filename, > + base->drv ? ...yet you are checking it for NULL here. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature