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

[libvirt] [PATCH v2 03/13] Turn virDomainObjList into an opaque virObject



From: "Daniel P. Berrange" <berrange redhat com>

As a step towards making virDomainObjList thread-safe turn it
into an opaque virObject, preventing any direct access to its
internals.

As part of this a new method virDomainObjListForEach is
introduced to replace all existing usage of virHashForEach
---
 src/conf/domain_conf.c                 | 65 ++++++++++++++++++++++----
 src/conf/domain_conf.h                 | 14 +++---
 src/conf/nwfilter_conf.c               | 22 ++++-----
 src/conf/nwfilter_conf.h               |  6 +--
 src/libvirt_private.syms               |  2 +-
 src/libxl/libxl_driver.c               | 51 +++++++++++----------
 src/lxc/lxc_driver.c                   |  9 ++--
 src/lxc/lxc_process.c                  | 28 +++++++-----
 src/nwfilter/nwfilter_gentech_driver.c | 36 +++++++--------
 src/nwfilter/nwfilter_gentech_driver.h |  7 +--
 src/openvz/openvz_conf.c               | 71 ++++++++++++++--------------
 src/parallels/parallels_driver.c       |  4 +-
 src/parallels/parallels_storage.c      | 34 ++++----------
 src/qemu/qemu_driver.c                 | 84 +++++++++++++++++-----------------
 src/qemu/qemu_process.c                | 15 +++---
 src/test/test_driver.c                 |  6 +--
 src/uml/uml_driver.c                   | 29 ++++++------
 src/vmware/vmware_conf.c               |  2 +-
 src/vmware/vmware_driver.c             | 12 ++---
 19 files changed, 266 insertions(+), 231 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 408584c..e9cc696 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -58,6 +58,15 @@
  * verify that it doesn't overflow an unsigned int when shifting */
 verify(VIR_DOMAIN_VIRT_LAST <= 32);
 
+
+struct _virDomainObjList {
+    virObject parent;
+
+    /* uuid string -> virDomainObj  mapping
+     * for O(1), lockless lookup-by-uuid */
+    virHashTable *objs;
+};
+
 /* Private flags used internally by virDomainSaveStatus and
  * virDomainLoadStatus. */
 typedef enum {
@@ -696,7 +705,9 @@ VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode,
 #define VIR_DOMAIN_XML_READ_FLAGS   VIR_DOMAIN_XML_INACTIVE
 
 static virClassPtr virDomainObjClass;
+static virClassPtr virDomainObjListClass;
 static void virDomainObjDispose(void *obj);
+static void virDomainObjListDispose(void *obj);
 
 static int virDomainObjOnceInit(void)
 {
@@ -706,6 +717,12 @@ static int virDomainObjOnceInit(void)
                                           virDomainObjDispose)))
         return -1;
 
+    if (!(virDomainObjListClass = virClassNew(virClassForObject(),
+                                              "virDomainObjList",
+                                              sizeof(virDomainObjList),
+                                              virDomainObjListDispose)))
+        return -1;
+
     return 0;
 }
 
@@ -782,26 +799,26 @@ virDomainObjListPtr virDomainObjListNew(void)
 {
     virDomainObjListPtr doms;
 
-    if (VIR_ALLOC(doms) < 0) {
-        virReportOOMError();
+    if (virDomainObjInitialize() < 0)
+        return NULL;
+
+    if (!(doms = virObjectLockableNew(virDomainObjListClass)))
         return NULL;
-    }
 
-    doms->objs = virHashCreate(50, virDomainObjListDataFree);
-    if (!doms->objs) {
-        VIR_FREE(doms);
+    if (!(doms->objs = virHashCreate(50, virDomainObjListDataFree))) {
+        virObjectUnref(doms);
         return NULL;
     }
+
     return doms;
 }
 
 
-void virDomainObjListFree(virDomainObjListPtr doms)
+static void virDomainObjListDispose(void *obj)
 {
-    if (!doms)
-        return;
+    virDomainObjListPtr doms = obj;
+
     virHashFree(doms->objs);
-    VIR_FREE(doms);
 }
 
 
@@ -15207,6 +15224,34 @@ cleanup:
     return -1;
 }
 
+
+struct virDomainListIterData {
+    virDomainObjListIterator callback;
+    void *opaque;
+    int ret;
+};
+
+static void virDomainObjListHelper(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+{
+    struct virDomainListIterData *data = opaque;
+
+    if (data->callback(payload, data->opaque) < 0)
+        data->ret = -1;
+}
+
+int virDomainObjListForEach(virDomainObjListPtr doms,
+                            virDomainObjListIterator callback,
+                            void *opaque)
+{
+    struct virDomainListIterData data = {
+        callback, opaque, 0,
+    };
+    virHashForEach(doms->objs, virDomainObjListHelper, &data);
+
+    return data.ret;
+}
+
+
 int virDomainChrDefForeach(virDomainDefPtr def,
                            bool abortOnError,
                            virDomainChrDefIterator iter,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 97acbe1..e534ca8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -37,7 +37,6 @@
 # include "virhash.h"
 # include "virsocketaddr.h"
 # include "nwfilter_params.h"
-# include "nwfilter_conf.h"
 # include "virnetdevmacvlan.h"
 # include "virsysinfo.h"
 # include "virnetdevvportprofile.h"
@@ -1892,11 +1891,6 @@ struct _virDomainObj {
 
 typedef struct _virDomainObjList virDomainObjList;
 typedef virDomainObjList *virDomainObjListPtr;
-struct _virDomainObjList {
-    /* uuid string -> virDomainObj  mapping
-     * for O(1), lockless lookup-by-uuid */
-    virHashTable *objs;
-};
 
 static inline bool
 virDomainObjIsActive(virDomainObjPtr dom)
@@ -1907,7 +1901,6 @@ virDomainObjIsActive(virDomainObjPtr dom)
 virDomainObjPtr virDomainObjNew(virCapsPtr caps);
 
 virDomainObjListPtr virDomainObjListNew(void);
-void virDomainObjListFree(virDomainObjListPtr objs);
 
 virDomainObjPtr virDomainObjListFindByID(const virDomainObjListPtr doms,
                                          int id);
@@ -2175,6 +2168,13 @@ int virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
                                      char **const names,
                                      int maxnames);
 
+typedef int (*virDomainObjListIterator)(virDomainObjPtr dom,
+                                        void *opaque);
+
+int virDomainObjListForEach(virDomainObjListPtr doms,
+                            virDomainObjListIterator callback,
+                            void *opaque);
+
 typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                              virDomainSmartcardDefPtr dev,
                                              void *opaque);
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index ca22411..e63a04b 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2867,7 +2867,7 @@ virNWFilterCallbackDriversUnlock(void)
 }
 
 
-static virHashIterator virNWFilterDomainFWUpdateCB;
+static virDomainObjListIterator virNWFilterDomainFWUpdateCB;
 
 /**
  * virNWFilterInstFiltersOnAllVMs:
@@ -2880,7 +2880,6 @@ virNWFilterInstFiltersOnAllVMs(virConnectPtr conn)
     int i;
     struct domUpdateCBStruct cb = {
         .conn = conn,
-        .err = 0, /* ignored here */
         .step = STEP_APPLY_CURRENT,
         .skipInterfaces = NULL, /* not needed */
     };
@@ -2897,10 +2896,9 @@ static int
 virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
 {
     int i;
-    int err;
+    int ret = 0;
     struct domUpdateCBStruct cb = {
         .conn = conn,
-        .err = 0,
         .step = STEP_APPLY_NEW,
         .skipInterfaces = virHashCreate(0, NULL),
     };
@@ -2909,16 +2907,14 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
         return -1;
 
     for (i = 0; i < nCallbackDriver; i++) {
-        callbackDrvArray[i]->vmFilterRebuild(conn,
-                                             virNWFilterDomainFWUpdateCB,
-                                             &cb);
+        if (callbackDrvArray[i]->vmFilterRebuild(conn,
+                                                 virNWFilterDomainFWUpdateCB,
+                                                 &cb) < 0)
+            ret = -1;
     }
 
-    err = cb.err;
-
-    if (err) {
+    if (ret < 0) {
         cb.step = STEP_TEAR_NEW; /* rollback */
-        cb.err = 0;
 
         for (i = 0; i < nCallbackDriver; i++)
             callbackDrvArray[i]->vmFilterRebuild(conn,
@@ -2935,7 +2931,7 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
 
     virHashFree(cb.skipInterfaces);
 
-    return err;
+    return ret;
 }
 
 
@@ -3503,7 +3499,7 @@ char *virNWFilterConfigFile(const char *dir,
 }
 
 
-int virNWFilterConfLayerInit(virHashIterator domUpdateCB)
+int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB)
 {
     virNWFilterDomainFWUpdateCB = domUpdateCB;
 
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index ca2c070..8c5a6ac 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -34,6 +34,7 @@
 # include "virbuffer.h"
 # include "virsocketaddr.h"
 # include "virmacaddr.h"
+# include "domain_conf.h"
 
 /* XXX
  * The config parser/structs should not be using platform specific
@@ -587,7 +588,6 @@ enum UpdateStep {
 struct domUpdateCBStruct {
     virConnectPtr conn;
     enum UpdateStep step;
-    int err;
     virHashTablePtr skipInterfaces;
 };
 
@@ -724,14 +724,14 @@ void virNWFilterObjUnlock(virNWFilterObjPtr obj);
 void virNWFilterLockFilterUpdates(void);
 void virNWFilterUnlockFilterUpdates(void);
 
-int virNWFilterConfLayerInit(virHashIterator domUpdateCB);
+int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB);
 void virNWFilterConfLayerShutdown(void);
 
 int virNWFilterInstFiltersOnAllVMs(virConnectPtr conn);
 
 
 typedef int (*virNWFilterRebuild)(virConnectPtr conn,
-                                  virHashIterator, void *data);
+                                  virDomainObjListIterator, void *data);
 typedef void (*virNWFilterVoidCall)(void);
 
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9441f48..17c35e1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -474,7 +474,7 @@ virDomainObjListExport;
 virDomainObjListFindByID;
 virDomainObjListFindByName;
 virDomainObjListFindByUUID;
-virDomainObjListFree;
+virDomainObjListForEach;
 virDomainObjListGetActiveIDs;
 virDomainObjListGetInactiveNames;
 virDomainObjListIsDuplicate;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 4afd106..a79a9ff 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -71,12 +71,12 @@ struct libxlOSEventHookTimerInfo {
     int id;
 };
 
+
 static libxlDriverPrivatePtr libxl_driver = NULL;
 
 /* Function declarations */
-static void
-libxlDomainManagedSaveLoad(void *payload,
-                           const void *n ATTRIBUTE_UNUSED,
+static int
+libxlDomainManagedSaveLoad(virDomainObjPtr vm,
                            void *opaque);
 
 static int
@@ -299,13 +299,13 @@ libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
     virDomainEventStateQueue(driver->domainEventState, event);
 }
 
-static void
-libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
+static int
+libxlAutostartDomain(virDomainObjPtr vm,
                      void *opaque)
 {
     libxlDriverPrivatePtr driver = opaque;
-    virDomainObjPtr vm = payload;
     virErrorPtr err;
+    int ret = -1;
 
     virObjectLock(vm);
     virResetLastError();
@@ -316,10 +316,14 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
         VIR_ERROR(_("Failed to autostart VM '%s': %s"),
                   vm->def->name,
                   err ? err->message : _("unknown error"));
+        goto cleanup;
     }
 
+    ret = 0;
+cleanup:
     if (vm)
         virObjectUnlock(vm);
+    return ret;
 }
 
 static int
@@ -861,12 +865,10 @@ error:
  * Reconnect to running domains that were previously started/created
  * with libxenlight driver.
  */
-static void
-libxlReconnectDomain(void *payload,
-                     const void *name ATTRIBUTE_UNUSED,
+static int
+libxlReconnectDomain(virDomainObjPtr vm,
                      void *opaque)
 {
-    virDomainObjPtr vm = payload;
     libxlDriverPrivatePtr driver = opaque;
     int rc;
     libxl_dominfo d_info;
@@ -903,7 +905,7 @@ libxlReconnectDomain(void *payload,
     /* Recreate domain death et. al. events */
     libxlCreateDomEvents(vm);
     virObjectUnlock(vm);
-    return;
+    return 0;
 
 out:
     libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_UNKNOWN);
@@ -911,12 +913,14 @@ out:
         virDomainObjListRemove(driver->domains, vm);
     else
         virObjectUnlock(vm);
+
+    return -1;
 }
 
 static void
 libxlReconnectDomains(libxlDriverPrivatePtr driver)
 {
-    virHashForEach(driver->domains->objs, libxlReconnectDomain, driver);
+    virDomainObjListForEach(driver->domains, libxlReconnectDomain, driver);
 }
 
 static int
@@ -927,7 +931,7 @@ libxlShutdown(void)
 
     libxlDriverLock(libxl_driver);
     virCapabilitiesFree(libxl_driver->caps);
-    virDomainObjListFree(libxl_driver->domains);
+    virObjectUnref(libxl_driver->domains);
     libxl_ctx_free(libxl_driver->ctx);
     xtl_logger_destroy(libxl_driver->logger);
     if (libxl_driver->logger_file)
@@ -1108,11 +1112,11 @@ libxlStartup(bool privileged,
                                        NULL, NULL) < 0)
         goto error;
 
-    virHashForEach(libxl_driver->domains->objs, libxlAutostartDomain,
-                   libxl_driver);
+    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+                            libxl_driver);
 
-    virHashForEach(libxl_driver->domains->objs, libxlDomainManagedSaveLoad,
-                   libxl_driver);
+    virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
+                            libxl_driver);
 
     libxlDriverUnlock(libxl_driver);
 
@@ -1144,8 +1148,8 @@ libxlReload(void)
                                    1, 1 << VIR_DOMAIN_VIRT_XEN,
                                    NULL, libxl_driver);
 
-    virHashForEach(libxl_driver->domains->objs, libxlAutostartDomain,
-                   libxl_driver);
+    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+                            libxl_driver);
 
     libxlDriverUnlock(libxl_driver);
 
@@ -2252,14 +2256,13 @@ cleanup:
     return ret;
 }
 
-static void
-libxlDomainManagedSaveLoad(void *payload,
-                           const void *n ATTRIBUTE_UNUSED,
+static int
+libxlDomainManagedSaveLoad(virDomainObjPtr vm,
                            void *opaque)
 {
-    virDomainObjPtr vm = payload;
     libxlDriverPrivatePtr driver = opaque;
     char *name;
+    int ret = -1;
 
     virObjectLock(vm);
 
@@ -2268,9 +2271,11 @@ libxlDomainManagedSaveLoad(void *payload,
 
     vm->hasManagedSave = virFileExists(name);
 
+    ret = 0;
 cleanup:
     virObjectUnlock(vm);
     VIR_FREE(name);
+    return ret;
 }
 
 static int
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9cd2fd8..db183c8 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -58,6 +58,7 @@
 #include "fdstream.h"
 #include "domain_audit.h"
 #include "domain_nwfilter.h"
+#include "nwfilter_conf.h"
 #include "network/bridge_driver.h"
 #include "virinitctl.h"
 #include "virnetdev.h"
@@ -82,11 +83,9 @@ virLXCDriverPtr lxc_driver = NULL;
 /* callbacks for nwfilter */
 static int
 lxcVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED,
-                   virHashIterator iter, void *data)
+                   virDomainObjListIterator iter, void *data)
 {
-    virHashForEach(lxc_driver->domains->objs, iter, data);
-
-    return 0;
+    return virDomainObjListForEach(lxc_driver->domains, iter, data);
 }
 
 static void
@@ -1555,7 +1554,7 @@ static int lxcShutdown(void)
 
     lxcDriverLock(lxc_driver);
     virNWFilterUnRegisterCallbackDriver(&lxcCallbackDriver);
-    virDomainObjListFree(lxc_driver->domains);
+    virObjectUnref(lxc_driver->domains);
     virDomainEventStateFree(lxc_driver->domainEventState);
 
     virLXCProcessAutoDestroyShutdown(lxc_driver);
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index f0aae40..5eff760 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1244,17 +1244,18 @@ struct virLXCProcessAutostartData {
     virConnectPtr conn;
 };
 
-static void
-virLXCProcessAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+static int
+virLXCProcessAutostartDomain(virDomainObjPtr vm,
+                             void *opaque)
 {
-    virDomainObjPtr vm = payload;
     const struct virLXCProcessAutostartData *data = opaque;
+    int ret = 0;
 
     virObjectLock(vm);
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
-        int ret = virLXCProcessStart(data->conn, data->driver, vm, false,
-                             VIR_DOMAIN_RUNNING_BOOTED);
+        ret = virLXCProcessStart(data->conn, data->driver, vm, false,
+                                 VIR_DOMAIN_RUNNING_BOOTED);
         virDomainAuditStart(vm, "booted", ret >= 0);
         if (ret < 0) {
             virErrorPtr err = virGetLastError();
@@ -1271,6 +1272,7 @@ virLXCProcessAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
         }
     }
     virObjectUnlock(vm);
+    return ret;
 }
 
 
@@ -1288,19 +1290,22 @@ virLXCProcessAutostartAll(virLXCDriverPtr driver)
     struct virLXCProcessAutostartData data = { driver, conn };
 
     lxcDriverLock(driver);
-    virHashForEach(driver->domains->objs, virLXCProcessAutostartDomain, &data);
+    virDomainObjListForEach(driver->domains,
+                            virLXCProcessAutostartDomain,
+                            &data);
     lxcDriverUnlock(driver);
 
     if (conn)
         virConnectClose(conn);
 }
 
-static void
-virLXCProcessReconnectDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+static int
+virLXCProcessReconnectDomain(virDomainObjPtr vm,
+                             void *opaque)
 {
-    virDomainObjPtr vm = payload;
     virLXCDriverPtr driver = opaque;
     virLXCDomainObjPrivatePtr priv;
+    int ret = -1;
 
     virObjectLock(vm);
     VIR_DEBUG("Reconnect id=%d pid=%d state=%d", vm->def->id, vm->pid, vm->state.state);
@@ -1344,9 +1349,10 @@ virLXCProcessReconnectDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
         vm->def->id = -1;
     }
 
+    ret = 0;
 cleanup:
     virObjectUnlock(vm);
-    return;
+    return ret;
 
 error:
     virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
@@ -1358,6 +1364,6 @@ error:
 int virLXCProcessReconnectAll(virLXCDriverPtr driver,
                               virDomainObjListPtr doms)
 {
-    virHashForEach(doms->objs, virLXCProcessReconnectDomain, driver);
+    virDomainObjListForEach(doms, virLXCProcessReconnectDomain, driver);
     return 0;
 }
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 8508f06..958f47a 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1150,16 +1150,15 @@ virNWFilterTeardownFilter(const virDomainNetDefPtr net)
 }
 
 
-void
-virNWFilterDomainFWUpdateCB(void *payload,
-                            const void *name ATTRIBUTE_UNUSED,
+int
+virNWFilterDomainFWUpdateCB(virDomainObjPtr obj,
                             void *data)
 {
-    virDomainObjPtr obj = payload;
     virDomainDefPtr vm = obj->def;
     struct domUpdateCBStruct *cb = data;
-    int i, err;
+    int i;
     bool skipIface;
+    int ret = 0;
 
     virObjectLock(obj);
 
@@ -1169,45 +1168,46 @@ virNWFilterDomainFWUpdateCB(void *payload,
             if ((net->filter) && (net->ifname)) {
                 switch (cb->step) {
                 case STEP_APPLY_NEW:
-                    cb->err = virNWFilterUpdateInstantiateFilter(cb->conn,
-                                                                 vm->uuid,
-                                                                 net,
-                                                                 &skipIface);
-                    if (cb->err == 0 && skipIface) {
+                    ret = virNWFilterUpdateInstantiateFilter(cb->conn,
+                                                             vm->uuid,
+                                                             net,
+                                                             &skipIface);
+                    if (ret == 0 && skipIface) {
                         /* filter tree unchanged -- no update needed */
-                        cb->err = virHashAddEntry(cb->skipInterfaces,
-                                                  net->ifname,
-                                                  (void *)~0);
+                        ret = virHashAddEntry(cb->skipInterfaces,
+                                              net->ifname,
+                                              (void *)~0);
                     }
                     break;
 
                 case STEP_TEAR_NEW:
                     if (!virHashLookup(cb->skipInterfaces, net->ifname)) {
-                        cb->err = virNWFilterRollbackUpdateFilter(net);
+                        ret = virNWFilterRollbackUpdateFilter(net);
                     }
                     break;
 
                 case STEP_TEAR_OLD:
                     if (!virHashLookup(cb->skipInterfaces, net->ifname)) {
-                        cb->err = virNWFilterTearOldFilter(net);
+                        ret = virNWFilterTearOldFilter(net);
                     }
                     break;
 
                 case STEP_APPLY_CURRENT:
-                    err = virNWFilterInstantiateFilter(cb->conn,
+                    ret = virNWFilterInstantiateFilter(cb->conn,
                                                        vm->uuid,
                                                        net);
-                    if (err)
+                    if (ret)
                         virReportError(VIR_ERR_INTERNAL_ERROR,
                                        _("Failure while applying current filter on "
                                          "VM %s"), vm->name);
                     break;
                 }
-                if (cb->err)
+                if (ret)
                     break;
             }
         }
     }
 
     virObjectUnlock(obj);
+    return ret;
 }
diff --git a/src/nwfilter/nwfilter_gentech_driver.h b/src/nwfilter/nwfilter_gentech_driver.h
index a632ca6..4b47b4a 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -23,6 +23,8 @@
 #ifndef __NWFILTER_GENTECH_DRIVER_H
 # define __NWFILTER_GENTECH_DRIVER_H
 
+# include "nwfilter_conf.h"
+
 virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name);
 
 int virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
@@ -60,8 +62,7 @@ int virNWFilterTeardownFilter(const virDomainNetDefPtr net);
 virNWFilterHashTablePtr virNWFilterCreateVarHashmap(char *macaddr,
                                        const virNWFilterVarValuePtr);
 
-void virNWFilterDomainFWUpdateCB(void *payload,
-                                 const void *name,
-                                 void *data);
+int virNWFilterDomainFWUpdateCB(virDomainObjPtr vm,
+                                void *data);
 
 #endif
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 46f30ca..6eacbca 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -558,7 +558,7 @@ openvzFreeDriver(struct openvz_driver *driver)
     if (!driver)
         return;
 
-    virDomainObjListFree(driver->domains);
+    virObjectUnref(driver->domains);
     virCapabilitiesFree(driver->caps);
     VIR_FREE(driver);
 }
@@ -570,6 +570,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
     char *status;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     virDomainObjPtr dom = NULL;
+    virDomainDefPtr def = NULL;
     char *temp = NULL;
     char *outbuf = NULL;
     char *line;
@@ -594,35 +595,20 @@ int openvzLoadDomains(struct openvz_driver *driver) {
         }
         *line++ = '\0';
 
-        if (!(dom = virDomainObjNew(driver->caps)))
-             goto cleanup;
-
-        if (VIR_ALLOC(dom->def) < 0)
+        if (VIR_ALLOC(def) < 0)
             goto no_memory;
 
-        dom->def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
-
-        if (STREQ(status, "stopped")) {
-            virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF,
-                                 VIR_DOMAIN_SHUTOFF_UNKNOWN);
-        } else {
-            virDomainObjSetState(dom, VIR_DOMAIN_RUNNING,
-                                 VIR_DOMAIN_RUNNING_UNKNOWN);
-        }
+        def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
 
-        dom->pid = veid;
         if (virDomainObjGetState(dom, NULL) == VIR_DOMAIN_SHUTOFF)
-            dom->def->id = -1;
+            def->id = -1;
         else
-            dom->def->id = veid;
-        /* XXX OpenVZ doesn't appear to have concept of a transient domain */
-        dom->persistent = 1;
-
-        if (virAsprintf(&dom->def->name, "%i", veid) < 0)
+            def->id = veid;
+        if (virAsprintf(&def->name, "%i", veid) < 0)
             goto no_memory;
 
         openvzGetVPSUUID(veid, uuidstr, sizeof(uuidstr));
-        ret = virUUIDParse(uuidstr, dom->def->uuid);
+        ret = virUUIDParse(uuidstr, def->uuid);
 
         if (ret == -1) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -630,9 +616,9 @@ int openvzLoadDomains(struct openvz_driver *driver) {
             goto cleanup;
         }
 
-        if (!(dom->def->os.type = strdup("exe")))
+        if (!(def->os.type = strdup("exe")))
             goto no_memory;
-        if (!(dom->def->os.init = strdup("/sbin/init")))
+        if (!(def->os.init = strdup("/sbin/init")))
             goto no_memory;
 
         ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
@@ -642,35 +628,47 @@ int openvzLoadDomains(struct openvz_driver *driver) {
                            veid);
             goto cleanup;
         } else if (ret > 0) {
-            dom->def->maxvcpus = strtoI(temp);
+            def->maxvcpus = strtoI(temp);
         }
 
-        if (ret == 0 || dom->def->maxvcpus == 0)
-            dom->def->maxvcpus = openvzGetNodeCPUs();
-        dom->def->vcpus = dom->def->maxvcpus;
+        if (ret == 0 || def->maxvcpus == 0)
+            def->maxvcpus = openvzGetNodeCPUs();
+        def->vcpus = def->maxvcpus;
 
         /* XXX load rest of VM config data .... */
 
-        openvzReadNetworkConf(dom->def, veid);
-        openvzReadFSConf(dom->def, veid);
-        openvzReadMemConf(dom->def, veid);
+        openvzReadNetworkConf(def, veid);
+        openvzReadFSConf(def, veid);
+        openvzReadMemConf(def, veid);
 
-        virUUIDFormat(dom->def->uuid, uuidstr);
-        if (virHashLookup(driver->domains->objs, uuidstr)) {
+        virUUIDFormat(def->uuid, uuidstr);
+        if (virDomainObjListIsDuplicate(driver->domains, def, true)) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Duplicate container UUID %s detected for %d"),
                            uuidstr,
                            veid);
             goto cleanup;
         }
-        if (virHashAddEntry(driver->domains->objs, uuidstr, dom) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Could not add UUID for container %d"), veid);
+        if (!(dom = virDomainObjListAdd(driver->domains,
+                                        driver->caps,
+                                        def,
+                                        STRNEQ(status, "stopped"))))
             goto cleanup;
+
+        if (STREQ(status, "stopped")) {
+            virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF,
+                                 VIR_DOMAIN_SHUTOFF_UNKNOWN);
+        } else {
+            virDomainObjSetState(dom, VIR_DOMAIN_RUNNING,
+                                 VIR_DOMAIN_RUNNING_UNKNOWN);
         }
+        /* XXX OpenVZ doesn't appear to have concept of a transient domain */
+        dom->persistent = 1;
+        dom->pid = veid;
 
         virObjectUnlock(dom);
         dom = NULL;
+        def = NULL;
     }
 
     virCommandFree(cmd);
@@ -687,6 +685,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
     VIR_FREE(temp);
     VIR_FREE(outbuf);
     virObjectUnref(dom);
+    virDomainDefFree(def);
     return -1;
 }
 
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index e472df8..ca1f862 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -940,7 +940,7 @@ parallelsOpenDefault(virConnectPtr conn)
     return VIR_DRV_OPEN_SUCCESS;
 
   error:
-    virDomainObjListFree(privconn->domains);
+    virObjectUnref(privconn->domains);
     virCapabilitiesFree(privconn->caps);
     virStoragePoolObjListFree(&privconn->pools);
     VIR_FREE(privconn);
@@ -987,7 +987,7 @@ parallelsClose(virConnectPtr conn)
 
     parallelsDriverLock(privconn);
     virCapabilitiesFree(privconn->caps);
-    virDomainObjListFree(privconn->domains);
+    virObjectUnref(privconn->domains);
     conn->privateData = NULL;
 
     parallelsDriverUnlock(privconn);
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 612168e..1186296 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -122,11 +122,6 @@ cleanup:
 
 }
 
-struct parallelsPoolsAddData {
-    virConnectPtr conn;
-    bool failed;
-};
-
 /*
  * Generate unique pool name by path
  */
@@ -404,26 +399,20 @@ cleanup:
 
 }
 
-static void
-parallelsPoolsAdd(void *payload,
-                  const void *name ATTRIBUTE_UNUSED,
+static int
+parallelsPoolsAdd(virDomainObjPtr dom,
                   void *opaque)
 {
-    struct parallelsPoolsAddData *data = (struct parallelsPoolsAddData *)opaque;
-    virDomainObjPtr dom = payload;
+    virConnectPtr conn = opaque;
     virStoragePoolObjPtr pool;
 
-    if (!(pool = parallelsPoolAddByDomain(data->conn, dom))) {
-        data->failed = true;
-        return;
-    }
+    if (!(pool = parallelsPoolAddByDomain(conn, dom)))
+        return -1;
 
-    if (parallelsFindVmVolumes(pool, dom)) {
-        data->failed = true;
-        return;
-    }
+    if (parallelsFindVmVolumes(pool, dom))
+        return -1;
 
-    return;
+    return 0;
 }
 
 static int parallelsLoadPools(virConnectPtr conn)
@@ -432,7 +421,6 @@ static int parallelsLoadPools(virConnectPtr conn)
     virStorageDriverStatePtr storageState = conn->storagePrivateData;
     char *base = NULL;
     size_t i;
-    struct parallelsPoolsAddData data;
 
     if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
         goto out_of_memory;
@@ -456,11 +444,7 @@ static int parallelsLoadPools(virConnectPtr conn)
         goto error;
     }
 
-    data.conn = conn;
-    data.failed = false;
-    virHashForEach(privconn->domains->objs, parallelsPoolsAdd, &data);
-
-    if (data.failed)
+    if (virDomainObjListForEach(privconn->domains, parallelsPoolsAdd, conn) < 0)
         goto error;
 
     for (i = 0; i < privconn->pools.count; i++) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 98d9501..97f010b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -79,6 +79,7 @@
 #include "cpu/cpu.h"
 #include "virsysinfo.h"
 #include "domain_nwfilter.h"
+#include "nwfilter_conf.h"
 #include "virhook.h"
 #include "virstoragefile.h"
 #include "virfile.h"
@@ -144,9 +145,8 @@ static int qemuDomainObjStart(virConnectPtr conn,
 
 static int qemuDomainGetMaxVcpus(virDomainPtr dom);
 
-static void qemuDomainManagedSaveLoad(void *payload,
-                                      const void *n ATTRIBUTE_UNUSED,
-                                      void *opaque);
+static int qemuDomainManagedSaveLoad(virDomainObjPtr vm,
+                                     void *opaque);
 
 
 virQEMUDriverPtr qemu_driver = NULL;
@@ -166,11 +166,9 @@ qemuVMDriverUnlock(void) {
 
 static int
 qemuVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED,
-                    virHashIterator iter, void *data)
+                    virDomainObjListIterator iter, void *data)
 {
-    virHashForEach(qemu_driver->domains->objs, iter, data);
-
-    return 0;
+    return virDomainObjListForEach(qemu_driver->domains, iter, data);
 }
 
 static virNWFilterCallbackDriver qemuCallbackDriver = {
@@ -278,15 +276,15 @@ qemuSnapObjFromSnapshot(virDomainObjPtr vm,
     return qemuSnapObjFromName(vm, snapshot->name);
 }
 
-static void
-qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
+static int
+qemuAutostartDomain(virDomainObjPtr vm,
                     void *opaque)
 {
-    virDomainObjPtr vm = payload;
     struct qemuAutostartData *data = opaque;
     virErrorPtr err;
     int flags = 0;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(data->driver);
+    int ret = -1;
 
     if (cfg->autoStartBypassCache)
         flags |= VIR_DOMAIN_START_BYPASS_CACHE;
@@ -315,10 +313,12 @@ qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
             vm = NULL;
     }
 
+    ret = 0;
 cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(cfg);
+    return ret;
 }
 
 
@@ -336,7 +336,7 @@ qemuAutostartDomains(virQEMUDriverPtr driver)
     struct qemuAutostartData data = { driver, conn };
 
     qemuDriverLock(driver);
-    virHashForEach(driver->domains->objs, qemuAutostartDomain, &data);
+    virDomainObjListForEach(driver->domains, qemuAutostartDomain, &data);
     qemuDriverUnlock(driver);
 
     if (conn)
@@ -489,18 +489,15 @@ err_exit:
 }
 
 
-static void
-qemuDomainSnapshotLoad(void *payload,
-                       const void *name ATTRIBUTE_UNUSED,
+static int
+qemuDomainSnapshotLoad(virDomainObjPtr vm,
                        void *data)
 {
-    virDomainObjPtr vm = (virDomainObjPtr)payload;
     char *baseDir = (char *)data;
     char *snapDir = NULL;
     DIR *dir = NULL;
     struct dirent *entry;
     char *xmlStr;
-    int ret;
     char *fullpath;
     virDomainSnapshotDefPtr def = NULL;
     virDomainSnapshotObjPtr snap = NULL;
@@ -509,6 +506,7 @@ qemuDomainSnapshotLoad(void *payload,
     unsigned int flags = (VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE |
                           VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
                           VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL);
+    int ret = -1;
 
     virObjectLock(vm);
     if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
@@ -541,8 +539,7 @@ qemuDomainSnapshotLoad(void *payload,
             continue;
         }
 
-        ret = virFileReadAll(fullpath, 1024*1024*1, &xmlStr);
-        if (ret < 0) {
+        if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) {
             /* Nothing we can do here, skip this one */
             VIR_ERROR(_("Failed to read snapshot file %s: %s"), fullpath,
                       virStrerror(errno, ebuf, sizeof(ebuf)));
@@ -596,21 +593,21 @@ qemuDomainSnapshotLoad(void *payload,
 
     virResetLastError();
 
+    ret = 0;
 cleanup:
     if (dir)
         closedir(dir);
     VIR_FREE(snapDir);
     virObjectUnlock(vm);
+    return ret;
 }
 
 
-static void
-qemuDomainNetsRestart(void *payload,
-                      const void *name ATTRIBUTE_UNUSED,
+static int
+qemuDomainNetsRestart(virDomainObjPtr vm,
                       void *data ATTRIBUTE_UNUSED)
 {
     int i;
-    virDomainObjPtr vm = (virDomainObjPtr)payload;
     virDomainDefPtr def = vm->def;
 
     virObjectLock(vm);
@@ -631,19 +628,20 @@ qemuDomainNetsRestart(void *payload,
     }
 
     virObjectUnlock(vm);
+    return 0;
 }
 
 
-static void
-qemuDomainFindMaxID(void *payload,
-                    const void *name ATTRIBUTE_UNUSED,
+static int
+qemuDomainFindMaxID(virDomainObjPtr vm,
                     void *data)
 {
-    virDomainObjPtr vm = payload;
     int *driver_maxid = data;
 
     if (vm->def->id >= *driver_maxid)
         *driver_maxid = vm->def->id + 1;
+
+    return 0;
 }
 
 
@@ -875,11 +873,13 @@ qemuStartup(bool privileged,
     /* find the maximum ID from active and transient configs to initialize
      * the driver with. This is to avoid race between autostart and reconnect
      * threads */
-    virHashForEach(qemu_driver->domains->objs,
-                   qemuDomainFindMaxID,
-                   &qemu_driver->nextvmid);
+    virDomainObjListForEach(qemu_driver->domains,
+                            qemuDomainFindMaxID,
+                            &qemu_driver->nextvmid);
 
-    virHashForEach(qemu_driver->domains->objs, qemuDomainNetsRestart, NULL);
+    virDomainObjListForEach(qemu_driver->domains,
+                            qemuDomainNetsRestart,
+                            NULL);
 
     conn = virConnectOpen(cfg->uri);
 
@@ -895,13 +895,13 @@ qemuStartup(bool privileged,
         goto error;
 
 
-    virHashForEach(qemu_driver->domains->objs,
-                   qemuDomainSnapshotLoad,
-                   cfg->snapshotDir);
+    virDomainObjListForEach(qemu_driver->domains,
+                            qemuDomainSnapshotLoad,
+                            cfg->snapshotDir);
 
-    virHashForEach(qemu_driver->domains->objs,
-                   qemuDomainManagedSaveLoad,
-                   qemu_driver);
+    virDomainObjListForEach(qemu_driver->domains,
+                            qemuDomainManagedSaveLoad,
+                            qemu_driver);
 
     qemu_driver->workerPool = virThreadPoolNew(0, 1, 0, processWatchdogEvent, qemu_driver);
     if (!qemu_driver->workerPool)
@@ -1055,7 +1055,7 @@ qemuShutdown(void) {
     virCapabilitiesFree(qemu_driver->caps);
     qemuCapsCacheFree(qemu_driver->capsCache);
 
-    virDomainObjListFree(qemu_driver->domains);
+    virObjectUnref(qemu_driver->domains);
     virObjectUnref(qemu_driver->remotePorts);
 
     virSysinfoDefFree(qemu_driver->hostsysinfo);
@@ -3136,14 +3136,13 @@ cleanup:
     return ret;
 }
 
-static void
-qemuDomainManagedSaveLoad(void *payload,
-                          const void *n ATTRIBUTE_UNUSED,
+static int
+qemuDomainManagedSaveLoad(virDomainObjPtr vm,
                           void *opaque)
 {
-    virDomainObjPtr vm = payload;
     virQEMUDriverPtr driver = opaque;
     char *name;
+    int ret = -1;
 
     virObjectLock(vm);
 
@@ -3152,11 +3151,14 @@ qemuDomainManagedSaveLoad(void *payload,
 
     vm->hasManagedSave = virFileExists(name);
 
+    ret = 0;
 cleanup:
     virObjectUnlock(vm);
     VIR_FREE(name);
+    return ret;
 }
 
+
 static int
 qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
 {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index dad6e25..8f76dde 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3338,23 +3338,21 @@ error:
     virObjectUnref(cfg);
 }
 
-static void
-qemuProcessReconnectHelper(void *payload,
-                           const void *name ATTRIBUTE_UNUSED,
+static int
+qemuProcessReconnectHelper(virDomainObjPtr obj,
                            void *opaque)
 {
     virThread thread;
     struct qemuProcessReconnectData *src = opaque;
     struct qemuProcessReconnectData *data;
-    virDomainObjPtr obj = payload;
 
     if (VIR_ALLOC(data) < 0) {
         virReportOOMError();
-        return;
+        return -1;
     }
 
     memcpy(data, src, sizeof(*data));
-    data->payload = payload;
+    data->payload = obj;
 
     /* This iterator is called with driver being locked.
      * We create a separate thread to run qemuProcessReconnect in it.
@@ -3415,10 +3413,11 @@ qemuProcessReconnectHelper(void *payload,
 
     virObjectUnlock(obj);
 
-    return;
+    return 0;
 
 error:
     VIR_FREE(data);
+    return -1;
 }
 
 /**
@@ -3431,7 +3430,7 @@ void
 qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
 {
     struct qemuProcessReconnectData data = {.conn = conn, .driver = driver};
-    virHashForEach(driver->domains->objs, qemuProcessReconnectHelper, &data);
+    virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
 }
 
 int
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 78b73b3..c4685b7 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -628,7 +628,7 @@ static int testOpenDefault(virConnectPtr conn) {
     return VIR_DRV_OPEN_SUCCESS;
 
 error:
-    virDomainObjListFree(privconn->domains);
+    virObjectUnref(privconn->domains);
     virNetworkObjListFree(&privconn->networks);
     virInterfaceObjListFree(&privconn->ifaces);
     virStoragePoolObjListFree(&privconn->pools);
@@ -1097,7 +1097,7 @@ static int testOpenFromFile(virConnectPtr conn,
     VIR_FREE(ifaces);
     VIR_FREE(pools);
     VIR_FREE(devs);
-    virDomainObjListFree(privconn->domains);
+    virObjectUnref(privconn->domains);
     virNetworkObjListFree(&privconn->networks);
     virInterfaceObjListFree(&privconn->ifaces);
     virStoragePoolObjListFree(&privconn->pools);
@@ -1166,7 +1166,7 @@ static int testClose(virConnectPtr conn)
     testConnPtr privconn = conn->privateData;
     testDriverLock(privconn);
     virCapabilitiesFree(privconn->caps);
-    virDomainObjListFree(privconn->domains);
+    virObjectUnref(privconn->domains);
     virNodeDeviceObjListFree(&privconn->devs);
     virNetworkObjListFree(&privconn->networks);
     virInterfaceObjListFree(&privconn->ifaces);
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 613973c..6702a7e 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -58,6 +58,7 @@
 #include "datatypes.h"
 #include "virlog.h"
 #include "domain_nwfilter.h"
+#include "nwfilter_conf.h"
 #include "virfile.h"
 #include "fdstream.h"
 #include "configmake.h"
@@ -148,11 +149,9 @@ static struct uml_driver *uml_driver = NULL;
 
 static int
 umlVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED,
-                   virHashIterator iter, void *data)
+                   virDomainObjListIterator iter, void *data)
 {
-    virHashForEach(uml_driver->domains->objs, iter, data);
-
-    return 0;
+    return virDomainObjListForEach(uml_driver->domains, iter, data);
 }
 
 static void
@@ -179,16 +178,15 @@ struct umlAutostartData {
     virConnectPtr conn;
 };
 
-static void
-umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+static int
+umlAutostartDomain(virDomainObjPtr vm,
+                   void *opaque)
 {
-    virDomainObjPtr vm = payload;
     const struct umlAutostartData *data = opaque;
-
+    int ret = 0;
     virObjectLock(vm);
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
-        int ret;
         virResetLastError();
         ret = umlStartVMDaemon(data->conn, data->driver, vm, false);
         virDomainAuditStart(vm, "booted", ret >= 0);
@@ -206,6 +204,7 @@ umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaqu
         }
     }
     virObjectUnlock(vm);
+    return ret;
 }
 
 static void
@@ -223,7 +222,7 @@ umlAutostartConfigs(struct uml_driver *driver) {
     struct umlAutostartData data = { driver, conn };
 
     umlDriverLock(driver);
-    virHashForEach(driver->domains->objs, umlAutostartDomain, &data);
+    virDomainObjListForEach(driver->domains, umlAutostartDomain, &data);
     umlDriverUnlock(driver);
 
     if (conn)
@@ -600,10 +599,9 @@ umlReload(void) {
 }
 
 
-static void
-umlShutdownOneVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+static int
+umlShutdownOneVM(virDomainObjPtr dom, void *opaque)
 {
-    virDomainObjPtr dom = payload;
     struct uml_driver *driver = opaque;
 
     virObjectLock(dom);
@@ -612,6 +610,7 @@ umlShutdownOneVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
         virDomainAuditStop(dom, "shutdown");
     }
     virObjectUnlock(dom);
+    return 0;
 }
 
 /**
@@ -633,9 +632,9 @@ umlShutdown(void) {
 
     /* shutdown active VMs
      * XXX allow them to stay around & reconnect */
-    virHashForEach(uml_driver->domains->objs, umlShutdownOneVM, uml_driver);
+    virDomainObjListForEach(uml_driver->domains, umlShutdownOneVM, uml_driver);
 
-    virDomainObjListFree(uml_driver->domains);
+    virObjectUnref(uml_driver->domains);
 
     virDomainEventStateFree(uml_driver->domainEventState);
 
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index d2afce3..b616c1b 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -43,7 +43,7 @@ vmwareFreeDriver(struct vmware_driver *driver)
         return;
 
     virMutexDestroy(&driver->lock);
-    virDomainObjListFree(driver->domains);
+    virObjectUnref(driver->domains);
     virCapabilitiesFree(driver->caps);
     VIR_FREE(driver);
 }
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 3b2d1e5..b99fca3 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -946,19 +946,19 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
     return xml;
 }
 
-static void vmwareDomainObjListUpdateDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *data)
+static int vmwareDomainObjListUpdateDomain(virDomainObjPtr dom, void *data)
 {
     struct vmware_driver *driver = data;
-    virDomainObjPtr vm = payload;
-    virObjectLock(vm);
-    ignore_value(vmwareUpdateVMStatus(driver, vm));
-    virObjectUnlock(vm);
+    virObjectLock(dom);
+    ignore_value(vmwareUpdateVMStatus(driver, dom));
+    virObjectUnlock(dom);
+    return 0;
 }
 
 static void
 vmwareDomainObjListUpdateAll(virDomainObjListPtr doms, struct vmware_driver *driver)
 {
-    virHashForEach(doms->objs, vmwareDomainObjListUpdateDomain, driver);
+    virDomainObjListForEach(doms, vmwareDomainObjListUpdateDomain, driver);
 }
 
 static int
-- 
1.8.0.2


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