Re: [PATCH] qemu: Report better error message when renaming to existing domain name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 18/08/15 21:05, Martin Kletzander wrote:
> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 99a3817ff5ab..16061a51d4a7 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -19892,6 +19892,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;
> @@ -19946,6 +19947,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;
> 
ACK, definitely tells more than "Duplicate key" error.

Erik

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]