mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
qemu: Report better error message when renaming to existing domain name
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
7b5acf9461
commit
c7596cf0e0
@ -19907,6 +19907,7 @@ static int qemuDomainRename(virDomainPtr dom,
|
||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainObjPtr tmp_dom = NULL;
|
||||
virObjectEventPtr event_new = NULL;
|
||||
virObjectEventPtr event_old = NULL;
|
||||
int ret = -1;
|
||||
@ -19961,6 +19962,21 @@ static int qemuDomainRename(virDomainPtr dom,
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a rather racy check, but still better than reporting
|
||||
* internal error. And since new_name != name here, there's no
|
||||
* deadlock imminent.
|
||||
*/
|
||||
tmp_dom = virDomainObjListFindByName(driver->domains, new_name);
|
||||
if (tmp_dom) {
|
||||
virObjectUnlock(tmp_dom);
|
||||
virObjectUnref(tmp_dom);
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("domain with name '%s' already exists"),
|
||||
new_name);
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
if (VIR_STRDUP(new_dom_name, new_name) < 0)
|
||||
goto endjob;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user