Ignore:
Timestamp:
Feb 17, 2009, 5:01:23 AM (15 years ago)
Author:
andersk
Message:

Don't confuse {KB, MB, GB} with {KiB, MiB, GiB}.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-remote/host/usr/sbin/invirt-availability

    r2114 r2161  
    99import os
    1010
    11 # return the amount of memory in kilobytes represented by s
     11# return the amount of memory in kibibytes represented by s
    1212def parseUnits(s):
    1313    num, unit = s.split(' ')
    14     return int(num) * {'kb':1, 'mb':1024}[unit.lower()]
     14    assert unit == 'kB', "unexpected unit"
     15    return int(num)
    1516
    1617def main(argv):
    1718    """
    1819    Calculate the amount of memory available for new VMs
    19     The numbers returned by xm info and xm info -c are in MB
    20     The numbers in /proc/xen/balloon have nice units
    21     All math is done in kilobytes for consistency
    22     Output is in MB
     20    The numbers returned by xm info and xm info -c are in MiB
     21    The numbers in /proc/xen/balloon are in KiB
     22    All math is done in kibibytes for consistency
     23    Output is in MiB
    2324
    2425    Bail if /etc/invirt/nocreate exists
     
    5152    xminfoc = yaml.load(output, yaml.CSafeLoader)
    5253
    53     # In kilobytes
     54    # In kibibytes
    5455    dom0minmem = int(xminfoc['dom0-min-mem']) * 1024
    5556
Note: See TracChangeset for help on using the changeset viewer.