On Wed 30 Oct 2019 05:55:04 PM CET, Max Reitz wrote: >> This patch also adds the get/set_l2_bitmap() functions that are used >> to access the bitmaps. For convenience, these functions are no-ops >> when used in traditional qcow2 images. > > Granted, I haven’t seen the following patches yet, but if these > functions are indeed called for images that don’t have subclusters, > shouldn’t they return 0x0*0f*f then? (i.e. everything allocated) > > If they aren’t, they should probably just abort(). Well, > set_l2_bitmap() should probably always abort() if there aren’t any > subclusters.
Yeah, set_l2_bitmap() should abort (I had this changed already). About get_l2_bitmap() ... I decided not to abort for convenience, for cases like this one: uint64_t l2_entry = get_l2_entry(s, l2_slice, l2_index); uint64_t l2_bitmap = get_l2_bitmap(s, l2_slice, l2_index); type = qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, sc); Here the value of l2_bitmap is going to be ignored anyway so it doesn't matter what we return, but perhaps for consistency we should return QCOW_OFLAG_SUB_ALLOC(0), which means that the first (and only, in this case) subcluster is allocated. Berto