nova/nova
Lee Yarwood caca71376f libvirt: Report the allocated size of preallocated file based disks
At present the Libvirt driver can preallocate file based disks using the
fallocate command and importantly the `-n` option. This option allocates
blocks on the filesystem past the initial EOF of a given file:

```
$ touch test.img ; fallocate -n -l $(( 1024 * 1024 )) test.img
$ ll -lah test.img
-rw-rw-r--. 1 stack stack 0 Apr 16 13:28 test.img
$ du -h test.img
1.0M	test.img
```

This results in a miscalculation of the total disk overcommit for file
based (excluding ploop) disks as os.path.getsize is currently used to
determine the allocated size of these disks:

```
>>> import os
>>> os.path.getsize('test.img')
0
```

Using the above example the disk overcommit would be reported as 1.0M as
the disk appears empty yet will report a potential (virtual) size of 1.0M.

However as the required blocks have already been allocated on the
filesystem the host will report disk_available_least as missing an
additional 1.0M, essentially doubling the allocation for each disk.

To correct this the allocated size of file based (excluding ploop) disks
is reported using `disk_size` from the `qemu-img info` command. This
should ensure blocks allocated past the EOF of the file are taken into
account and correctly reported as allocated.

A future change should ultimately remove the use of the `-n` option with
fallocate, however as this would not help disks that have already been
allocated this has not been included in this change to simplify backports.

Conflicts:
        nova/tests/unit/virt/libvirt/test_driver.py

NOTE(lyarwood): I11e329ac5f5fe4b9819fefbcc32ff1ee504fc58b made
get_domain private in Queens.

Change-Id: If642e51a4e186833349a8e30b04224a3687f5594
Closes-bug: #1764489
(cherry picked from commit 23bd8f6263)
(cherry picked from commit 2d50f6e785)
(cherry picked from commit d88b75e81e)
2018-04-17 23:52:23 +01:00
..
CA
api Merge "Fix instance lookup in hide_server_addresses extension" into stable/ocata 2018-02-25 15:28:58 +00:00
cells Use six.text_type() when logging Instance object 2017-05-22 10:57:28 +00:00
cert Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
cloudpipe Rename security_group parameter in compute.API:create 2016-11-10 11:25:43 -05:00
cmd Add 'delete_host' command in 'nova-manage cell_v2' 2018-02-13 00:44:41 +00:00
common cors: update default configuration in config 2016-11-05 20:17:42 -04:00
compute Merge "Don't update RT in _allocate_network" into stable/ocata 2018-02-24 04:49:03 +00:00
conductor Merge "Don't try to delete build request during a reschedule" into stable/ocata 2018-03-23 02:11:42 +00:00
conf Document the real behavior of notify_on_state_change 2017-11-27 12:24:18 +00:00
console Merge "tests: Replace use of CONF with monkey patching" 2017-01-24 12:03:07 +00:00
consoleauth Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
db Merge "Fix joins in instance_get_all_by_host" into stable/ocata 2018-03-21 08:33:10 +00:00
hacking [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
image Merge "[2/3]Replace six.iteritems() with .items()" 2017-01-21 06:55:52 +00:00
ipv6
keymgr Deprecate barbican options 2016-07-29 15:36:28 -05:00
locale Imported Translations from Zanata 2016-10-27 08:19:38 +00:00
network Merge "Handle exception on adding secgroup" into stable/ocata 2018-01-31 12:51:31 +00:00
notifications Merge "[2/3]Replace six.iteritems() with .items()" 2017-01-21 06:55:52 +00:00
objects Lazy-load instance attributes with read_deleted=yes 2018-02-19 16:38:08 -05:00
pci [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
policies Separate CRUD policy for server_groups 2016-11-21 11:43:13 -05:00
scheduler Handle volume-backed instances in IsolatedHostsFilter 2018-02-12 16:04:06 -05:00
servicegroup Don't use 'updated_at' to check service's status 2016-12-08 09:51:03 +00:00
tests libvirt: Report the allocated size of preallocated file based disks 2018-04-17 23:52:23 +01:00
virt libvirt: Report the allocated size of preallocated file based disks 2018-04-17 23:52:23 +01:00
vnc
volume libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot 2018-01-09 01:09:59 +00:00
wsgi Clarify the language in the apache wsgi sample 2017-02-02 15:43:25 -08:00
__init__.py
availability_zones.py Avoid lazy-load error when getting instance AZ 2017-05-31 16:00:42 +00:00
baserpc.py
block_device.py Allow None for block_device_mapping_v2.boot_index 2017-02-09 15:20:06 +00:00
cache_utils.py
config.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
context.py Cache database and message queue connection objects 2017-05-19 21:54:25 +00:00
crypto.py
debugger.py
exception.py libvirt: Always disconnect_volume after rebase failures 2017-04-26 21:25:47 +01:00
exception_wrapper.py do not include context to exception notification 2017-03-17 13:00:21 -04:00
filters.py
hash_ring.py Ironic: allow multiple compute services 2016-08-04 23:51:13 +00:00
hooks.py
i18n.py
loadables.py
manager.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
policy.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
profiler.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
quota.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
rpc.py Merge "Add live.migration.force.complete to the legacy notification whitelist" into stable/ocata 2017-10-24 06:19:51 +00:00
safe_utils.py
service.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
service_auth.py Add service_token for nova-cinder interaction 2017-01-11 15:49:16 +00:00
signature_utils.py
test.py Expose StandardLogging fixture for use 2017-07-26 14:09:26 +00:00
utils.py Use six.text_type() when logging Instance object 2017-05-22 10:57:28 +00:00
version.py
weights.py
wsgi.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00