]> xenbits.xensource.com Git - libvirt.git/commitdiff
504262 Check for duplicated UUID in XM Xen defines
authorDaniel Veillard <veillard@redhat.com>
Tue, 17 Nov 2009 11:06:46 +0000 (12:06 +0100)
committerDaniel Veillard <veillard@redhat.com>
Fri, 20 Nov 2009 15:02:17 +0000 (16:02 +0100)
* src/xen/xm_internal.c: the XM driver was not checking for previously
  defined UUID on new defines. Similar to virDomainObjIsDuplicate()
  behaviour.

src/xen/xm_internal.c

index f833ce7efeaf8ee257cd1c5a09ac75e836dd10a9..2ee321f0b3e9f0af9d50bdaa655ca51e77e6a8ab 100644 (file)
@@ -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 */