]> 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)
committerGuido Günther <agx@sigxcpu.org>
Wed, 11 Jul 2012 08:40:03 +0000 (10:40 +0200)
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.

src/openvz/openvz_conf.c

index 7b662994df8c1dc93b0aabb7cec6c38fb4561195..8d7bc258cbca80f6d2f7a43dd9298e70cc9d2d14 100644 (file)
@@ -670,8 +670,18 @@ int openvzLoadDomains(struct openvz_driver *driver) {
         openvzReadMemConf(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;