
In some cases, the guest volume may not be in a pool and virStorageVol.storagePoolLookupByVolume() will raise an exception which will point to user a false negative guest deletion - as an error is shown to him but the guest was really deleted. So prevent it by using a try/except block around virStorageVol.storagePoolLookupByVolume() Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com> --- src/kimchi/model/vms.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index d13732b..8c10618 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -761,12 +761,17 @@ class VMModel(object): {'name': name, 'err': e.get_error_message()}) for path in paths: - vol = conn.storageVolLookupByPath(path) - pool = vol.storagePoolLookupByVolume() - xml = pool.XMLDesc(0) - pool_type = xpath_get_text(xml, "/pool/@type")[0] - if pool_type not in READONLY_POOL_TYPE: - vol.delete(0) + try: + vol = conn.storageVolLookupByPath(path) + pool = vol.storagePoolLookupByVolume() + xml = pool.XMLDesc(0) + pool_type = xpath_get_text(xml, "/pool/@type")[0] + if pool_type not in READONLY_POOL_TYPE: + vol.delete(0) + except Exception as e: + kimchi_log.error('Unable to get storage volume by path: %s' % + e.message) + try: with self.objstore as session: session.delete('vm', dom.UUIDString(), ignore_missing=True) -- 1.9.3