]> git.ipfire.org Git - thirdparty/libvirt.git/commit
storage: support more scaling suffixes
authorEric Blake <eblake@redhat.com>
Mon, 5 Mar 2012 21:06:33 +0000 (14:06 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 8 Mar 2012 01:24:43 +0000 (18:24 -0700)
commit2e14861224f4af54fb5747152263c88a6c23fe3b
tree444a473bd845d7bd495b34da7a44e13efbaefb5a
parent265457845fc51f197d9cc0854fa5e9164565f3bb
storage: support more scaling suffixes

Disk manufacturers are fond of quoting sizes in powers of 10,
rather than powers of 2 (after all, 2.1 GB sounds larger than
2.0 GiB, even though the exact opposite is true).  So, we might
as well follow coreutils' lead in supporting three types of
suffix: single letter ${u} (which we already had) and ${u}iB
for the power of 2, and ${u}B for power of 10.

Additionally, it is impossible to create a file with more than
2**63 bytes, since off_t is signed (if you have enough storage
to even create one 8EiB file, I'm jealous).  This now reports
failure up front rather than down the road when the kernel
finally refuses an impossible size.

* docs/schemas/basictypes.rng (unit): Add suffixes.
* src/conf/storage_conf.c (virStorageSize): Use new function.
* docs/formatstorage.html.in: Document it.
* tests/storagevolxml2xmlin/vol-file-backing.xml: Test it.
* tests/storagevolxml2xmlin/vol-file.xml: Likewise.
docs/formatstorage.html.in
docs/schemas/basictypes.rng
src/conf/storage_conf.c
tests/storagevolxml2xmlin/vol-file-backing.xml
tests/storagevolxml2xmlin/vol-file.xml