Martin Betak has uploaded a new change for review. Change subject: virt: s/vm._dom.XMLDesc(0)/vm.xml/g ......................................................................
virt: s/vm._dom.XMLDesc(0)/vm.xml/g Added small helper property to avoid accessing private state of VM to get it's XML description. Change-Id: Ic159cb84049d90cdb2a4279a34145462c8ee6be4 Signed-off-by: Martin Betak <mbe...@redhat.com> --- M vdsm/virt/migration.py M vdsm/virt/vm.py 2 files changed, 17 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/52882/1 diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py index a2b5254..aa3a27b 100644 --- a/vdsm/virt/migration.py +++ b/vdsm/virt/migration.py @@ -184,7 +184,7 @@ del self._machineParams[k] if not self.hibernating: self._machineParams['migrationDest'] = 'libvirt' - self._machineParams['_srcDomXML'] = self._vm._dom.XMLDesc(0) + self._machineParams['_srcDomXML'] = self._vm.xml def _prepareGuest(self): if self.hibernating: @@ -319,7 +319,7 @@ def _startUnderlyingMigration(self, startTime): if self.hibernating: - hooks.before_vm_hibernate(self._vm._dom.XMLDesc(0), self._vm.conf) + hooks.before_vm_hibernate(self._vm.xml, self._vm.conf) fname = self._vm.cif.prepareVolumePath(self._dst) try: self._vm._dom.save(fname) @@ -329,8 +329,7 @@ for dev in self._vm._customDevices(): hooks.before_device_migrate_source( dev._deviceXML, self._vm.conf, dev.custom) - hooks.before_vm_migrate_source(self._vm._dom.XMLDesc(0), - self._vm.conf) + hooks.before_vm_migrate_source(self._vm.xml, self._vm.conf) # Do not measure the time spent for creating the VM on the # destination. In some cases some expensive operations can cause diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index d4dd0ff..916b38e 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1885,7 +1885,7 @@ self._dom = virdomain.Notifying( self._connection.createXML(domxml, flags), self._timeoutExperienced) - hooks.after_vm_start(self._dom.XMLDesc(0), self.conf) + hooks.after_vm_start(self.xml, self.conf) for dev in self._customDevices(): hooks.after_device_create(dev._deviceXML, self.conf, dev.custom) @@ -2717,7 +2717,7 @@ deadline = (utils.monotonic_time() + config.getfloat('vars', 'hotunplug_timeout')) sleep_time = config.getfloat('vars', 'hotunplug_check_interval') - while device.is_attached_to(self._dom.XMLDesc(0)): + while device.is_attached_to(self.xml): time.sleep(sleep_time) if utils.monotonic_time() > deadline: raise HotunplugTimeout("Timeout detaching device %s" @@ -2780,7 +2780,7 @@ with self._confLock: del self.conf['restoreState'] fromSnapshot = self.conf.pop('restoreFromSnapshot', False) - hooks.after_vm_dehibernate(self._dom.XMLDesc(0), self.conf, + hooks.after_vm_dehibernate(self.xml, self.conf, {'FROM_SNAPSHOT': fromSnapshot}) self._syncGuestTime() elif 'migrationDest' in self.conf: @@ -2791,7 +2791,7 @@ # else domain connection already established earlier self._domDependentInit() del self.conf['migrationDest'] - hooks.after_vm_migrate_destination(self._dom.XMLDesc(0), self.conf) + hooks.after_vm_migrate_destination(self.xml, self.conf) for dev in self._customDevices(): hooks.after_device_migrate_destination( @@ -2873,11 +2873,11 @@ raise def _underlyingCont(self): - hooks.before_vm_cont(self._dom.XMLDesc(0), self.conf) + hooks.before_vm_cont(self.xml, self.conf) self._dom.resume() def _underlyingPause(self): - hooks.before_vm_pause(self._dom.XMLDesc(0), self.conf) + hooks.before_vm_pause(self.xml, self.conf) self._dom.suspend() def _findDriveByName(self, name): @@ -3081,7 +3081,7 @@ """Returns the needed vm configuration with the memory snapshot""" return {'restoreFromSnapshot': True, - '_srcDomXML': self._dom.XMLDesc(0), + '_srcDomXML': self.xml, 'elapsedTimeOffset': time.time() - self._startTime} def _padMemoryVolume(memoryVolPath, sdUUID): @@ -3733,6 +3733,10 @@ def name(self): return self.conf['vmName'] + @property + def xml(self): + return self._dom.XMLDesc(0) + def _getPid(self): try: pid = supervdsm.getProxy().getVmPid( @@ -3746,7 +3750,7 @@ return pid def _updateDomainDescriptor(self): - domainXML = self._dom.XMLDesc(0) + domainXML = self.xml self._domain = DomainDescriptor(domainXML) def _ejectFloppy(self): @@ -4556,7 +4560,7 @@ # In this case self._dom is disconnected because the function # _completeIncomingMigration didn't update it yet. try: - domxml = self._dom.XMLDesc(0) + domxml = self.xml except virdomain.NotConnectedError: pass else: @@ -4572,7 +4576,7 @@ # The event handler delivers the domain instance in the # callback however we do not use it. try: - domxml = self._dom.XMLDesc(0) + domxml = self.xml except virdomain.NotConnectedError: pass else: -- To view, visit https://gerrit.ovirt.org/52882 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic159cb84049d90cdb2a4279a34145462c8ee6be4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Betak <mbe...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches