> unallocated_blocks_are_zero is false if there is a backing hd. Same as > has_zero_init.
Peter > Am 03.12.2013 um 16:21 schrieb Paolo Bonzini <pbonz...@redhat.com>: > > Il 03/12/2013 16:09, Kevin Wolf ha scritto: >>>> BDRVQcowState *s = bs->opaque; >>>> + bdi->unallocated_blocks_are_zero = true; >>>> + bdi->can_write_zeroes_with_unmap = (s->qcow_version >= 3); >>>> bdi->cluster_size = s->cluster_size; >>>> bdi->vm_state_offset = qcow2_vm_state_offset(s); >>>> return 0; >> We must change qcow2_discard_clusters() to set the zero flag instead of >> just deallocating the cluster. (We should be doing that anyway, because >> the backing file reappearing isn't very nice.) > > No, that's not needed: > > * unallocated_blocks_are_zero is only meaningful for bs->backing_hd == > NULL (not too intuitive, but I didn't introduce that interface :)). In > fact, v2 was checking backing_hd == NULL but I removed it after Peter > noticed I was being inconsistent. > > * can_write_zeroes_with_unmap correctly returns true only if zero > clusters are enabled > >> For the other formats, I guess this is only correct because they don't >> implement discard anyway? > > No, it is correct because that's what their bdrv_co_readv (or similar) > will return when a block is not allocated and there is no backing file. > Of course, for many formats there will never be a backing file. > > Paolo