Nir Soffer has uploaded a new change for review. Change subject: virt: Report disks stats using libvirt bulk stats ......................................................................
virt: Report disks stats using libvirt bulk stats We used to collect disk apparentsize and truesize using risky storage apis, updating the value once per minute. Turns out that we already fetch the needed info during bulk sampling every 15 seconds. Use the values from the stats cache instead of the drive object. Change-Id: I4139ac1fa2ab5000ba41d3035c7f810cfe2bcbbd Signed-off-by: Nir Soffer <[email protected]> --- M lib/vdsm/virt/vmstats.py M tests/vmStatsTests.py 2 files changed, 28 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/64093/1 diff --git a/lib/vdsm/virt/vmstats.py b/lib/vdsm/virt/vmstats.py index dadbf26..ef2d67a 100644 --- a/lib/vdsm/virt/vmstats.py +++ b/lib/vdsm/virt/vmstats.py @@ -362,12 +362,12 @@ drive_stats = {} try: drive_stats = { - 'truesize': str(vm_drive.truesize), - 'apparentsize': str(vm_drive.apparentsize), 'readLatency': '0', 'writeLatency': '0', 'flushLatency': '0' } + drive_stats.update( + _disk_size(last_sample, last_indexes[vm_drive.name])) if isVdsmImage(vm_drive): drive_stats['imageID'] = vm_drive.imageID elif "GUID" in vm_drive: @@ -408,6 +408,19 @@ return stats +def _disk_size(sample, index): + stats = {} + + for libvirt_name, ovirt_name in ( + ("physical", "apparentsize"), + ("allocation", "truesize"), + ): + key = 'block.%d.%s' % (index, libvirt_name) + stats[ovirt_name] = str(sample.get(key, 0)) + + return stats + + def _disk_rate(first_sample, first_index, last_sample, last_index, interval): stats = {} diff --git a/tests/vmStatsTests.py b/tests/vmStatsTests.py index 9827c4e..6363495 100644 --- a/tests/vmStatsTests.py +++ b/tests/vmStatsTests.py @@ -85,7 +85,8 @@ 'block.1.wr.times': 0, 'block.1.fl.reqs': 0, 'block.1.fl.times': 0, - 'block.1.allocation': 0, + 'block.1.allocation': 268435456, + 'block.1.physical': 1073741824, 'block.1.capacity': 42949672960, }, { @@ -414,6 +415,17 @@ 'writtenBytes', ) + def test_disk_size(self): + drives = (FakeDrive(name='vda', size=700 * 1024 * 1024),) + testvm = FakeVM(drives=drives) + stats = {} + before = copy.deepcopy(self.bulk_stats) + after = copy.deepcopy(self.bulk_stats) + vmstats.disks(testvm, stats, before, after, 10) + drive = stats['disks']['vda'] + self.assertEqual(drive['apparentsize'], '1073741824') + self.assertEqual(drive['truesize'], '268435456') + def test_disk_all_keys_present(self): interval = 10 # seconds drives = (FakeDrive(name='hdc', size=700 * 1024 * 1024),) -- To view, visit https://gerrit.ovirt.org/64093 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4139ac1fa2ab5000ba41d3035c7f810cfe2bcbbd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list -- [email protected] To unsubscribe send an email to [email protected]
