Vinzenz Feenstra has uploaded a new change for review. Change subject: Create GuestAgent instance in __init__ and connect later ......................................................................
Create GuestAgent instance in __init__ and connect later This is not only a cosmetic improvement. There are cases where we are trying to call methods of the GuestAgent before the instance was created. To avoid these race conditions we're creating the instance of the guest agent already in the __init__ phase. Change-Id: I82f7397b01bff48a3c635eee9912cc67cf722b13 Signed-off-by: Vinzenz Feenstra <[email protected]> --- M vdsm/guestIF.py M vdsm/vm.py 2 files changed, 7 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/26142/1 diff --git a/vdsm/guestIF.py b/vdsm/guestIF.py index 1f8d18d..1eaa42b 100644 --- a/vdsm/guestIF.py +++ b/vdsm/guestIF.py @@ -108,7 +108,7 @@ MAX_MESSAGE_SIZE = 2 ** 20 # 1 MiB for now def __init__(self, socketName, channelListener, log, user='Unknown', - ips='', connect=True): + ips=''): self.effectiveApiVersion = _IMPLICIT_API_VERSION_ZERO self.log = log self._socketName = socketName @@ -128,7 +128,8 @@ self._agentTimestamp = 0 self._channelListener = channelListener self._messageState = MessageState.NORMAL - if connect: + + def connect(self): try: self._prepare_socket() except: diff --git a/vdsm/vm.py b/vdsm/vm.py index 1390c6e..7fbf07a 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -2008,7 +2008,6 @@ self._volPrepareLock = threading.Lock() self._initTimePauseCode = None self._initTimeRTC = long(self.conf.get('timeOffset', 0)) - self.guestAgent = None self._guestEvent = 'Powering up' self._guestEventTime = 0 self._vmStats = None @@ -2028,6 +2027,8 @@ self.conf['vmName'] = 'n%s' % self.id self._guestSocketFile = self._makeChannelPath(_VMCHANNEL_DEVICE_NAME) self._qemuguestSocketFile = self._makeChannelPath(_QEMU_GA_DEVICE_NAME) + self.guestAgent = guestIF.GuestAgent( + self._guestSocketFile, self.cif.channelListener, self.log) self._lastXMLDesc = '<domain><uuid>%s</uuid></domain>' % self.id self._devXmlHash = '0' self._released = False @@ -3128,9 +3129,8 @@ # VmStatsThread may use block devices info from libvirt. # So, run it after you have this info self._initVmStats() - self.guestAgent = guestIF.GuestAgent( - self._guestSocketFile, self.cif.channelListener, self.log, - connect=utils.tobool(self.conf.get('vmchannel', 'true'))) + if utils.tobool(self.conf.get('vmchannel', 'true')): + self.guestAgent.connect() self._guestCpuRunning = (self._dom.info()[0] == libvirt.VIR_DOMAIN_RUNNING) -- To view, visit http://gerrit.ovirt.org/26142 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82f7397b01bff48a3c635eee9912cc67cf722b13 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
