]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
openvz: Handle domain obj hash map errors
authorGuido Günther <agx@sigxcpu.org>
Mon, 9 Jul 2012 10:11:17 +0000 (12:11 +0200)
committerCole Robinson <crobinso@redhat.com>
Sun, 12 Aug 2012 23:23:51 +0000 (19:23 -0400)
This makes the driver fail with a clear error message in case of UUID
collisions (for example if somebody copied a container configuration
without updating the UUID) and also raises an error on other hash map
failures.

OpenVZ itself doesn't complain about duplicate UUIDs since this
parameter is only used by libvirt.
(cherry picked from commit 31351c316fee0487dcbc5ef6b630d75be6b212e5)

src/openvz/openvz_conf.c

index 790440628c28d6caab843bec92fe06070559eb0f..da150e4cde1e5095f1a278248ee3522970ba8f43 100644 (file)
@@ -537,8 +537,18 @@ int openvzLoadDomains(struct openvz_driver *driver) {
         openvzReadFSConf(dom->def, veid);
 
         virUUIDFormat(dom->def->uuid, uuidstr);
-        if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
+        if (virHashLookup(driver->domains.objs, uuidstr)) {
+            openvzError(VIR_ERR_INTERNAL_ERROR,
+                        _("Duplicate container UUID %s detected for %d"),
+                        uuidstr,
+                        veid);
+            goto cleanup;
+        }
+        if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0) {
+            openvzError(VIR_ERR_INTERNAL_ERROR,
+                        _("Could not add UUID for container %d"), veid);
             goto cleanup;
+        }
 
         virDomainObjUnlock(dom);
         dom = NULL;