Change in vdsm[master]: virt: Make VM domain descriptor public

mbetak at redhat.com mbetak at redhat.com
Wed Feb 10 17:07:06 UTC 2016


Martin Betak has uploaded a new change for review.

Change subject: virt: Make VM domain descriptor public
......................................................................

virt: Make VM domain descriptor public

Change-Id: I58dacec299fd6176b10b4180e2737d6b2f59ccbc
Signed-off-by: Martin Betak <mbetak at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 27 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/53371/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 4084d05..fb7646e 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -288,7 +288,7 @@
         self.guestAgent = guestagent.GuestAgent(
             self._guestSocketFile, self.cif.channelListener, self.log,
             self._onGuestStatusChange)
-        self._domain = DomainDescriptor.from_id(self.id)
+        self.domain = DomainDescriptor.from_id(self.id)
         self._released = False
         self._releaseLock = threading.Lock()
         self.saveState()
@@ -1381,7 +1381,7 @@
             stats.update(vmstats.translate(decStats))
 
         stats.update(self._getGraphicsStats())
-        stats['hash'] = str(hash((self._domain.devices_hash,
+        stats['hash'] = str(hash((self.domain.devices_hash,
                                   self.guestAgent.diskMappingHash)))
         if self._watchdogEvent:
             stats['watchdogEvent'] = self._watchdogEvent
@@ -1718,7 +1718,7 @@
         This is necessary to prevent incoming migrations, restoring of VMs and
         the upgrade of VDSM with running VMs to fail on this.
         """
-        for name, path in self._domain.all_channels():
+        for name, path in self.domain.all_channels():
             if name not in vmchannels.AGENT_DEVICE_NAMES:
                 continue
 
@@ -3647,7 +3647,7 @@
         use updateDevice to select the device.
         """
         try:
-            graphics = self._domain.get_device_elements('graphics')[0]
+            graphics = self.domain.get_device_elements('graphics')[0]
         except IndexError:
             return response.error('ticketErr',
                                   'no graphics devices configured')
@@ -3662,7 +3662,7 @@
             graphics.setAttribute('passwdValidTo', validto)
         if graphics.getAttribute('type') == 'spice':
             graphics.setAttribute('connected', connAct)
-        hooks.before_vm_set_ticket(self._domain.xml, self.conf, params)
+        hooks.before_vm_set_ticket(self.domain.xml, self.conf, params)
         try:
             self._dom.updateDeviceFlags(graphics.toxml(), 0)
             disconnectAction = params.get('disconnectAction',
@@ -3671,7 +3671,7 @@
         except virdomain.TimeoutError as tmo:
             res = response.error('ticketErr', unicode(tmo))
         else:
-            hooks.after_vm_set_ticket(self._domain.xml, self.conf, params)
+            hooks.after_vm_set_ticket(self.domain.xml, self.conf, params)
             res = {'status': doneCode}
         return res
 
@@ -3772,7 +3772,7 @@
 
     def _updateDomainDescriptor(self):
         domainXML = self._dom.XMLDesc(0)
-        self._domain = DomainDescriptor(domainXML)
+        self.domain = DomainDescriptor(domainXML)
 
     def _ejectFloppy(self):
         if 'volatileFloppy' in self.conf:
@@ -3824,7 +3824,7 @@
 
             self.cif.irs.inappropriateDevices(self.id)
 
-            hooks.after_vm_destroy(self._domain.xml, self.conf)
+            hooks.after_vm_destroy(self.domain.xml, self.conf)
             for dev in self._customDevices():
                 hooks.after_device_destroy(dev._deviceXML, self.conf,
                                            dev.custom)
@@ -3888,7 +3888,7 @@
             hooks.before_device_destroy(dev._deviceXML, self.conf,
                                         dev.custom)
 
-        hooks.before_vm_destroy(self._domain.xml, self.conf)
+        hooks.before_vm_destroy(self.domain.xml, self.conf)
         with self._shutdownLock:
             self._shutdownReason = vmexitreason.ADMIN_SHUTDOWN
         self._destroyed = True
@@ -4013,7 +4013,7 @@
                     return True
             return False
 
-        for x in self._domain.devices.childNodes:
+        for x in self.domain.devices.childNodes:
             # Ignore empty nodes and devices without address
             if (x.nodeName == '#text' or
                     not x.getElementsByTagName('address')):
@@ -4035,7 +4035,7 @@
         """
         Obtain controller devices info from libvirt.
         """
-        for x in self._domain.get_device_elements('controller'):
+        for x in self.domain.get_device_elements('controller'):
             # Ignore controller devices without address
             if not x.getElementsByTagName('address'):
                 continue
@@ -4080,7 +4080,7 @@
         """
         Obtain balloon device info from libvirt.
         """
-        for x in self._domain.get_device_elements('memballoon'):
+        for x in self.domain.get_device_elements('memballoon'):
             # Ignore balloon devices without address.
             if not x.getElementsByTagName('address'):
                 address = None
@@ -4105,7 +4105,7 @@
         """
         Obtain the alias for the console device from libvirt
         """
-        for x in self._domain.get_device_elements('console'):
+        for x in self.domain.get_device_elements('console'):
             # All we care about is the alias
             alias = x.getElementsByTagName('alias')[0].getAttribute('name')
             for dev in self._devices[hwclass.CONSOLE]:
@@ -4121,7 +4121,7 @@
         """
         Obtain smartcard device info from libvirt.
         """
-        for x in self._domain.get_device_elements('smartcard'):
+        for x in self.domain.get_device_elements('smartcard'):
             if not x.getElementsByTagName('address'):
                 continue
 
@@ -4143,7 +4143,7 @@
         """
         Obtain rng device info from libvirt.
         """
-        for rng in self._domain.get_device_elements('rng'):
+        for rng in self.domain.get_device_elements('rng'):
             address = self._getUnderlyingDeviceAddress(rng)
             alias = rng.getElementsByTagName('alias')[0].getAttribute('name')
             source = rng.getElementsByTagName('backend')[0].firstChild.\
@@ -4189,7 +4189,7 @@
         """
         Obtain host device info from libvirt
         """
-        for x in self._domain.get_device_elements('hostdev'):
+        for x in self.domain.get_device_elements('hostdev'):
             device_type = x.getAttribute('type')
             if device_type == 'usb':
                 self._getUnderlyingHostDeviceUSBInfo(x)
@@ -4232,7 +4232,7 @@
         """
         Obtain watchdog device info from libvirt.
         """
-        for x in self._domain.get_device_elements('watchdog'):
+        for x in self.domain.get_device_elements('watchdog'):
 
             # PCI watchdog has "address" different from ISA watchdog
             if x.getElementsByTagName('address'):
@@ -4254,7 +4254,7 @@
         """
         Obtain video devices info from libvirt.
         """
-        for x in self._domain.get_device_elements('video'):
+        for x in self.domain.get_device_elements('video'):
             alias = x.getElementsByTagName('alias')[0].getAttribute('name')
             # Get video card address
             address = self._getUnderlyingDeviceAddress(x)
@@ -4280,7 +4280,7 @@
         """
         Obtain sound devices info from libvirt.
         """
-        for x in self._domain.get_device_elements('sound'):
+        for x in self.domain.get_device_elements('sound'):
             alias = x.getElementsByTagName('alias')[0].getAttribute('name')
             # Get sound card address
             address = self._getUnderlyingDeviceAddress(x)
@@ -4322,7 +4322,7 @@
         # FIXME!  We need to gather as much info as possible from the libvirt.
         # In the future we can return this real data to management instead of
         # vm's conf
-        for x in self._domain.get_device_elements('disk'):
+        for x in self.domain.get_device_elements('disk'):
             alias, devPath, name = self._getDriveIdentification(x)
             readonly = bool(x.getElementsByTagName('readonly'))
             boot = x.getElementsByTagName('boot')
@@ -4416,7 +4416,7 @@
         device of each type (sdl, vnc, spice) is supported
         """
 
-        for gxml in self._domain.get_device_elements('graphics'):
+        for gxml in self.domain.get_device_elements('graphics'):
             port = gxml.getAttribute('port')
             tlsPort = gxml.getAttribute('tlsPort')
             graphicsType = gxml.getAttribute('type')
@@ -4445,7 +4445,7 @@
         """
         Obtain network interface info from libvirt.
         """
-        for x in self._domain.get_device_elements('interface'):
+        for x in self.domain.get_device_elements('interface'):
             devType = x.getAttribute('type')
             mac = x.getElementsByTagName('mac')[0].getAttribute('address')
             alias = x.getElementsByTagName('alias')[0].getAttribute('name')
@@ -4525,7 +4525,7 @@
         """
         Obtain memory device info from libvirt.
         """
-        for x in self._domain.get_device_elements('memory'):
+        for x in self.domain.get_device_elements('memory'):
             alias = x.getElementsByTagName('alias')[0].getAttribute('name')
             # Get device address
             address = self._getUnderlyingDeviceAddress(x)
@@ -4542,7 +4542,7 @@
                     dev['address'] = address
                     dev['alias'] = alias
                     break
-        self.conf['memSize'] = self._domain.get_memory_size()
+        self.conf['memSize'] = self.domain.get_memory_size()
 
     def _setWriteWatermarks(self):
         """
@@ -4557,13 +4557,13 @@
         if event == libvirt.VIR_DOMAIN_EVENT_STOPPED:
             if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and
                     self.lastStatus == vmstatus.MIGRATION_SOURCE):
-                hooks.after_vm_migrate_source(self._domain.xml, self.conf)
+                hooks.after_vm_migrate_source(self.domain.xml, self.conf)
                 for dev in self._customDevices():
                     hooks.after_device_migrate_source(
                         dev._deviceXML, self.conf, dev.custom)
             elif (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_SAVED and
                     self.lastStatus == vmstatus.SAVING_STATE):
-                hooks.after_vm_hibernate(self._domain.xml, self.conf)
+                hooks.after_vm_hibernate(self.domain.xml, self.conf)
             else:
                 if detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN:
                     with self._shutdownLock:
@@ -4959,7 +4959,7 @@
         self._updateDomainDescriptor()
         for drive in drives:
             alias = drive['alias']
-            diskXML = lookupDeviceXMLByAlias(self._domain.xml, alias)
+            diskXML = lookupDeviceXMLByAlias(self.domain.xml, alias)
             volChain = self._diskXMLGetVolumeChainInfo(diskXML, drive)
             if volChain:
                 ret[alias] = volChain


-- 
To view, visit https://gerrit.ovirt.org/53371
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I58dacec299fd6176b10b4180e2737d6b2f59ccbc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <mbetak at redhat.com>


More information about the vdsm-patches mailing list