• E
    storage: support more scaling suffixes · 2e148612
    Eric Blake 提交于
    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.
    2e148612
storage_conf.c 51.0 KB