From 0f6fddf61055039db713056c9367098164b5733a Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 6 Dec 2014 17:29:05 -0500 Subject: [PATCH] devicedisk: Simplife get_xmlpath Rather than deal with hacks, just read the backing paths and return the first hit --- virtinst/devicedisk.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index 0629e71ee..f6689a4ae 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -614,21 +614,13 @@ class VirtualDisk(VirtualDevice): return None def _get_xmlpath(self): - # Hack to avoid an ordering problem when building XML. - # If both path and type are unset, but we try to read back disk.path, - # it triggers default_type->storage_backend->path->default_type... - # loop - if (not self._storage_creator and - not self.__storage_backend and - not self._source_file and - not self._source_dev and - not self._source_dir): - return None - - propname = self._disk_type_to_object_prop_name() - if not propname: - return None - return getattr(self, propname) + if self._source_file: + return self._source_file + if self._source_dev: + return self._source_dev + if self._source_dir: + return self._source_dir + return None def _set_xmlpath(self, val): self._clear_source_xml()