core: prevent VM renaming over already existing VM

Fixes QubesOS/qubes-issues#1723
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-08 04:38:26 +01:00
parent be231421de
commit 9fa090b422
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -591,6 +591,10 @@ class QubesVm(object):
if self.installed_by_rpm: if self.installed_by_rpm:
raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.") raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.")
assert self._collection is not None
if self._collection.get_vm_by_name(name):
raise QubesException("VM with this name already exists")
self.pre_rename(name) self.pre_rename(name)
try: try:
self.libvirt_domain.undefine() self.libvirt_domain.undefine()