[virt-tools-list] [virt-manager] [PATCH 1/2] Keep the value of filesystem/source when attribute is changed

Cole Robinson crobinso at redhat.com
Fri Jun 16 18:01:32 UTC 2017


On 06/16/2017 06:32 AM, Radostin Stoyanov wrote:
> When the attribute of filesystem/source is changed the old value is
> not assigned to the new attribute.
> ---
>  virtinst/devicefilesystem.py | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/devicefilesystem.py b/virtinst/devicefilesystem.py
> index 951b716..be8f841 100644
> --- a/virtinst/devicefilesystem.py
> +++ b/virtinst/devicefilesystem.py
> @@ -54,7 +54,7 @@ class VirtualFilesystem(VirtualDevice):
>          DRIVER_DEFAULT]
>  
>  
> -    type = XMLProperty("./@type",
> +    _type_prop = XMLProperty("./@type",
>                         default_cb=lambda s: None,
>                         default_name=TYPE_DEFAULT)
>      accessmode = XMLProperty("./@accessmode",
> @@ -111,6 +111,15 @@ class VirtualFilesystem(VirtualDevice):
>          return setattr(self, self._type_to_source_prop(), val)
>      source = property(_get_source, _set_source)
>  
> +    def _get_type(self):
> +        return getattr(self, '_type_prop')
> +    def _set_type(self, val):
> +        source_value = self.source
> +        new_type = setattr(self, '_type_prop', val)
> +        self.source = source_value
> +        return new_type
> +    type = property(_get_type, _set_type)
> +
>      def set_defaults(self, guest):
>          ignore = guest
>  
> 

This causes some minor test suite changes, please run python setup.py test
--regenerate-output and add the changes to v2 of this patch

Additionally please extend testAlterFilesystems in tests/xmlparse.py to
exercise this new behavior. I think you can probably just do this and make
sure the results make sense:

diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 8526a601..cc29eadc 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -781,9 +781,9 @@ class XMLParseTest(unittest.TestCase):
         check("units", "MB", "KiB")

         check = self._make_checker(dev6)
-        check("type", "block")
         check("source", "/foo/bar", "/dev/new")
         check("readonly", False, True)
+        check("type", "block", "file")

         check = self._make_checker(dev7)
         check("type", "file")


Thanks,
Cole




More information about the virt-tools-list mailing list