Fix domain renaming when it wasn't defined in libvirt

Fixes QubesOS/qubes-issues#1632
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-06 05:36:07 +01:00
parent 8ee909f08c
commit 0b5bd060bb
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -592,8 +592,13 @@ class QubesVm(object):
raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.")
self.pre_rename(name)
if self.libvirt_domain:
try:
self.libvirt_domain.undefine()
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
pass
else:
raise
if self._qdb_connection:
self._qdb_connection.close()
self._qdb_connection = None