diff --git a/tests/xmlparse-xml/change-filesystems-out.xml b/tests/xmlparse-xml/change-filesystems-out.xml index 1af754485..0c8908474 100644 --- a/tests/xmlparse-xml/change-filesystems-out.xml +++ b/tests/xmlparse-xml/change-filesystems-out.xml @@ -47,8 +47,8 @@ - - + + diff --git a/tests/xmlparse.py b/tests/xmlparse.py index 8526a6017..cc29eadcd 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") diff --git a/virtinst/devicefilesystem.py b/virtinst/devicefilesystem.py index 951b71653..fee9e8716 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,25 @@ 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): + # Get type/value of the attrubute of "source" property + old_source_type = self._type_to_source_prop() + old_source_value = self.source + + # Update "type" property + new_type = setattr(self, '_type_prop', val) + + # If the attribute type of 'source' property has changed + # restore the value + if old_source_type != self._type_to_source_prop(): + self.source = old_source_value + + return new_type + + type = property(_get_type, _set_type) + def set_defaults(self, guest): ignore = guest