summaryrefslogtreecommitdiff
path: root/ceilometer/compute
diff options
context:
space:
mode:
authorzhang-shaoman <zhang.shaoman@zte.com.cn>2019-03-08 14:48:40 +0800
committerzhang-shaoman <zhang.shaoman@zte.com.cn>2019-04-23 18:58:12 +0800
commit194c8828640543ccf66ebe367f4a0fb4917a6b63 (patch)
tree8372c2809563a9ee334fe019a52ce856e22a3661 /ceilometer/compute
parent062e02c612d1fdd8c40b9209319b32e04489c163 (diff)
downloadceilometer-194c8828640543ccf66ebe367f4a0fb4917a6b63.tar.gz
disk capacity is less than disk usage
If the virtual machine mounts cd-rom, libvirt will align by 4K bytes, causing the disk capacity is less than the disk usage, which does not seem reasonable. Maybe we shoulde use the bigger one as disk capacity. Change-Id: I25808856bce27483da0cb2583ae94e8dc162d647 Closes-Bug: #1819107
Diffstat (limited to 'ceilometer/compute')
-rwxr-xr-xceilometer/compute/virt/libvirt/inspector.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py
index 1ef5b58a..a83cbdb2 100755
--- a/ceilometer/compute/virt/libvirt/inspector.py
+++ b/ceilometer/compute/virt/libvirt/inspector.py
@@ -154,8 +154,12 @@ class LibvirtInspector(virt_inspector.Inspector):
domain = self._get_domain_not_shut_off_or_raise(instance)
for device in self._get_disk_devices(domain):
block_info = domain.blockInfo(device)
+ # if vm mount cdrom, libvirt will align by 4K bytes, capacity may
+ # be smaller than physical, avoid with this.
+ # https://libvirt.org/html/libvirt-libvirt-domain.html
+ disk_capacity = max(block_info[0], block_info[2])
yield virt_inspector.DiskInfo(device=device,
- capacity=block_info[0],
+ capacity=disk_capacity,
allocation=block_info[1],
physical=block_info[2])