mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-10 01:18:03 +03:00
Keep the value of filesystem/source when attribute is changed
When the attribute of filesystem/source is changed the old value was not assigned to the new attribute.
This commit is contained in:
parent
4be3d030b5
commit
0dfc371f18
@ -47,8 +47,8 @@
|
||||
<source usage="123" units="KiB"/>
|
||||
<target dir="/bar/baz"/>
|
||||
</filesystem>
|
||||
<filesystem type="block">
|
||||
<source dev="/dev/new"/>
|
||||
<filesystem type="file">
|
||||
<source dev="/dev/new" file="/dev/new"/>
|
||||
<target dir="/bar/baz"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user