Re: [libvirt] [PATCH] Check for duplicated UUID in XM Xen defines

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

 



On Tue, Nov 17, 2009 at 12:16:11PM +0100, Daniel Veillard wrote:
>   This fixes https://bugzilla.redhat.com/show_bug.cgi?id=504262
> where the xen drivers happily allows to define domains with conflicting
> UUID. This is similar to the virDomainObjIsDuplicate check done in other
> drivers but the internal structures are different so this need to be
> done in a special way
> 
> Author: Daniel Veillard <veillard@xxxxxxxxxx>
> Date:   Tue Nov 17 12:06:46 2009 +0100
> 
>     504262 Check for duplicated UUID in XM Xen defines
> 
>     * src/xen/xm_internal.c: the XM driver was not checking for previously
>       defined UUID on new defines. Similar to virDomainObjIsDuplicate()
>       behaviour.
> 
> diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
> index f833ce7..47bcc11 100644
> --- a/src/xen/xm_internal.c
> +++ b/src/xen/xm_internal.c
> @@ -2623,6 +2623,26 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
>          return (NULL);
>      }
>  
> +    /*
> +     * check that if there is another domain defined with the same uuid
> +     * it has the same name
> +     */
> +    if ((entry = virHashSearch(priv->configCache, xenXMDomainSearchForUUID,
> +                               (const void *)&(def->uuid))) != NULL) {
> +	if ((entry->def != NULL) && (entry->def->name != NULL) &&
> +	    (STRNEQ(def->name, entry->def->name))) {
> +	    char uuidstr[VIR_UUID_STRING_BUFLEN];
> +
> +	    virUUIDFormat(entry->def->uuid, uuidstr);
> +	    xenXMError(conn, VIR_ERR_OPERATION_FAILED,
> +	               _("domain '%s' is already defined with uuid %s"),
> +		       entry->def->name, uuidstr);
> +	    entry = NULL;
> +            goto error;
> +	}
> +	entry = NULL;
> +    }
> +
>      if (virHashLookup(priv->nameConfigMap, def->name)) {
>          /* domain exists, we will overwrite it */
>  
> 

ACK, though the indentation looks a little off here.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]