ShaoHe Feng has uploaded a new change for review.
Change subject: cancel the core dump of a VM ......................................................................
cancel the core dump of a VM
Change-Id: I2fa9e82cfbd43c9edb98fac9af41eb0deb0c67ad Signed-off-by: ShaoHe Feng shaohef@linux.vnet.ibm.com --- M vdsm/API.py M vdsm/BindingXMLRPC.py M vdsm/define.py M vdsm/vm.py M vdsm_api/vdsmapi-schema.json M vdsm_cli/vdsClient.py 6 files changed, 62 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/11130/1
diff --git a/vdsm/API.py b/vdsm/API.py index 4f5eed8..c5f7d40 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -293,6 +293,15 @@ return errCode['noVM'] return v.coreDump(to, dumpParams)
+ def dumpCancel(self): + """ + Cancel a currently outgoing core dump process. + """ + v = self._cif.vmContainer.get(self._UUID) + if not v: + return errCode['noVM'] + return v.dumpCancel() + def desktopLock(self): """ Lock user session in guest operating system using guest agent. diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py index 9fcbefd..17d97b1 100644 --- a/vdsm/BindingXMLRPC.py +++ b/vdsm/BindingXMLRPC.py @@ -215,6 +215,10 @@ vm = API.VM(vmId) return vm.coreDump(to, params)
+ def vmCoreDumpCancel(self, vmId): + vm = API.VM(vmId) + return vm.dumpCancel() + def vmReset(self, vmId): vm = API.VM(vmId) return vm.reset() @@ -764,6 +768,7 @@ (self.vmPause, 'pause'), (self.vmCont, 'cont'), (self.vmCoreDump, 'coreDump'), + (self.vmCoreDumpCancel, 'dumpCancel'), (self.vmSnapshot, 'snapshot'), (self.vmMerge, 'merge'), (self.vmMergeStatus, 'mergeStatus'), diff --git a/vdsm/define.py b/vdsm/define.py index 84aacad..e1d428c 100644 --- a/vdsm/define.py +++ b/vdsm/define.py @@ -134,6 +134,9 @@ {'code': 58, 'message': 'Failed to generate coreDump file'}}, + 'dumpCancelErr': {'status': + {'code': 59, + 'message': 'Failed to cancel dump'}}, 'recovery': {'status': {'code': 99, 'message': diff --git a/vdsm/vm.py b/vdsm/vm.py index be947c6..0a40e97 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -1345,3 +1345,29 @@ return check finally: self._guestCpuLock.release() + + def dumpCancel(self): + def reportError(self, key='dumpCancelErr', msg=None): + if msg is None: + error = errCode[key] + else: + error = {'status': + {'code': errCode[key]['status']['code'], + 'message': msg}} + self.log.error("Failed to cancel core dump. " + msg, + exc_info=True) + return error + + self._acquireCpuLockWithTimeout() + try: + if not self.isDoingDump(): + return reportError(msg='no core dump in process') + if self.dumpMode() == "memory": + return reportError(msg='invalid to cancel memory dump') + self._doCoredumpThread.stop() + return {'status': {'code': 0, + 'message': 'core dump process stopped'}} + except Exception, e: + return reportError(msg=e.message) + finally: + self._guestCpuLock.release() diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 63b0fb1..39d1cba 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -5474,6 +5474,16 @@ 'data': {'to': 'str', 'params': 'DumpParams'}}
## +# @VM.dumpCancel: +# +# Cancel the currently outgoing core dump process. +# +# Since: 4.10.4 +# +## +{'command': {'class': 'VM', 'name': 'dumpCancel'}} + +## # @VM.monitorCommand: # # Send a command to the qemu monitor. diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py index c4171d9..32ad348 100644 --- a/vdsm_cli/vdsClient.py +++ b/vdsm_cli/vdsClient.py @@ -1669,6 +1669,11 @@
return status['status']['code'], status['status']['message']
+ def do_dumpCancel(self, args): + vmId = args[0] + response = self.s.dumpCancel(vmId) + return response['status']['code'], response['status']['message'] + def coreDump(self, args): dumpParams = {'crash': False, 'live': False, @@ -2413,6 +2418,10 @@ 'Start live replication to the destination ' 'domain' )), + 'coreDumpCancel': (serv.do_dumpCancel, + ('<vmId>', + 'cancel machine core dump' + )), 'coreDump': (serv.coreDump, ('<vmId> <file> [live=<True|False>] ' '[crash=<True|False>] [bypass-cache=<True|False>] '
-- To view, visit http://gerrit.ovirt.org/11130 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I2fa9e82cfbd43c9edb98fac9af41eb0deb0c67ad Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: ShaoHe Feng shaohef@linux.vnet.ibm.com