[libvirt] [PATCH v2 3/3] qemuDomainRename: Explicitly check if domain is renaming to itself

Martin Kletzander mkletzan at redhat.com
Mon Aug 17 21:27:44 UTC 2015


On Mon, Aug 17, 2015 at 11:16:29PM +0200, Michal Privoznik wrote:
>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.
>

Or just return 0 :)  (that way it's a feature)

>Signed-off-by: Michal Privoznik <mprivozn at 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
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150817/7558ca3a/attachment-0001.sig>


More information about the libvir-list mailing list