On 1/31/19 7:46 AM, Andrey Shinkevich wrote: > In the 'Format specific information' section of the 'qemu-img info' > command output, the supplemental information about existing QCOW2 > bitmaps will be shown, such as a bitmap name, flags and granularity: >
> + > +static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags) > +{ > + Qcow2BitmapInfoFlagsList *list = NULL; > + Qcow2BitmapInfoFlagsList **plist = &list; > + int i; > + > + static const struct { > + int bme; /* Bitmap directory entry flags */ > + int info; /* The flags to report to the user */ > + } map[] = { > + { BME_FLAG_IN_USE, QCOW2_BITMAP_INFO_FLAGS_IN_USE }, > + { BME_FLAG_AUTO, QCOW2_BITMAP_INFO_FLAGS_AUTO }, > + }; > + > + int map_size = sizeof(map) / sizeof(map[0]); We have the ARRAY_SIZE() macro for this. > + > + for (i = 0; i < map_size; ++i) { > + if (flags & map[i].bme) { > + Qcow2BitmapInfoFlagsList *entry = > + g_new0(Qcow2BitmapInfoFlagsList, 1); > + entry->value = map[i].info; > + *plist = entry; > + plist = &entry->next; > + flags &= ~map[i].bme; > + } > + } > + /* Check if the BME_* mapping above is complete */ > + assert(!flags); > + > + info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS); > + info->unknown_flags = bm->flags & BME_RESERVED_FLAGS; > + info->has_unknown_flags = !!info->unknown_flags; Glad you liked my idea for better sanity checking. If that's the only change needed, I don't mind making it as part of staging for a pull request (of course, review comments on 3/3 may still result in a v12 for other reasons). Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature