On 11/17/2015 11:15 PM, Vladimir Sementsov-Ogievskiy wrote: >> You may want to compare to the qcow2 spec, which also lists expected >> byte offsets for each field (rather than having to count how many >> earlier fields of which widths were specified). > > I've compared qed spec with qcow2 spec and like the first one. What the > need of specifying each offset? Creating a c-structure is simpler when > you see types. and than offsetof and sizeof may be used if needed. > Nobody will #define numeric offsets I think.
You'd be surprised (libvirt has some hard-coded numeric offsets: https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/virstoragefile.c;h=2aa1d90;hb=5ed7afa9d#l159) Also, listing offsets makes it obvious that you are NOT relying on compiler padding, and makes it obvious whether you have been careful that all 64-bit quantities are 8-byte-aligned without wasting space. The original cow format (not qcow or qcow2) has the awful distinction of NOT having specified offsets, and had different layouts on 32-bit platforms than it did on 64-bit platforms; hence, we retired it in commit 550830f9 as unsupportable. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
