Skip to content

Commit

Permalink
vm: Log changes in drive extension info
Browse files Browse the repository at this point in the history
Each time drives' capacity, allocation, or physical change, log a debug
log with the new values. This log will allow easy debugging when lower
level component misbehave.

Here is an example log when starting a VM:

2017-08-02 02:54:24,468+0300 DEBUG (periodic/0) [virt.vm]
(vmId='f33a7fbc-3dab-448c-bb41-204eccee70ba') Extension info for drive
sda volume 13b40805-a43b-4c0e-9a0b-0c03a2e4ecbb:
BlockInfo(capacity=8589934592L, allocation=0L, physical=1073741824L) (vm:1057)

The allocation value is 0, since qemu did not write anything yet to this
drive. Once qemu write to the drive, we get the correct allocation:

2017-08-02 02:54:38,473+0300 DEBUG (periodic/1) [virt.vm]
(vmId='f33a7fbc-3dab-448c-bb41-204eccee70ba') Extension info for drive
sda volume 13b40805-a43b-4c0e-9a0b-0c03a2e4ecbb:
BlockInfo(capacity=8589934592L, allocation=2490368L, physical=1073741824L)
(vm:1057)

Change-Id: I68701bcb1b83295f346139b2aed64b9221a4ee44
Bug-Url: https://bugzilla.redhat.com/1461536
Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Aug 8, 2017
1 parent 8c11924 commit b718903
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/vdsm/virt/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,14 @@ def _getExtendInfo(self, drive):
replica["volumeID"])
physical = volsize.apparentsize

return capacity, alloc, physical
blockinfo = vmdevices.storage.BlockInfo(capacity, alloc, physical)

if blockinfo != drive.blockinfo:
drive.blockinfo = blockinfo
self.log.debug("Extension info for drive %s volume %s: %s",
drive.name, drive.volumeID, blockinfo)

return blockinfo

def _shouldExtendVolume(self, drive, volumeID, capacity, alloc, physical):
nextPhysSize = drive.getNextVolumeSize(physical, capacity)
Expand Down
12 changes: 11 additions & 1 deletion lib/vdsm/virt/vmdevices/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def __init__(self, path, index):
['uuid', 'path', 'allocation', 'index'])


BlockInfo = collections.namedtuple("BlockInfo", [
"capacity", # guest virtual size
"allocation", # host allocated size (highest allocated offset)
"physical" # host physical size (lv size, file size)
])


class Drive(core.Base):
__slots__ = ('iface', '_path', 'readonly', 'bootOrder', 'domainID',
'poolID', 'imageID', 'UUID', 'volumeID', 'format',
Expand All @@ -102,7 +109,7 @@ class Drive(core.Base):
'volumeChain', 'baseVolumeID', 'serial', 'reqsize', 'cache',
'extSharedState', 'drv', 'sgio', 'GUID', 'diskReplicate',
'_diskType', 'hosts', 'protocol', 'auth', 'discard',
'vm_custom')
'vm_custom', 'blockinfo')
VOLWM_CHUNK_SIZE = (config.getint('irs', 'volume_utilization_chunk_mb') *
constants.MEGAB)
VOLWM_FREE_PCT = 100 - config.getint('irs', 'volume_utilization_percent')
Expand Down Expand Up @@ -217,6 +224,9 @@ def __init__(self, log, **kwargs):
self.cache = config.get('vars', 'qemu_drive_cache')
self.discard = kwargs.get('discard', False)

# Used for chunked drives or drives replicating to chunked replica.
self.blockinfo = None

self._customize()
self._setExtSharedState()

Expand Down

0 comments on commit b718903

Please sign in to comment.