Marcin Mirecki has uploaded a new change for review. Change subject: virt: Alternative proposal for passing flags in/from vm/device hooks ......................................................................
virt: Alternative proposal for passing flags in/from vm/device hooks Change-Id: I5f0f18beff1f1ed8da8658c4b3786f4133fa030f Signed-off-by: mirecki <mmire...@redhat.com> --- M lib/vdsm/hooks.py M vdsm/hooking.py M vdsm/virt/vm.py 3 files changed, 31 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/57803/1 diff --git a/lib/vdsm/hooks.py b/lib/vdsm/hooks.py index 67cb77d..1c0d45b 100644 --- a/lib/vdsm/hooks.py +++ b/lib/vdsm/hooks.py @@ -25,6 +25,7 @@ import hashlib import itertools import json +import libvirt import logging import os import os.path @@ -410,6 +411,20 @@ raiseError=False, hookType=_JSON_HOOK) +def get_vm_launch_flags_from_file(vm_id): + flags_file = "/var/run/vdsm/hook/" + vm_id + "/launchflags" + if os.path.isfile(flags_file): + with open(flags_file) as f: + return f.readline() + return libvirt.VIR_DOMAIN_NONE + + +def dump_vm_launch_flags_to_file(vm_id, flags): + flags_file = "/var/run/vdsm/hook/" + vm_id + "/launchflags" + with open(flags_file, mode='w') as file: + file.write(str(flags)) + + def _getScriptInfo(path): try: with open(path) as f: diff --git a/vdsm/hooking.py b/vdsm/hooking.py index 97bf13d..a17d9e5 100644 --- a/vdsm/hooking.py +++ b/vdsm/hooking.py @@ -36,6 +36,7 @@ >2 - reserved """ +import hooks import json import os import sys @@ -73,6 +74,14 @@ sys.stderr.write(message + '\n') +def get_vm_launch_flags_from_file(vm_id): + hooks.get_vm_launch_flags_from_file(vm_id) + + +def dump_vm_launch_flags_to_file(vm_id, flags): + hooks.dump_vm_launch_flags_to_file(vm_id, flags) + + def exit_hook(message, return_code=2): """ Exit the hook with a given message, which will be printed to the standard diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index baf9837..61fc260 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1971,7 +1971,6 @@ self._connection.lookupByUUIDString(self.id), self._timeoutExperienced) else: - domxml = hooks.before_vm_start(self._buildDomainXML(), self.conf) # TODO: this is debug information. For 3.6.x we still need to # see the XML even with 'info' as default level. self.log.info(domxml) @@ -1982,6 +1981,13 @@ flags |= libvirt.VIR_DOMAIN_START_PAUSED self.conf['pauseCode'] = 'NOERR' del self.conf['launchPaused'] + + hooks.dump_vm_launch_flags_to_file(self.id, flags) + # Dear code reviewer, we can not move the flags into + # before_vm_start, as it is also needed in _buildDomainXML + domxml = hooks.before_vm_start(self._buildDomainXML(), self.conf) + flags = hooks.get_vm_launch_flags_from_file(self.id) + self._dom = virdomain.Notifying( self._connection.createXML(domxml, flags), self._timeoutExperienced) -- To view, visit https://gerrit.ovirt.org/57803 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5f0f18beff1f1ed8da8658c4b3786f4133fa030f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Marcin Mirecki <mmire...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches