Adam Litke has uploaded a new change for review. Change subject: LiveMerge: Debug blockjob lifecycle ......................................................................
LiveMerge: Debug blockjob lifecycle Change-Id: I81bfc022d37a6bcdfae6fafdac352e7b40b09d15 Signed-off-by: Adam Litke <ali...@redhat.com> --- M vdsm/clientIF.py M vdsm/vm.py 2 files changed, 38 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/26766/1 diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py index 74f2f47..dc9232d 100644 --- a/vdsm/clientIF.py +++ b/vdsm/clientIF.py @@ -24,6 +24,7 @@ import pickle from xml.dom import minidom import uuid +import json import alignmentScan from vdsm.config import config @@ -233,6 +234,7 @@ binding.start() while self._enabled: time.sleep(3) + self.tickFakeBlockJobs() def _getUUIDSpecPath(self, uuid): try: @@ -571,3 +573,29 @@ v.log.warning('unknown eventid %s args %s', eventid, args) except: self.log.error("Error running VM callback", exc_info=True) + + def getFakeBlockJobs(self): + try: + with open('/tmp/blockJobs.json') as f: + return json.loads(f.read()) + except (IOError, OSError, ValueError): + return {} + + def setFakeBlockJobs(self, jobs): + with open('/tmp/blockJobs.json', 'w') as f: + f.write(json.dumps(jobs)) + + def tickFakeBlockJobs(self): + jobs = self.getFakeBlockJobs() + for jobId in jobs.keys(): + if jobs[jobId]['cur'] >= jobs[jobId]['end']: + vmId = jobs[jobId]['vmId'] + path = jobs[jobId]['path'] + del jobs[jobId] + v = self.vmContainer.get(vmId) + v._onBlockJobEvent(path, + libvirt.VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, + libvirt.VIR_DOMAIN_BLOCK_JOB_COMPLETED) + else: + jobs[jobId]['cur'] = jobs[jobId]['cur'] + 1 + self.setFakeBlockJobs(jobs) diff --git a/vdsm/vm.py b/vdsm/vm.py index 2f276f4..bb1af71 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -5248,12 +5248,14 @@ # data set is returned from each call. with self._jobsLock: jobs = {} + jobs = self.cif.getFakeBlockJobs() for dev in self.status()['devices']: jobID = dev.get('blockJobID') if dev['device'] != 'disk' or jobID is None: continue ret = self._dom.blockJobInfo(dev['name'], 0) + ret = jobs.get(jobID) if not ret: self.log.debug("Block Job for vm:%s, img:%s has ended", self.conf['vmId'], dev['imageID']) @@ -5266,6 +5268,8 @@ self._postLiveMergeSyncVolumeChain(drive) self.setDiskBlockJobID(dev, None) continue + + self.log.debug("AGLITKE: Found job in dev: %s", dev) jobs[jobID] = {'id': jobID, 'jobType': 'block', 'opType': opTypeMap[ret['type']], @@ -5307,6 +5311,12 @@ self._findAndsetDiskBlockJobID(drive['path'], None) return errCode['mergeErr'] + jobs = self.cif.getFakeBlockJobs() + jobs[jobUUID] = {'type': libvirt.VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, + 'cur': 0, 'end': 15, 'bandwidth': 0, + 'vmId': self.conf['vmId'], 'path': drive['path']} + self.cif.setFakeBlockJobs(jobs) + # Trigger the collection of stats before returning so that callers # of getVmStats after this returns will see the new job self._vmStats.sampleVmJobs() -- To view, visit http://gerrit.ovirt.org/26766 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81bfc022d37a6bcdfae6fafdac352e7b40b09d15 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <ali...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches