[virt-tools-list] [PATCH 2/2] virt install: Add support for filesystem <driver> sub-element
Cole Robinson
crobinso at redhat.com
Thu Dec 22 19:53:46 UTC 2011
On 12/21/2011 12:52 AM, Deepak C Shetty wrote:
> This patch adds support for the <driver...> sub-element
> of <filesystem> node. driver is an optional sub-element
> and has path and handle as the supported values as of
> now. For more details refer to libvirt filesystem
> doc page at ...
> http://libvirt.org/formatdomain.html#elementsFilesystems
>
Code looks good, but please add some test cases. Take a look at
tests/xmlparse.py:testAlterFilesystems for a reference.
Thanks,
Cole
> Signed-off-by: Deepak C Shetty <deepakcs at linux.vnet.ibm.com>
> ---
>
> virtinst/VirtualFilesystem.py | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/virtinst/VirtualFilesystem.py b/virtinst/VirtualFilesystem.py
> index a74d009..1e67004 100644
> --- a/virtinst/VirtualFilesystem.py
> +++ b/virtinst/VirtualFilesystem.py
> @@ -42,6 +42,11 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
> MODE_DEFAULT = "default"
> MOUNT_MODES = [MODE_PASSTHROUGH, MODE_MAPPED, MODE_SQUASH, MODE_DEFAULT]
>
> + DRIVER_PATH = "path"
> + DRIVER_HANDLE = "handle"
> + DRIVER_DEFAULT = "default"
> + DRIVER_TYPES = [DRIVER_PATH, DRIVER_HANDLE, DRIVER_DEFAULT]
> +
> @staticmethod
> def type_to_source_prop(fs_type):
> """
> @@ -66,6 +71,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
>
> self._type = None
> self._mode = None
> + self._driver = None
> self._target = None
> self._source = None
>
> @@ -74,6 +80,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
>
> self.mode = self.MODE_DEFAULT
> self.type = self.TYPE_DEFAULT
> + self.driver = self.DRIVER_DEFAULT
>
> def _get_type(self):
> return self._type
> @@ -91,6 +98,14 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
> self._mode = val
> mode = _xml_property(_get_mode, _set_mode, xpath="./@accessmode")
>
> + def _get_driver(self):
> + return self._driver
> + def _set_driver(self, val):
> + if val is not None and not self.DRIVER_TYPES.count(val):
> + raise ValueError(_("Unsupported filesystem driver '%s'" % val))
> + self._driver = val
> + driver = _xml_property(_get_driver, _set_driver, xpath="./driver/@type")
> +
> def _get_source(self):
> return self._source
> def _set_source(self, val):
> @@ -136,6 +151,7 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
> def _get_xml_config(self):
> mode = self.mode
> ftype = self.type
> + driver = self.driver
> source = self.source
> target = self.target
>
> @@ -143,6 +159,8 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
> mode = None
> if ftype == self.TYPE_DEFAULT:
> ftype = None
> + if driver == self.DRIVER_DEFAULT:
> + driver = None
>
> if not source or not target:
> raise ValueError(
> @@ -155,6 +173,9 @@ class VirtualFilesystem(VirtualDevice.VirtualDevice):
> fsxml += " accessmode='%s'" % mode
> fsxml += ">\n"
>
> + if driver:
> + fsxml += " <driver type='%s'/>\n" % driver
> +
> fsxml += " <source %s='%s'/>\n" % (
> self.type_to_source_prop(ftype),
> source)
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
More information about the virt-tools-list
mailing list