[libvirt] [PATCH] openvz: Handle domain obj hash map errors

Daniel P. Berrange berrange at redhat.com
Tue Jul 10 09:37:25 UTC 2012


On Tue, Jul 10, 2012 at 02:42:13PM +0800, Osier Yang wrote:
> On 2012年07月10日 13:21, Guido Günther wrote:
> >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).
> >
> >OpenVZ itself doesn't complain about duplicate UUIDs since this
> >parameter is only used by libvirt.
> >---
> >  src/openvz/openvz_conf.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> >diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
> >index 503c8a0..0764c2c 100644
> >--- a/src/openvz/openvz_conf.c
> >+++ b/src/openvz/openvz_conf.c
> >@@ -684,8 +684,11 @@ int openvzLoadDomains(struct openvz_driver *driver) {
> >          openvzReadMemConf(dom->def, veid);
> >
> >          virUUIDFormat(dom->def->uuid, uuidstr);
> >-        if (virHashAddEntry(driver->domains.objs, uuidstr, dom)<  0)
> >+        if (virHashAddEntry(driver->domains.objs, uuidstr, dom)<  0) {
> >+            openvzError(VIR_ERR_INTERNAL_ERROR,
> >+                        _("Could not add UUID for container %d"), veid);
> >              goto cleanup;
> >+        }
> 
> It's good to have a clear error for the UUID collisions, but
> it's not the only reason for failure of virHashAddEntry. It
> could be the memory allocation error too. So The better fix
> is to check the UUID duplication explicitly with virHashLookup
> before adding it to the table, (virHashAddOrUpdateEntry reports
> the memory allocation error anyway, so we just need to care
> about the UUID conllisions, and actually the memory error
> could be overriden with this patch).

Agreed, you need to check for collisions before adding the entry,
otherwise you obscure other relevant error messages.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list