[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH] virtinst: Add support for fs write policy



This introduces new attribute wrpolicy with only supported
value as immediate. This helps specify whether to skip the
host page cache.

When wrpolicy is specified, meaning when wrpolicy=immediate
a writeback is explicitly initiated for the dirty pages in
the host page cache as part of the guest file write operation.

Signed-off-by: Deepak C Shetty <deepakcs linux vnet ibm com>
---

 tests/xmlparse-xml/change-filesystems-in.xml  |    5 +++++
 tests/xmlparse-xml/change-filesystems-out.xml |    6 ++++++
 tests/xmlparse.py                             |   10 ++++++++++
 virtinst/VirtualFilesystem.py                 |   25 ++++++++++++++++++++++++-
 4 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/tests/xmlparse-xml/change-filesystems-in.xml b/tests/xmlparse-xml/change-filesystems-in.xml
index 2f95068..f0d5a1a 100644
--- a/tests/xmlparse-xml/change-filesystems-in.xml
+++ b/tests/xmlparse-xml/change-filesystems-in.xml
@@ -33,6 +33,11 @@
       <target dir='/bar/baz'/>
     </filesystem>
     <filesystem type='mount' accessmode='squash'>
+      <driver type='path' wrpolicy='immediate'/>
+      <source dir='/foo/bar'/>
+      <target dir='/bar/baz'/>
+    </filesystem>
+    <filesystem type='mount' accessmode='mapped'>
       <driver type='path'/>
       <source dir='/foo/bar'/>
       <target dir='/bar/baz'/>
diff --git a/tests/xmlparse-xml/change-filesystems-out.xml b/tests/xmlparse-xml/change-filesystems-out.xml
index c952c4b..6d0c00c 100644
--- a/tests/xmlparse-xml/change-filesystems-out.xml
+++ b/tests/xmlparse-xml/change-filesystems-out.xml
@@ -37,5 +37,11 @@
       <target dir="/bar/baz"/>
       <readonly/>
     </filesystem>
+    <filesystem>
+      <driver type="handle" wrpolicy="immediate"/>
+      <source dir="/foo/bar"/>
+      <target dir="/bar/baz"/>
+      <readonly/>
+    </filesystem>
   </devices>
 </domain>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 927861c..b27e8d2 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -577,11 +577,13 @@ class XMLParseTest(unittest.TestCase):
         dev1 = guest.get_devices(devtype)[0]
         dev2 = guest.get_devices(devtype)[1]
         dev3 = guest.get_devices(devtype)[2]
+        dev4 = guest.get_devices(devtype)[3]
 
         check = self._make_checker(dev1)
         check("type", None, "mount")
         check("mode", None, "passthrough")
         check("driver", "handle", None)
+        check("wrpolicy", None, None)
         check("source", "/foo/bar", "/new/path")
         check("target", "/bar/baz", "/new/target")
 
@@ -595,6 +597,14 @@ class XMLParseTest(unittest.TestCase):
         check("type", "mount", None)
         check("mode", "squash", None)
         check("driver", "path", "handle")
+        check("wrpolicy", "immediate", None)
+        check("readonly", False, True)
+
+        check = self._make_checker(dev4)
+        check("type", "mount", None)
+        check("mode", "mapped", None)
+        check("driver", "path", "handle")
+        check("wrpolicy", None, "immediate")
         check("readonly", False, True)
 
         self._alter_compare(guest.get_config_xml(), outfile)
diff --git a/virtinst/VirtualFilesystem.py b/virtinst/VirtualFilesystem.py
index b1cf71d..dfd3a6a 100644
--- a/virtinst/VirtualFilesystem.py
+++ b/virtinst/VirtualFilesystem.py
@@ -42,6 +42,10 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
     MODE_DEFAULT = "default"
     MOUNT_MODES = [MODE_PASSTHROUGH, MODE_MAPPED, MODE_SQUASH, MODE_DEFAULT]
 
+    WRPOLICY_IMM = "immediate"
+    WRPOLICY_DEFAULT = "default"
+    WRPOLICIES = [WRPOLICY_IMM, WRPOLICY_DEFAULT]
+
     DRIVER_PATH = "path"
     DRIVER_HANDLE = "handle"
     DRIVER_DEFAULT = "default"
@@ -75,6 +79,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
         self._target = None
         self._source = None
         self._readonly = None
+        self._wrpolicy = None
 
         if self._is_parse():
             return
@@ -82,6 +87,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
         self.mode = self.MODE_DEFAULT
         self.type = self.TYPE_DEFAULT
         self.driver = self.DRIVER_DEFAULT
+        self.wrpolicy = self.WRPOLICY_DEFAULT
 
     def _get_type(self):
         return self._type
@@ -99,6 +105,14 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
         self._mode = val
     mode = _xml_property(_get_mode, _set_mode, xpath="./@accessmode")
 
+    def _get_wrpolicy(self):
+        return self._wrpolicy
+    def _set_wrpolicy(self, val):
+        if val is not None and not self.WRPOLICIES.count(val):
+            raise ValueError(_("Unsupported filesystem write policy '%s'" % val))
+        self._wrpolicy = val
+    wrpolicy = _xml_property(_get_wrpolicy, _set_wrpolicy, xpath="./driver/@wrpolicy")
+
     def _get_readonly(self):
         return self._readonly
     def _set_readonly(self, val):
@@ -162,6 +176,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
         source = self.source
         target = self.target
         readonly = self.readonly
+        wrpolicy = self.wrpolicy
 
         if mode == self.MODE_DEFAULT:
             mode = None
@@ -169,6 +184,9 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
             ftype = None
         if driver == self.DRIVER_DEFAULT:
             driver = None
+            wrpolicy = None
+        if wrpolicy == self.WRPOLICY_DEFAULT:
+            wrpolicy = None
 
         if not source or not target:
             raise ValueError(
@@ -182,7 +200,12 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
         fsxml += ">\n"
 
         if driver:
-            fsxml += "      <driver type='%s'/>\n" % driver
+            if not wrpolicy:
+                fsxml += "      <driver type='%s'/>\n" % driver
+            else:
+                fsxml += "      <driver type='%s' wrpolicy='%s' />\n" % (
+                                                                    driver,
+                                                                    wrpolicy)
 
         fsxml += "      <source %s='%s'/>\n" % (
                                             self.type_to_source_prop(ftype),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]