Martin Polednik has uploaded a new change for review.

Change subject: virt: add device setup and teardown
......................................................................

virt: add device setup and teardown

More and more devices require some action to be taken before VM is
started - even before the XML is generated. We add two methods, setup
and teardown, that are called before VM's start and after VM's
destruction respectively.

These methods should be used as a replacement for device-specific
methods.

Change-Id: I3f99b855de43cff693b99b6873a835b7ad56db1b
Signed-off-by: Martin Polednik <[email protected]>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/core.py
2 files changed, 23 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/55135/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a133a9b..dde665c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1678,11 +1678,17 @@
         self._cleanupDrives()
         self._cleanupFloppy()
         self._cleanupGuestAgent()
+        self._teardownDevices()
         cleanup_guest_socket(self._qemuguestSocketFile)
         self._cleanupStatsCache()
         numaUtils.invalidateNumaCache(self)
         for con in self._devices[hwclass.CONSOLE]:
             con.cleanup()
+
+    def _teardownDevices(self):
+        for dev_type, dev_objects in self._devices.items():
+            for dev_object in dev_objects:
+                dev_object.teardown()
 
     def _cleanupRecoveryFile(self):
         self._recovery_file.cleanup()
@@ -1857,6 +1863,10 @@
                 self.log.debug('Detaching device %s from the host.' % dev_name)
                 dev.detach()
 
+            for dev_type, dev_objects in self._devices.items():
+                for dev_object in dev_objects:
+                    dev_object.setup()
+
         if self.recovering:
             self._dom = virdomain.Notifying(
                 self._connection.lookupByUUIDString(self.id),
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index 5951f7d..c5f0d95 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -74,6 +74,19 @@
         """
         raise NotImplementedError()
 
+    def setup(self):
+        """
+        Actions to be executed right before VM's XML is generated. Not executed
+        in the recovery flow.
+        """
+        pass
+
+    def teardown(self):
+        """
+        Actions to be executed before VM is destroyed.
+        """
+        pass
+
 
 class Generic(Base):
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f99b855de43cff693b99b6873a835b7ad56db1b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to