It may happen that user (mistakenly) wants to rename a domain to
itself. Which is no renaming at all. We should reject that with
some meaningful error message.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4c05324..083e4ff 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19937,6 +19937,12 @@ static int qemuDomainRename(virDomainPtr dom,
goto endjob;
}
+ if (STREQ(vm->def->name, new_name)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Can't rename domain to itself"));
+ goto cleanup;
+ }
+
if (VIR_STRDUP(new_dom_name, new_name) < 0)
goto endjob;
--
2.4.6