Change in vdsm[master]: snapshot: Start the snapshot module
nsoffer at redhat.com
nsoffer at redhat.com
Mon Jun 29 19:12:02 UTC 2015
Nir Soffer has uploaded a new change for review.
Change subject: snapshot: Start the snapshot module
......................................................................
snapshot: Start the snapshot module
This module will hold the code taking a vm snapshot. Currently it
include only the GuestAgent class, responsible for freezing and thawing
guest file systems during a snapshot.
This module is an attempt to add testable vm code without adding more
code to the Vm class.
Change-Id: I8e4c54f461039de99823c3b80a10be0a960c4273
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M debian/vdsm.install
M tests/Makefile.am
A tests/vmSnapshotTests.py
M tests/vmfakelib.py
M vdsm.spec.in
M vdsm/virt/Makefile.am
A vdsm/virt/snapshot.py
7 files changed, 117 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/43018/1
diff --git a/debian/vdsm.install b/debian/vdsm.install
index 35fcba7..aac35c0 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -152,6 +152,7 @@
./usr/share/vdsm/virt/periodic.py
./usr/share/vdsm/virt/sampling.py
./usr/share/vdsm/virt/secret.py
+./usr/share/vdsm/virt/snapshot.py
./usr/share/vdsm/virt/vm.py
./usr/share/vdsm/virt/vmchannels.py
./usr/share/vdsm/virt/vmexitreason.py
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b9b8e72..a472ee6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -110,6 +110,7 @@
vmApiTests.py \
vmfakelibTests.py \
vmMigrationTests.py \
+ vmSnapshotTests.py \
vmSecretTests.py \
vmStorageTests.py \
vmTests.py \
diff --git a/tests/vmSnapshotTests.py b/tests/vmSnapshotTests.py
new file mode 100644
index 0000000..23f0c9b
--- /dev/null
+++ b/tests/vmSnapshotTests.py
@@ -0,0 +1,41 @@
+#
+# Copyright 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import logging
+from testlib import VdsmTestCase
+import vmfakelib
+from virt import snapshot
+
+
+class SnapshotGuestAgentTests(VdsmTestCase):
+
+ def test_freeze_filesystems(self):
+ dom = vmfakelib.Domain()
+ guest = snapshot.GuestAgent(dom, logging.getLogger())
+ guest.freeze_filesystems()
+ self.assertEqual(dom.__recording__,
+ [("fsFreeze", (), {"mountpoints": None})])
+
+ def test_thaw_filesystems(self):
+ dom = vmfakelib.Domain()
+ guest = snapshot.GuestAgent(dom, logging.getLogger())
+ guest.thaw_filesystems()
+ self.assertEqual(dom.__recording__,
+ [("fsThaw", (), {"mountpoints": None})])
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index 2c841ca..cfdea00 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -244,6 +244,14 @@
def getDowntimes(self):
return self._downtimes
+ @recorded
+ def fsFreeze(self, mountpoints=None, flags=0):
+ self._failIfRequested()
+
+ @recorded
+ def fsThaw(self, mountpoints=None, flags=0):
+ self._failIfRequested()
+
class GuestAgent(object):
def __init__(self):
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2f5ffc8..91ffcbb 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -921,6 +921,7 @@
%{_datadir}/%{vdsm_name}/virt/periodic.py*
%{_datadir}/%{vdsm_name}/virt/sampling.py*
%{_datadir}/%{vdsm_name}/virt/secret.py*
+%{_datadir}/%{vdsm_name}/virt/snapshot.py*
%{_datadir}/%{vdsm_name}/virt/vmchannels.py*
%{_datadir}/%{vdsm_name}/virt/vmstats.py*
%{_datadir}/%{vdsm_name}/virt/vmstatus.py*
diff --git a/vdsm/virt/Makefile.am b/vdsm/virt/Makefile.am
index 745e7dc..aec4981 100644
--- a/vdsm/virt/Makefile.am
+++ b/vdsm/virt/Makefile.am
@@ -31,6 +31,7 @@
periodic.py \
sampling.py \
secret.py \
+ snapshot.py \
vm.py \
vmchannels.py \
vmexitreason.py \
diff --git a/vdsm/virt/snapshot.py b/vdsm/virt/snapshot.py
new file mode 100644
index 0000000..2629ed6
--- /dev/null
+++ b/vdsm/virt/snapshot.py
@@ -0,0 +1,64 @@
+#
+# Copyright 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+"""
+snapshot - take vm snapshot
+
+This module will implement vm snapshot. Currently it only contains the
+GuestAgent class, implementing filesystem freezing and thawing, using during a
+snapshot flow.
+"""
+
+
+class GuestAgent(object):
+ """
+ For consistent snapshot, we must freeze the guest filesystems before the
+ snapshot, and thaw them when the snapshot is done. These operations are
+ implemented by a guest agent, and application specific code on the guest.
+
+ If a guest agent supporiting these operation is not installed or libvirt
+ fail to communicate with the guest agent, these operations will fail.
+ """
+
+ def __init__(self, dom, log):
+ self._dom = dom
+ self._log = log
+
+ def freeze_filesystems(self, mountpoints=None):
+ """
+ Freeze specified filesystems within the guest (hence guest agent may be
+ required depending on hypervisor used).
+
+ If mountpoints is None every mounted filesystem on the guest is frozen.
+ """
+ self._log.info("Freezing guest filesystems (moutpoints=%s)",
+ mountpoints)
+ self._dom.fsFreeze(mountpoints=mountpoints)
+
+ def thaw_filesystems(self, mountpoints=None):
+ """
+ Thaw specified filesystems within the guest (hence guest agent may be
+ required depending on hypervisor used).
+
+ If mountpoints is None every mounted filesystem on the guest is thawed.
+ """
+ self._log.info("Thawing guest filesystems (moutpoints=%s)",
+ mountpoints)
+ self._dom.fsThaw(mountpoints=mountpoints)
--
To view, visit https://gerrit.ovirt.org/43018
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e4c54f461039de99823c3b80a10be0a960c4273
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list