[PATCH 3/7] Convert virDomainObj, qemuAgent, qemuMonitor, lxcMonitor to virObjectLockable

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The  virDomainObj, qemuAgent, qemuMonitor, lxcMonitor classes
all require a mutex, so can be switched to use virObjectLockable
---
 src/conf/domain_conf.c                 |  66 ++++------
 src/conf/domain_conf.h                 |   7 +-
 src/libvirt_private.syms               |   2 -
 src/libxl/libxl_driver.c               |  92 ++++++-------
 src/lxc/lxc_driver.c                   |  70 +++++-----
 src/lxc/lxc_monitor.c                  |  32 +----
 src/lxc/lxc_process.c                  |  14 +-
 src/nwfilter/nwfilter_gentech_driver.c |   4 +-
 src/openvz/openvz_conf.c               |   2 +-
 src/openvz/openvz_driver.c             |  46 +++----
 src/parallels/parallels_driver.c       |  28 ++--
 src/qemu/THREADS.txt                   |   8 +-
 src/qemu/qemu_agent.c                  |  49 ++-----
 src/qemu/qemu_agent.h                  |   3 -
 src/qemu/qemu_capabilities.c           |   4 +-
 src/qemu/qemu_conf.c                   |   2 +-
 src/qemu/qemu_domain.c                 |  32 ++---
 src/qemu/qemu_driver.c                 | 232 ++++++++++++++++-----------------
 src/qemu/qemu_migration.c              |  12 +-
 src/qemu/qemu_monitor.c                |  60 +++------
 src/qemu/qemu_monitor.h                |   3 -
 src/qemu/qemu_process.c                | 106 +++++++--------
 src/test/test_driver.c                 |  74 +++++------
 src/uml/uml_driver.c                   |  68 +++++-----
 src/vmware/vmware_conf.c               |   2 +-
 src/vmware/vmware_driver.c             |  38 +++---
 tests/qemumonitortestutils.c           |   4 +-
 27 files changed, 481 insertions(+), 579 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 38dc334..494008b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -695,7 +695,7 @@ static void virDomainObjDispose(void *obj);
 
 static int virDomainObjOnceInit(void)
 {
-    if (!(virDomainObjClass = virClassNew(virClassForObject(),
+    if (!(virDomainObjClass = virClassNew(virClassForObjectLockable(),
                                           "virDomainObj",
                                           sizeof(virDomainObj),
                                           virDomainObjDispose)))
@@ -796,11 +796,11 @@ static int virDomainObjListSearchID(const void *payload,
     const int *id = data;
     int want = 0;
 
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (virDomainObjIsActive(obj) &&
         obj->def->id == *id)
         want = 1;
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
     return want;
 }
 
@@ -810,7 +810,7 @@ virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms,
     virDomainObjPtr obj;
     obj = virHashSearch(doms->objs, virDomainObjListSearchID, &id);
     if (obj)
-        virDomainObjLock(obj);
+        virObjectLock(obj);
     return obj;
 }
 
@@ -825,7 +825,7 @@ virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
 
     obj = virHashLookup(doms->objs, uuidstr);
     if (obj)
-        virDomainObjLock(obj);
+        virObjectLock(obj);
     return obj;
 }
 
@@ -836,10 +836,10 @@ static int virDomainObjListSearchName(const void *payload,
     virDomainObjPtr obj = (virDomainObjPtr)payload;
     int want = 0;
 
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (STREQ(obj->def->name, (const char *)data))
         want = 1;
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
     return want;
 }
 
@@ -849,7 +849,7 @@ virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
     virDomainObjPtr obj;
     obj = virHashSearch(doms->objs, virDomainObjListSearchName, name);
     if (obj)
-        virDomainObjLock(obj);
+        virObjectLock(obj);
     return obj;
 }
 
@@ -1781,8 +1781,6 @@ static void virDomainObjDispose(void *obj)
     if (dom->privateDataFreeFunc)
         (dom->privateDataFreeFunc)(dom->privateData);
 
-    virMutexDestroy(&dom->lock);
-
     virDomainSnapshotObjListFree(dom->snapshots);
 }
 
@@ -1794,16 +1792,9 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps)
     if (virDomainObjInitialize() < 0)
         return NULL;
 
-    if (!(domain = virObjectNew(virDomainObjClass)))
+    if (!(domain = virObjectLockableNew(virDomainObjClass)))
         return NULL;
 
-    if (virMutexInit(&domain->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("cannot initialize mutex"));
-        VIR_FREE(domain);
-        return NULL;
-    }
-
     if (caps &&
         caps->privateDataAllocFunc) {
         if (!(domain->privateData = (caps->privateDataAllocFunc)())) {
@@ -1816,7 +1807,7 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps)
     if (!(domain->snapshots = virDomainSnapshotObjListNew()))
         goto error;
 
-    virDomainObjLock(domain);
+    virObjectLock(domain);
     virDomainObjSetState(domain, VIR_DOMAIN_SHUTOFF,
                                  VIR_DOMAIN_SHUTOFF_UNKNOWN);
 
@@ -1994,7 +1985,7 @@ void virDomainRemoveInactive(virDomainObjListPtr doms,
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     virUUIDFormat(dom->def->uuid, uuidstr);
 
-    virDomainObjUnlock(dom);
+    virObjectUnlock(dom);
 
     virHashRemoveEntry(doms->objs, uuidstr);
 }
@@ -14894,7 +14885,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
                                       notify,
                                       opaque);
         if (dom) {
-            virDomainObjUnlock(dom);
+            virObjectUnlock(dom);
             if (!liveStatus)
                 dom->persistent = 1;
         }
@@ -15061,40 +15052,29 @@ virDomainObjIsDuplicate(virDomainObjListPtr doms,
     ret = dupVM;
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
 
-void virDomainObjLock(virDomainObjPtr obj)
-{
-    virMutexLock(&obj->lock);
-}
-
-void virDomainObjUnlock(virDomainObjPtr obj)
-{
-    virMutexUnlock(&obj->lock);
-}
-
-
 static void virDomainObjListCountActive(void *payload, const void *name ATTRIBUTE_UNUSED, void *data)
 {
     virDomainObjPtr obj = payload;
     int *count = data;
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (virDomainObjIsActive(obj))
         (*count)++;
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 }
 
 static void virDomainObjListCountInactive(void *payload, const void *name ATTRIBUTE_UNUSED, void *data)
 {
     virDomainObjPtr obj = payload;
     int *count = data;
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (!virDomainObjIsActive(obj))
         (*count)++;
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 }
 
 int virDomainObjListNumOfDomains(virDomainObjListPtr doms, int active)
@@ -15117,10 +15097,10 @@ static void virDomainObjListCopyActiveIDs(void *payload, const void *name ATTRIB
 {
     virDomainObjPtr obj = payload;
     struct virDomainIDData *data = opaque;
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (virDomainObjIsActive(obj) && data->numids < data->maxids)
         data->ids[data->numids++] = obj->def->id;
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 }
 
 int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
@@ -15147,14 +15127,14 @@ static void virDomainObjListCopyInactiveNames(void *payload, const void *name AT
     if (data->oom)
         return;
 
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     if (!virDomainObjIsActive(obj) && data->numnames < data->maxnames) {
         if (!(data->names[data->numnames] = strdup(obj->def->name)))
             data->oom = 1;
         else
             data->numnames++;
     }
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 }
 
 
@@ -15847,7 +15827,7 @@ virDomainListPopulate(void *payload,
     if (data->error)
         return;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     /* check if the domain matches the filter */
 
     /* filter by active state */
@@ -15920,7 +15900,7 @@ virDomainListPopulate(void *payload,
     data->domains[data->ndomains++] = dom;
 
 cleanup:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     return;
 }
 #undef MATCH
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4284caf..e85c67e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1858,9 +1858,7 @@ struct _virDomainStateReason {
 typedef struct _virDomainObj virDomainObj;
 typedef virDomainObj *virDomainObjPtr;
 struct _virDomainObj {
-    virObject object;
-
-    virMutex lock;
+    virObjectLockable parent;
 
     pid_t pid;
     virDomainStateReason state;
@@ -2159,9 +2157,6 @@ int virDomainObjIsDuplicate(virDomainObjListPtr doms,
                             virDomainDefPtr def,
                             unsigned int check_active);
 
-void virDomainObjLock(virDomainObjPtr obj);
-void virDomainObjUnlock(virDomainObjPtr obj);
-
 int virDomainObjListNumOfDomains(virDomainObjListPtr doms, int active);
 
 int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f02aee4..cbdbb32 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -479,12 +479,10 @@ virDomainObjListGetActiveIDs;
 virDomainObjListGetInactiveNames;
 virDomainObjListInit;
 virDomainObjListNumOfDomains;
-virDomainObjLock;
 virDomainObjNew;
 virDomainObjSetDefTransient;
 virDomainObjSetState;
 virDomainObjTaint;
-virDomainObjUnlock;
 virDomainPausedReasonTypeFromString;
 virDomainPausedReasonTypeToString;
 virDomainPciRombarModeTypeFromString;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a956188..8017a4a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -299,7 +299,7 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
     virDomainObjPtr vm = payload;
     virErrorPtr err;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     virResetLastError();
 
     if (vm->autostart && !virDomainObjIsActive(vm) &&
@@ -311,7 +311,7 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
     }
 
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 }
 
 static int
@@ -528,7 +528,7 @@ static void libxlEventHandler(void *data, const libxl_event *event)
     virDomainEventPtr dom_event = NULL;
 
     libxlDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     libxlDriverUnlock(driver);
 
     if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN) {
@@ -566,7 +566,7 @@ static void libxlEventHandler(void *data, const libxl_event *event)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (dom_event) {
         libxlDriverLock(driver);
         libxlDomainEventQueue(driver, dom_event);
@@ -863,7 +863,7 @@ libxlReconnectDomain(void *payload,
     int len;
     uint8_t *data = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     /* Does domain still exist? */
     rc = libxl_domain_info(driver->ctx, &d_info, vm->def->id);
@@ -892,7 +892,7 @@ libxlReconnectDomain(void *payload,
 
     /* Recreate domain death et. al. events */
     libxlCreateDomEvents(vm);
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     return;
 
 out:
@@ -900,7 +900,7 @@ out:
     if (!vm->persistent)
         virDomainRemoveInactive(&driver->domains, vm);
     else
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 }
 
 static void
@@ -1312,7 +1312,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return dom;
 }
@@ -1339,7 +1339,7 @@ libxlDomainLookupByID(virConnectPtr conn, int id)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1365,7 +1365,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1391,7 +1391,7 @@ libxlDomainLookupByName(virConnectPtr conn, const char *name)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1443,7 +1443,7 @@ libxlDomainSuspend(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event) {
         libxlDriverLock(driver);
         libxlDomainEventQueue(driver, event);
@@ -1503,7 +1503,7 @@ libxlDomainResume(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event) {
         libxlDriverLock(driver);
         libxlDomainEventQueue(driver, event);
@@ -1553,7 +1553,7 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -1602,7 +1602,7 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -1652,7 +1652,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         libxlDomainEventQueue(driver, event);
     libxlDriverUnlock(driver);
@@ -1688,7 +1688,7 @@ libxlDomainGetOSType(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return type;
 }
 
@@ -1711,7 +1711,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1825,7 +1825,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1880,7 +1880,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1911,7 +1911,7 @@ libxlDomainGetState(virDomainPtr dom,
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2033,7 +2033,7 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -2087,7 +2087,7 @@ cleanup:
         virReportSystemError(errno, "%s", _("cannot close file"));
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -2183,7 +2183,7 @@ cleanup_unpause:
     }
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event) {
         libxlDriverLock(driver);
         libxlDomainEventQueue(driver, event);
@@ -2232,7 +2232,7 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     VIR_FREE(name);
     return ret;
@@ -2247,7 +2247,7 @@ libxlDomainManagedSaveLoad(void *payload,
     libxlDriverPrivatePtr driver = opaque;
     char *name;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     if (!(name = libxlDomainManagedSavePath(driver, vm)))
         goto cleanup;
@@ -2255,7 +2255,7 @@ libxlDomainManagedSaveLoad(void *payload,
     vm->hasManagedSave = virFileExists(name);
 
 cleanup:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     VIR_FREE(name);
 }
 
@@ -2282,7 +2282,7 @@ libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -2317,7 +2317,7 @@ libxlDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
 cleanup:
     VIR_FREE(name);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -2452,7 +2452,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 cleanup:
     VIR_FREE(bitmask);
      if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2518,7 +2518,7 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2581,7 +2581,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2649,7 +2649,7 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2676,7 +2676,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2827,7 +2827,7 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -2882,7 +2882,7 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml)
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         libxlDomainEventQueue(driver, event);
     libxlDriverUnlock(driver);
@@ -2958,7 +2958,7 @@ libxlDomainUndefineFlags(virDomainPtr dom,
   cleanup:
     VIR_FREE(name);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         libxlDomainEventQueue(driver, event);
     libxlDriverUnlock(driver);
@@ -3438,7 +3438,7 @@ cleanup:
     virDomainDefFree(vmdef);
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -3558,7 +3558,7 @@ libxlDomainGetAutostart(virDomainPtr dom, int *autostart)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3626,7 +3626,7 @@ cleanup:
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     libxlDriverUnlock(driver);
     return ret;
 }
@@ -3686,7 +3686,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3754,7 +3754,7 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3840,7 +3840,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3869,7 +3869,7 @@ libxlDomainIsActive(virDomainPtr dom)
 
   cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -3891,7 +3891,7 @@ libxlDomainIsPersistent(virDomainPtr dom)
 
   cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -3913,7 +3913,7 @@ libxlDomainIsUpdated(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 8050ce6..957a073 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -222,7 +222,7 @@ static virDomainPtr lxcDomainLookupByID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -251,7 +251,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -277,7 +277,7 @@ static virDomainPtr lxcDomainLookupByName(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -302,7 +302,7 @@ static int lxcDomainIsActive(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -327,7 +327,7 @@ static int lxcDomainIsPersistent(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -351,7 +351,7 @@ static int lxcDomainIsUpdated(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -456,7 +456,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     lxcDriverUnlock(driver);
@@ -509,7 +509,7 @@ static int lxcDomainUndefineFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     lxcDriverUnlock(driver);
@@ -578,7 +578,7 @@ cleanup:
     if (cgroup)
         virCgroupFree(&cgroup);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -611,7 +611,7 @@ lxcDomainGetState(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -640,7 +640,7 @@ static char *lxcGetOSType(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -668,7 +668,7 @@ lxcDomainGetMaxMemory(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -700,7 +700,7 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -755,7 +755,7 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (cgroup)
         virCgroupFree(&cgroup);
     return ret;
@@ -834,7 +834,7 @@ cleanup:
     if (cgroup)
         virCgroupFree(&cgroup);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -933,7 +933,7 @@ cleanup:
     if (cgroup)
         virCgroupFree(&cgroup);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -965,7 +965,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1024,7 +1024,7 @@ static int lxcDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     lxcDriverUnlock(driver);
@@ -1111,7 +1111,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     lxcDriverUnlock(driver);
@@ -1172,7 +1172,7 @@ static int lxcDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secla
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -1342,7 +1342,7 @@ lxcDomainDestroyFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     lxcDriverUnlock(driver);
@@ -1871,7 +1871,7 @@ cleanup:
     virDomainDefFree(vmdef);
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -1990,7 +1990,7 @@ out:
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2099,7 +2099,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2206,7 +2206,7 @@ cleanup:
     if (group)
         virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2258,7 +2258,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 #else
@@ -2295,7 +2295,7 @@ static int lxcDomainGetAutostart(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2369,7 +2369,7 @@ cleanup:
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2512,7 +2512,7 @@ cleanup:
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2578,7 +2578,7 @@ cleanup:
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2648,7 +2648,7 @@ lxcDomainOpenConsole(virDomainPtr dom,
     ret = 0;
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
@@ -2727,7 +2727,7 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2829,7 +2829,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
 cleanup:
     VIR_FREE(vroot);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2918,7 +2918,7 @@ lxcDomainReboot(virDomainPtr dom,
 cleanup:
     VIR_FREE(vroot);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4418,7 +4418,7 @@ cleanup:
         virDomainDeviceDefFree(dev_copy);
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     lxcDriverUnlock(driver);
     return ret;
 }
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index f697e09..e3901f8 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -34,9 +34,7 @@
 #define VIR_FROM_THIS VIR_FROM_LXC
 
 struct _virLXCMonitor {
-    virObject parent;
-
-    virMutex lock;
+    virObjectLockable parent;
 
     virDomainObjPtr vm;
     virLXCMonitorCallbacks cb;
@@ -50,7 +48,7 @@ static void virLXCMonitorDispose(void *obj);
 
 static int virLXCMonitorOnceInit(void)
 {
-    if (!(virLXCMonitorClass = virClassNew(virClassForObject(),
+    if (!(virLXCMonitorClass = virClassNew(virClassForObjectLockable(),
                                            "virLXCMonitor",
                                            sizeof(virLXCMonitor),
                                            virLXCMonitorDispose)))
@@ -120,10 +118,10 @@ static void virLXCMonitorEOFNotify(virNetClientPtr client ATTRIBUTE_UNUSED,
     virDomainObjPtr vm;
 
     VIR_DEBUG("EOF notify mon=%p", mon);
-    virLXCMonitorLock(mon);
+    virObjectLock(mon);
     eofNotify = mon->cb.eofNotify;
     vm = mon->vm;
-    virLXCMonitorUnlock(mon);
+    virObjectUnlock(mon);
 
     if (eofNotify) {
         VIR_DEBUG("EOF callback mon=%p vm=%p", mon, vm);
@@ -151,15 +149,8 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
     if (virLXCMonitorInitialize() < 0)
         return NULL;
 
-    if (!(mon = virObjectNew(virLXCMonitorClass)))
-        return NULL;
-
-    if (virMutexInit(&mon->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot initialize monitor mutex"));
-        VIR_FREE(mon);
+    if (!(mon = virObjectLockableNew(virLXCMonitorClass)))
         return NULL;
-    }
 
     if (virAsprintf(&sockpath, "%s/%s.sock",
                     socketdir, vm->def->name) < 0)
@@ -209,7 +200,6 @@ static void virLXCMonitorDispose(void *opaque)
     VIR_DEBUG("mon=%p", mon);
     if (mon->cb.destroy)
         (mon->cb.destroy)(mon, mon->vm);
-    virMutexDestroy(&mon->lock);
     virObjectUnref(mon->program);
 }
 
@@ -229,15 +219,3 @@ void virLXCMonitorClose(virLXCMonitorPtr mon)
         mon->client = NULL;
     }
 }
-
-
-void virLXCMonitorLock(virLXCMonitorPtr mon)
-{
-    virMutexLock(&mon->lock);
-}
-
-
-void virLXCMonitorUnlock(virLXCMonitorPtr mon)
-{
-    virMutexUnlock(&mon->lock);
-}
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 1a89e4a..4ad7ba0 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -104,7 +104,7 @@ static void virLXCProcessAutoDestroyDom(void *payload,
         virDomainRemoveInactive(&data->driver->domains, dom);
 
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     if (event)
         virDomainEventStateQueue(data->driver->domainEventState, event);
     virHashRemoveEntry(data->driver->autodestroy, uuidstr);
@@ -558,7 +558,7 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
     VIR_DEBUG("mon=%p vm=%p", mon, vm);
 
     lxcDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     lxcDriverUnlock(driver);
 
     priv = vm->privateData;
@@ -595,7 +595,7 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
     }
 
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event) {
         lxcDriverLock(driver);
         virDomainEventStateQueue(driver->domainEventState, event);
@@ -1250,7 +1250,7 @@ virLXCProcessAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
     virDomainObjPtr vm = payload;
     const struct virLXCProcessAutostartData *data = opaque;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
         int ret = virLXCProcessStart(data->conn, data->driver, vm, false,
@@ -1270,7 +1270,7 @@ virLXCProcessAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
                 virDomainEventStateQueue(data->driver->domainEventState, event);
         }
     }
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 }
 
 
@@ -1302,7 +1302,7 @@ virLXCProcessReconnectDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
     virLXCDriverPtr driver = opaque;
     virLXCDomainObjPrivatePtr priv;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     VIR_DEBUG("Reconnect id=%d pid=%d state=%d", vm->def->id, vm->pid, vm->state.state);
 
     priv = vm->privateData;
@@ -1345,7 +1345,7 @@ virLXCProcessReconnectDomain(void *payload, const void *name ATTRIBUTE_UNUSED, v
     }
 
 cleanup:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     return;
 
 error:
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 086bb13..8508f06 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1161,7 +1161,7 @@ virNWFilterDomainFWUpdateCB(void *payload,
     int i, err;
     bool skipIface;
 
-    virDomainObjLock(obj);
+    virObjectLock(obj);
 
     if (virDomainObjIsActive(obj)) {
         for (i = 0; i < vm->nnets; i++) {
@@ -1209,5 +1209,5 @@ virNWFilterDomainFWUpdateCB(void *payload,
         }
     }
 
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 }
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 09518d5..8db6d6b 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -669,7 +669,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
             goto cleanup;
         }
 
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
         dom = NULL;
     }
 
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index c6f814e..f4f93f5 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -264,7 +264,7 @@ openvzDomainGetHostname(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return hostname;
 
 error:
@@ -294,7 +294,7 @@ static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -326,7 +326,7 @@ static char *openvzGetOSType(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -352,7 +352,7 @@ static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -377,7 +377,7 @@ static virDomainPtr openvzDomainLookupByName(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -419,7 +419,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -450,7 +450,7 @@ openvzDomainGetState(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -472,7 +472,7 @@ static int openvzDomainIsActive(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -494,7 +494,7 @@ static int openvzDomainIsPersistent(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -524,7 +524,7 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -582,7 +582,7 @@ static int openvzDomainSuspend(virDomainPtr dom) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -620,7 +620,7 @@ static int openvzDomainResume(virDomainPtr dom) {
 
 cleanup:
   if (vm)
-      virDomainObjUnlock(vm);
+      virObjectUnlock(vm);
   return ret;
 }
 
@@ -665,7 +665,7 @@ openvzDomainShutdownFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -714,7 +714,7 @@ static int openvzDomainReboot(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1024,7 +1024,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
 cleanup:
     virDomainDefFree(vmdef);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     openvzDriverUnlock(driver);
     return dom;
 }
@@ -1109,7 +1109,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
 cleanup:
     virDomainDefFree(vmdef);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     openvzDriverUnlock(driver);
     return dom;
 }
@@ -1157,7 +1157,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1206,7 +1206,7 @@ openvzDomainUndefineFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     openvzDriverUnlock(driver);
     return ret;
 }
@@ -1244,7 +1244,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1281,7 +1281,7 @@ cleanup:
     VIR_FREE(value);
 
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1372,7 +1372,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1985,7 +1985,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2090,7 +2090,7 @@ cleanup:
     openvzDriverUnlock(driver);
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 6f33080..1383ff8 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -854,7 +854,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
     else
         dom->autostart = 0;
 
-    virDomainObjUnlock(dom);
+    virObjectUnlock(dom);
 
     return dom;
 
@@ -1137,7 +1137,7 @@ parallelsLookupDomainByID(virConnectPtr conn, int id)
 
   cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1166,7 +1166,7 @@ parallelsLookupDomainByUUID(virConnectPtr conn, const unsigned char *uuid)
 
   cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1193,7 +1193,7 @@ parallelsLookupDomainByName(virConnectPtr conn, const char *name)
 
   cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1222,7 +1222,7 @@ parallelsGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1246,7 +1246,7 @@ parallelsGetOSType(virDomainPtr domain)
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     parallelsDriverUnlock(privconn);
     return ret;
 }
@@ -1269,7 +1269,7 @@ parallelsDomainIsPersistent(virDomainPtr domain)
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     parallelsDriverUnlock(privconn);
     return ret;
 }
@@ -1297,7 +1297,7 @@ parallelsDomainGetState(virDomainPtr domain,
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1327,7 +1327,7 @@ parallelsDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1352,7 +1352,7 @@ parallelsDomainGetAutostart(virDomainPtr domain, int *autostart)
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1395,7 +1395,7 @@ parallelsDomainChangeState(virDomainPtr domain,
 
   cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
 
     return ret;
 }
@@ -2360,10 +2360,10 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
     }
 
     if (parallelsApplyChanges(conn, olddom, def) < 0) {
-        virDomainObjUnlock(olddom);
+        virObjectUnlock(olddom);
         goto cleanup;
     }
-    virDomainObjUnlock(olddom);
+    virObjectUnlock(olddom);
 
     if (!(dom = virDomainAssignDef(privconn->caps,
                                    &privconn->domains, def, false))) {
@@ -2381,7 +2381,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
   cleanup:
     virDomainDefFree(def);
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     parallelsDriverUnlock(privconn);
     return ret;
 }
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index f697537..c3bad21 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -125,10 +125,10 @@ To lock the driver
 
 To lock the virDomainObjPtr
 
-  virDomainObjLock()
+  virObjectLock()
     - Acquires the virDomainObjPtr lock
 
-  virDomainObjUnlock()
+  virObjectUnlock()
     - Releases the virDomainObjPtr lock
 
 
@@ -419,9 +419,9 @@ Design patterns
          ...monitor job progress...
          qemuDomainObjExitMonitorWithDriver(driver, obj);
 
-         virDomainObjUnlock(obj);
+         virObjectUnlock(obj);
          sleep(aWhile);
-         virDomainObjLock(obj);
+         virObjectLock(obj);
      }
 
      ...do final work...
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index db4a0bc..0997784 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -82,9 +82,8 @@ struct _qemuAgentMessage {
 
 
 struct _qemuAgent {
-    virObject object;
+    virObjectLockable parent;
 
-    virMutex lock; /* also used to protect fd */
     virCond notify;
 
     int fd;
@@ -121,7 +120,7 @@ static void qemuAgentDispose(void *obj);
 
 static int qemuAgentOnceInit(void)
 {
-    if (!(qemuAgentClass = virClassNew(virClassForObject(),
+    if (!(qemuAgentClass = virClassNew(virClassForObjectLockable(),
                                        "qemuAgent",
                                        sizeof(qemuAgent),
                                        qemuAgentDispose)))
@@ -153,17 +152,6 @@ qemuAgentEscapeNonPrintable(const char *text)
 }
 #endif
 
-void qemuAgentLock(qemuAgentPtr mon)
-{
-    virMutexLock(&mon->lock);
-}
-
-
-void qemuAgentUnlock(qemuAgentPtr mon)
-{
-    virMutexUnlock(&mon->lock);
-}
-
 
 static void qemuAgentDispose(void *obj)
 {
@@ -172,7 +160,6 @@ static void qemuAgentDispose(void *obj)
     if (mon->cb && mon->cb->destroy)
         (mon->cb->destroy)(mon, mon->vm);
     ignore_value(virCondDestroy(&mon->notify));
-    virMutexDestroy(&mon->lock);
     VIR_FREE(mon->buffer);
 }
 
@@ -592,7 +579,7 @@ qemuAgentIO(int watch, int fd, int events, void *opaque) {
 
     virObjectRef(mon);
     /* lock access to the monitor and protect fd */
-    qemuAgentLock(mon);
+    virObjectLock(mon);
 #if DEBUG_IO
     VIR_DEBUG("Agent %p I/O on watch %d fd %d events %d", mon, watch, fd, events);
 #endif
@@ -695,7 +682,7 @@ qemuAgentIO(int watch, int fd, int events, void *opaque) {
 
         /* Make sure anyone waiting wakes up now */
         virCondSignal(&mon->notify);
-        qemuAgentUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
         VIR_DEBUG("Triggering EOF callback");
         (eofNotify)(mon, vm);
@@ -706,12 +693,12 @@ qemuAgentIO(int watch, int fd, int events, void *opaque) {
 
         /* Make sure anyone waiting wakes up now */
         virCondSignal(&mon->notify);
-        qemuAgentUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
         VIR_DEBUG("Triggering error callback");
         (errorNotify)(mon, vm);
     } else {
-        qemuAgentUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
     }
 }
@@ -733,26 +720,18 @@ qemuAgentOpen(virDomainObjPtr vm,
     if (qemuAgentInitialize() < 0)
         return NULL;
 
-    if (!(mon = virObjectNew(qemuAgentClass)))
+    if (!(mon = virObjectLockableNew(qemuAgentClass)))
         return NULL;
 
-    if (virMutexInit(&mon->lock) < 0) {
-        virReportSystemError(errno, "%s",
-                             _("cannot initialize monitor mutex"));
-        VIR_FREE(mon);
-        return NULL;
-    }
+    mon->fd = -1;
     if (virCondInit(&mon->notify) < 0) {
         virReportSystemError(errno, "%s",
                              _("cannot initialize monitor condition"));
-        virMutexDestroy(&mon->lock);
-        VIR_FREE(mon);
+        virObjectUnref(mon);
         return NULL;
     }
-    mon->fd = -1;
     mon->vm = vm;
     mon->cb = cb;
-    qemuAgentLock(mon);
 
     switch (config->type) {
     case VIR_DOMAIN_CHR_TYPE_UNIX:
@@ -791,7 +770,6 @@ qemuAgentOpen(virDomainObjPtr vm,
     virObjectRef(mon);
 
     VIR_DEBUG("New mon %p fd =%d watch=%d", mon, mon->fd, mon->watch);
-    qemuAgentUnlock(mon);
 
     return mon;
 
@@ -802,7 +780,6 @@ cleanup:
      * so kill the callbacks now.
      */
     mon->cb = NULL;
-    qemuAgentUnlock(mon);
     qemuAgentClose(mon);
     return NULL;
 }
@@ -815,7 +792,7 @@ void qemuAgentClose(qemuAgentPtr mon)
 
     VIR_DEBUG("mon=%p", mon);
 
-    qemuAgentLock(mon);
+    virObjectLock(mon);
 
     if (mon->fd >= 0) {
         if (mon->watch)
@@ -829,7 +806,7 @@ void qemuAgentClose(qemuAgentPtr mon)
         mon->msg->finished = 1;
         virCondSignal(&mon->notify);
     }
-    qemuAgentUnlock(mon);
+    virObjectUnlock(mon);
 
     virObjectUnref(mon);
 }
@@ -883,8 +860,8 @@ static int qemuAgentSend(qemuAgentPtr mon,
     qemuAgentUpdateWatch(mon);
 
     while (!mon->msg->finished) {
-        if ((then && virCondWaitUntil(&mon->notify, &mon->lock, then) < 0) ||
-            (!then && virCondWait(&mon->notify, &mon->lock) < 0)) {
+        if ((then && virCondWaitUntil(&mon->notify, &mon->parent.lock, then) < 0) ||
+            (!then && virCondWait(&mon->notify, &mon->parent.lock) < 0)) {
             if (errno == ETIMEDOUT) {
                 virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
                                _("Guest agent not available for now"));
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index dad068b..ba04e61 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -47,9 +47,6 @@ qemuAgentPtr qemuAgentOpen(virDomainObjPtr vm,
                            virDomainChrSourceDefPtr config,
                            qemuAgentCallbacksPtr cb);
 
-void qemuAgentLock(qemuAgentPtr mon);
-void qemuAgentUnlock(qemuAgentPtr mon);
-
 void qemuAgentClose(qemuAgentPtr mon);
 
 typedef enum {
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 29b5066..c92321b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2380,7 +2380,7 @@ qemuCapsInitQMP(qemuCapsPtr caps,
         goto cleanup;
     }
 
-    qemuMonitorLock(mon);
+    virObjectLock(mon);
 
     if (qemuMonitorSetCapabilities(mon) < 0) {
         virErrorPtr err = virGetLastError();
@@ -2453,7 +2453,7 @@ qemuCapsInitQMP(qemuCapsPtr caps,
 
 cleanup:
     if (mon)
-        qemuMonitorUnlock(mon);
+        virObjectUnlock(mon);
     qemuMonitorClose(mon);
     virCommandAbort(cmd);
     virCommandFree(cmd);
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a138352..680e8fb 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -536,7 +536,7 @@ qemuDriverCloseCallbackRun(void *payload,
 
     dom = closeDef->cb(data->driver, dom, data->conn);
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
 
     virHashRemoveEntry(data->driver->closeCallbacks, uuidstr);
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 08774b9..1ae75e9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -786,12 +786,12 @@ retry:
     }
 
     while (!nested && !qemuDomainNestedJobAllowed(priv, job)) {
-        if (virCondWaitUntil(&priv->job.asyncCond, &obj->lock, then) < 0)
+        if (virCondWaitUntil(&priv->job.asyncCond, &obj->parent.lock, then) < 0)
             goto error;
     }
 
     while (priv->job.active) {
-        if (virCondWaitUntil(&priv->job.cond, &obj->lock, then) < 0)
+        if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0)
             goto error;
     }
 
@@ -818,9 +818,9 @@ retry:
     }
 
     if (driver_locked) {
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
         qemuDriverLock(driver);
-        virDomainObjLock(obj);
+        virObjectLock(obj);
     }
 
     if (qemuDomainTrackJob(job))
@@ -851,9 +851,9 @@ error:
                              "%s", _("cannot acquire job mutex"));
     priv->jobs_queued--;
     if (driver_locked) {
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
         qemuDriverLock(driver);
-        virDomainObjLock(obj);
+        virObjectLock(obj);
     }
     virObjectUnref(obj);
     return -1;
@@ -1004,10 +1004,10 @@ qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver,
                  " monitor without asking for a nested job is dangerous");
     }
 
-    qemuMonitorLock(priv->mon);
+    virObjectLock(priv->mon);
     virObjectRef(priv->mon);
     ignore_value(virTimeMillisNow(&priv->monStart));
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
     if (driver_locked)
         qemuDriverUnlock(driver);
 
@@ -1025,11 +1025,11 @@ qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver,
     hasRefs = virObjectUnref(priv->mon);
 
     if (hasRefs)
-        qemuMonitorUnlock(priv->mon);
+        virObjectUnlock(priv->mon);
 
     if (driver_locked)
         qemuDriverLock(driver);
-    virDomainObjLock(obj);
+    virObjectLock(obj);
 
     priv->monStart = 0;
     if (!hasRefs)
@@ -1127,10 +1127,10 @@ qemuDomainObjEnterAgentInternal(virQEMUDriverPtr driver,
 {
     qemuDomainObjPrivatePtr priv = obj->privateData;
 
-    qemuAgentLock(priv->agent);
+    virObjectLock(priv->agent);
     virObjectRef(priv->agent);
     ignore_value(virTimeMillisNow(&priv->agentStart));
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
     if (driver_locked)
         qemuDriverUnlock(driver);
 
@@ -1148,11 +1148,11 @@ qemuDomainObjExitAgentInternal(virQEMUDriverPtr driver,
     hasRefs = virObjectUnref(priv->agent);
 
     if (hasRefs)
-        qemuAgentUnlock(priv->agent);
+        virObjectUnlock(priv->agent);
 
     if (driver_locked)
         qemuDriverLock(driver);
-    virDomainObjLock(obj);
+    virObjectLock(obj);
 
     priv->agentStart = 0;
     if (!hasRefs)
@@ -1214,7 +1214,7 @@ void qemuDomainObjEnterRemoteWithDriver(virQEMUDriverPtr driver,
                                         virDomainObjPtr obj)
 {
     virObjectRef(obj);
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
     qemuDriverUnlock(driver);
 }
 
@@ -1222,7 +1222,7 @@ void qemuDomainObjExitRemoteWithDriver(virQEMUDriverPtr driver,
                                        virDomainObjPtr obj)
 {
     qemuDriverLock(driver);
-    virDomainObjLock(obj);
+    virObjectLock(obj);
     virObjectUnref(obj);
 }
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 06b0d28..ab1fd4c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -290,7 +290,7 @@ qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
     if (data->driver->autoStartBypassCache)
         flags |= VIR_DOMAIN_START_BYPASS_CACHE;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     virResetLastError();
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
@@ -316,7 +316,7 @@ qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 }
 
 
@@ -501,7 +501,7 @@ qemuDomainSnapshotLoad(void *payload,
                           VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
                           VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL);
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
         VIR_ERROR(_("Failed to allocate memory for snapshot directory for domain %s"),
                    vm->def->name);
@@ -591,7 +591,7 @@ cleanup:
     if (dir)
         closedir(dir);
     VIR_FREE(snapDir);
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 }
 
 
@@ -604,7 +604,7 @@ qemuDomainNetsRestart(void *payload,
     virDomainObjPtr vm = (virDomainObjPtr)payload;
     virDomainDefPtr def = vm->def;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDefPtr net = def->nets[i];
@@ -621,7 +621,7 @@ qemuDomainNetsRestart(void *payload,
         }
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 }
 
 
@@ -1459,7 +1459,7 @@ static virDomainPtr qemuDomainLookupByID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1486,7 +1486,7 @@ static virDomainPtr qemuDomainLookupByUUID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1511,7 +1511,7 @@ static virDomainPtr qemuDomainLookupByName(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1528,7 +1528,7 @@ static int qemuDomainIsActive(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1544,7 +1544,7 @@ static int qemuDomainIsPersistent(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1560,7 +1560,7 @@ static int qemuDomainIsUpdated(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1712,7 +1712,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event) {
         qemuDomainEventQueue(driver, event);
         if (event2)
@@ -1798,7 +1798,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 
     if (event)
         qemuDomainEventQueue(driver, event);
@@ -1862,7 +1862,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
@@ -1938,7 +1938,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2036,7 +2036,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2076,7 +2076,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2169,7 +2169,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
@@ -2194,7 +2194,7 @@ static char *qemuDomainGetOSType(virDomainPtr dom) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return type;
 }
 
@@ -2212,7 +2212,7 @@ qemuDomainGetMaxMemory(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2301,7 +2301,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2363,7 +2363,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -2432,7 +2432,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2509,7 +2509,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2532,7 +2532,7 @@ qemuDomainGetState(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2582,7 +2582,7 @@ qemuDomainGetControlInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3032,7 +3032,7 @@ cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3106,7 +3106,7 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 
     return ret;
@@ -3172,7 +3172,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     VIR_FREE(name);
 
@@ -3188,7 +3188,7 @@ qemuDomainManagedSaveLoad(void *payload,
     virQEMUDriverPtr driver = opaque;
     char *name;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     if (!(name = qemuDomainManagedSavePath(driver, vm)))
         goto cleanup;
@@ -3196,7 +3196,7 @@ qemuDomainManagedSaveLoad(void *payload,
     vm->hasManagedSave = virFileExists(name);
 
 cleanup:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     VIR_FREE(name);
 }
 
@@ -3212,7 +3212,7 @@ qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
         return -1;
 
     ret = vm->hasManagedSave;
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     return ret;
 }
 
@@ -3244,7 +3244,7 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     VIR_FREE(name);
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -3474,7 +3474,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
@@ -3564,7 +3564,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -3575,7 +3575,7 @@ static void processWatchdogEvent(void *data, void *opaque)
     virQEMUDriverPtr driver = opaque;
 
     qemuDriverLock(driver);
-    virDomainObjLock(wdEvent->vm);
+    virObjectLock(wdEvent->vm);
 
     switch (wdEvent->action) {
     case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
@@ -3633,7 +3633,7 @@ endjob:
     ignore_value(qemuDomainObjEndAsyncJob(driver, wdEvent->vm));
 
 unlock:
-    virDomainObjUnlock(wdEvent->vm);
+    virObjectUnlock(wdEvent->vm);
     virObjectUnref(wdEvent->vm);
     qemuDriverUnlock(driver);
     VIR_FREE(wdEvent);
@@ -3924,7 +3924,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4096,7 +4096,7 @@ cleanup:
     if (cgroup_dom)
         virCgroupFree(&cgroup_dom);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     virBitmapFree(pcpumap);
     return ret;
 }
@@ -4186,7 +4186,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4339,7 +4339,7 @@ cleanup:
     virBitmapFree(pcpumap);
 
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4406,7 +4406,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4495,7 +4495,7 @@ qemuDomainGetVcpus(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4526,7 +4526,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -4590,7 +4590,7 @@ static int qemuDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secl
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -4663,7 +4663,7 @@ static int qemuDomainGetSecurityLabelList(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -5032,7 +5032,7 @@ cleanup:
     VIR_FORCE_CLOSE(fd);
     virFileWrapperFdFree(wrapperFd);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -5267,7 +5267,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -5582,7 +5582,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -5687,7 +5687,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     virObjectUnref(caps);
@@ -5784,7 +5784,7 @@ qemuDomainUndefineFlags(virDomainPtr dom,
 cleanup:
     VIR_FREE(name);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
@@ -6570,7 +6570,7 @@ cleanup:
         virDomainDeviceDefFree(dev_copy);
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -6620,7 +6620,7 @@ static int qemuDomainGetAutostart(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -6687,7 +6687,7 @@ cleanup:
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7035,7 +7035,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7221,7 +7221,7 @@ cleanup:
     if (group)
         virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7390,7 +7390,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7550,7 +7550,7 @@ cleanup:
     if (group)
         virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7699,7 +7699,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -7812,7 +7812,7 @@ cleanup:
     VIR_FREE(nodeset);
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -8063,7 +8063,7 @@ cleanup:
     virDomainDefFree(vmdef);
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -8322,7 +8322,7 @@ out:
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -8417,7 +8417,7 @@ endjob:
 cleanup:
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -8488,7 +8488,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -8658,7 +8658,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -8698,7 +8698,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 #else
@@ -8882,7 +8882,7 @@ cleanup:
     virNetDevBandwidthFree(newBandwidth);
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -9004,7 +9004,7 @@ cleanup:
     if (group)
         virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -9055,7 +9055,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -9113,7 +9113,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
 cleanup:
     VIR_FORCE_CLOSE(fd);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -9198,7 +9198,7 @@ cleanup:
         unlink(tmp);
     VIR_FREE(tmp);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -9343,7 +9343,7 @@ cleanup:
     virStorageFileFreeMetadata(meta);
     VIR_FORCE_CLOSE(fd);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -9715,7 +9715,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return xml;
 
@@ -9950,7 +9950,7 @@ qemuDomainMigrateConfirm3(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -10187,7 +10187,7 @@ static int qemuDomainGetJobInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -10235,7 +10235,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -10283,7 +10283,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -10331,7 +10331,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -10355,7 +10355,7 @@ qemuDomainMigrateGetMaxSpeed(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -11599,7 +11599,7 @@ cleanup:
         } else if (snap) {
             virDomainSnapshotObjListRemove(vm->snapshots, snap);
         }
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     }
     virDomainSnapshotDefFree(def);
     VIR_FREE(xml);
@@ -11625,7 +11625,7 @@ static int qemuDomainSnapshotListNames(virDomainPtr domain, char **names,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11645,7 +11645,7 @@ static int qemuDomainSnapshotNum(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11666,7 +11666,7 @@ qemuDomainListAllSnapshots(virDomainPtr domain, virDomainSnapshotPtr **snaps,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11694,7 +11694,7 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11719,7 +11719,7 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11746,7 +11746,7 @@ qemuDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return n;
 }
 
@@ -11770,7 +11770,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotLookupByName(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return snapshot;
 }
 
@@ -11789,7 +11789,7 @@ static int qemuDomainHasCurrentSnapshot(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -11820,7 +11820,7 @@ qemuDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return parent;
 }
 
@@ -11845,7 +11845,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCurrent(virDomainPtr domain,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return snapshot;
 }
 
@@ -11871,7 +11871,7 @@ static char *qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return xml;
 }
 
@@ -11896,7 +11896,7 @@ qemuDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -11924,7 +11924,7 @@ qemuDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -12267,7 +12267,7 @@ cleanup:
             qemuDomainEventQueue(driver, event2);
     }
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 
     return ret;
@@ -12422,7 +12422,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -12473,7 +12473,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -12564,7 +12564,7 @@ cleanup:
     virObjectUnref(caps);
     virDomainChrSourceDefFree(monConfig);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     VIR_FREE(pidfile);
     return dom;
@@ -12646,7 +12646,7 @@ qemuDomainOpenConsole(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -12718,7 +12718,7 @@ qemuDomainOpenChannel(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -13051,13 +13051,13 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
                 if (ret <= 0)
                     break;
 
-                virDomainObjUnlock(vm);
+                virObjectUnlock(vm);
                 qemuDriverUnlock(driver);
 
                 nanosleep(&ts, NULL);
 
                 qemuDriverLock(driver);
-                virDomainObjLock(vm);
+                virObjectLock(vm);
 
                 if (!virDomainObjIsActive(vm)) {
                     virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -13078,7 +13078,7 @@ endjob:
 cleanup:
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
@@ -13290,7 +13290,7 @@ cleanup:
         virCgroupFree(&cgroup);
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -13468,7 +13468,7 @@ endjob:
 cleanup:
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -13536,7 +13536,7 @@ qemuDomainOpenGraphics(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -13708,7 +13708,7 @@ endjob:
 cleanup:
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -13844,7 +13844,7 @@ endjob:
 cleanup:
     VIR_FREE(device);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -13916,7 +13916,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     virHashFree(table);
     if (ret < 0) {
         for (i = 0; i < n; i++)
@@ -14010,7 +14010,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 no_memory:
     virReportOOMError();
@@ -14075,7 +14075,7 @@ qemuDomainGetMetadata(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -14346,7 +14346,7 @@ qemuDomainGetCPUStats(virDomainPtr domain,
 cleanup:
     virCgroupFree(&group);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     qemuDriverUnlock(driver);
     return ret;
 }
@@ -14448,7 +14448,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -14494,7 +14494,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -14578,7 +14578,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return result;
 }
 
@@ -14645,7 +14645,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index e235677..19bf369 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1267,13 +1267,13 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver, virDomainObjPtr vm,
             goto cleanup;
         }
 
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
         qemuDriverUnlock(driver);
 
         nanosleep(&ts, NULL);
 
         qemuDriverLock(driver);
-        virDomainObjLock(vm);
+        virObjectLock(vm);
     }
 
 cleanup:
@@ -1751,7 +1751,7 @@ cleanup:
     VIR_FORCE_CLOSE(dataFD[1]);
     if (vm) {
         if (ret >= 0 || vm->persistent)
-            virDomainObjUnlock(vm);
+            virObjectUnlock(vm);
         else
             qemuDomainRemoveInactive(driver, vm);
     }
@@ -3096,7 +3096,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     return ret;
@@ -3180,7 +3180,7 @@ endjob:
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
     return ret;
@@ -3493,7 +3493,7 @@ endjob:
 cleanup:
     if (vm) {
         VIR_FREE(priv->origname);
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     }
     if (event)
         qemuDomainEventQueue(driver, event);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index d6176c7..5d89ffd 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -48,9 +48,8 @@
 #define DEBUG_RAW_IO 0
 
 struct _qemuMonitor {
-    virObject object;
+    virObjectLockable parent;
 
-    virMutex lock; /* also used to protect fd */
     virCond notify;
 
     int fd;
@@ -86,7 +85,7 @@ static void qemuMonitorDispose(void *obj);
 
 static int qemuMonitorOnceInit(void)
 {
-    if (!(qemuMonitorClass = virClassNew(virClassForObject(),
+    if (!(qemuMonitorClass = virClassNew(virClassForObjectLockable(),
                                          "qemuMonitor",
                                          sizeof(qemuMonitor),
                                          qemuMonitorDispose)))
@@ -230,17 +229,6 @@ static char * qemuMonitorEscapeNonPrintable(const char *text)
 }
 #endif
 
-void qemuMonitorLock(qemuMonitorPtr mon)
-{
-    virMutexLock(&mon->lock);
-}
-
-void qemuMonitorUnlock(qemuMonitorPtr mon)
-{
-    virMutexUnlock(&mon->lock);
-}
-
-
 static void qemuMonitorDispose(void *obj)
 {
     qemuMonitorPtr mon = obj;
@@ -250,7 +238,6 @@ static void qemuMonitorDispose(void *obj)
         (mon->cb->destroy)(mon, mon->vm);
     if (virCondDestroy(&mon->notify) < 0)
     {}
-    virMutexDestroy(&mon->lock);
     VIR_FREE(mon->buffer);
 }
 
@@ -563,12 +550,12 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) {
     virObjectRef(mon);
 
     /* lock access to the monitor and protect fd */
-    qemuMonitorLock(mon);
+    virObjectLock(mon);
 #if DEBUG_IO
     VIR_DEBUG("Monitor %p I/O on watch %d fd %d events %d", mon, watch, fd, events);
 #endif
     if (mon->fd == -1 || mon->watch == 0) {
-        qemuMonitorUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
         return;
     }
@@ -666,7 +653,7 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) {
 
         /* Make sure anyone waiting wakes up now */
         virCondSignal(&mon->notify);
-        qemuMonitorUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
         VIR_DEBUG("Triggering EOF callback");
         (eofNotify)(mon, vm);
@@ -677,12 +664,12 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) {
 
         /* Make sure anyone waiting wakes up now */
         virCondSignal(&mon->notify);
-        qemuMonitorUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
         VIR_DEBUG("Triggering error callback");
         (errorNotify)(mon, vm);
     } else {
-        qemuMonitorUnlock(mon);
+        virObjectUnlock(mon);
         virObjectUnref(mon);
     }
 }
@@ -711,21 +698,14 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
     if (qemuMonitorInitialize() < 0)
         return NULL;
 
-    if (!(mon = virObjectNew(qemuMonitorClass)))
+    if (!(mon = virObjectLockableNew(qemuMonitorClass)))
         return NULL;
 
-    if (virMutexInit(&mon->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot initialize monitor mutex"));
-        VIR_FREE(mon);
-        return NULL;
-    }
+    mon->fd = -1;
     if (virCondInit(&mon->notify) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("cannot initialize monitor condition"));
-        virMutexDestroy(&mon->lock);
-        VIR_FREE(mon);
-        return NULL;
+        goto cleanup;
     }
     mon->fd = fd;
     mon->hasSendFD = hasSendFD;
@@ -734,7 +714,7 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
     if (json)
         mon->wait_greeting = 1;
     mon->cb = cb;
-    qemuMonitorLock(mon);
+    virObjectLock(mon);
 
     if (virSetCloseExec(mon->fd) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -763,8 +743,8 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
 
     PROBE(QEMU_MONITOR_NEW,
           "mon=%p refs=%d fd=%d",
-          mon, mon->object.refs, mon->fd);
-    qemuMonitorUnlock(mon);
+          mon, mon->parent.parent.refs, mon->fd);
+    virObjectUnlock(mon);
 
     return mon;
 
@@ -775,7 +755,7 @@ cleanup:
      * so kill the callbacks now.
      */
     mon->cb = NULL;
-    qemuMonitorUnlock(mon);
+    virObjectUnlock(mon);
     /* The caller owns 'fd' on failure */
     mon->fd = -1;
     if (mon->watch)
@@ -834,9 +814,9 @@ void qemuMonitorClose(qemuMonitorPtr mon)
     if (!mon)
         return;
 
-    qemuMonitorLock(mon);
+    virObjectLock(mon);
     PROBE(QEMU_MONITOR_CLOSE,
-          "mon=%p refs=%d", mon, mon->object.refs);
+          "mon=%p refs=%d", mon, mon->parent.parent.refs);
 
     if (mon->fd >= 0) {
         if (mon->watch) {
@@ -867,7 +847,7 @@ void qemuMonitorClose(qemuMonitorPtr mon)
         virCondSignal(&mon->notify);
     }
 
-    qemuMonitorUnlock(mon);
+    virObjectUnlock(mon);
     virObjectUnref(mon);
 }
 
@@ -905,7 +885,7 @@ int qemuMonitorSend(qemuMonitorPtr mon,
           mon, mon->msg->txBuffer, mon->msg->txFD);
 
     while (!mon->msg->finished) {
-        if (virCondWait(&mon->notify, &mon->lock) < 0) {
+        if (virCondWait(&mon->notify, &mon->parent.lock) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to wait on monitor condition"));
             goto cleanup;
@@ -960,10 +940,10 @@ cleanup:
 #define QEMU_MONITOR_CALLBACK(mon, ret, callback, ...)          \
     do {                                                        \
         virObjectRef(mon);                                      \
-        qemuMonitorUnlock(mon);                                 \
+        virObjectUnlock(mon);                                   \
         if ((mon)->cb && (mon)->cb->callback)                   \
             (ret) = ((mon)->cb->callback)(mon, __VA_ARGS__);    \
-        qemuMonitorLock(mon);                                   \
+        virObjectLock(mon);                                     \
         virObjectUnref(mon);                                    \
     } while (0)
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 00ce813..7953b82 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -160,9 +160,6 @@ void qemuMonitorClose(qemuMonitorPtr mon);
 
 int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
 
-void qemuMonitorLock(qemuMonitorPtr mon);
-void qemuMonitorUnlock(qemuMonitorPtr mon);
-
 int qemuMonitorSetLink(qemuMonitorPtr mon,
                        const char *name,
                        enum virDomainNetInterfaceLinkState state) ;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 938c17e..c8c898f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -130,13 +130,13 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
     VIR_DEBUG("Received EOF from agent on %p '%s'", vm, vm->def->name);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     priv = vm->privateData;
     if (priv->agent == agent)
         priv->agent = NULL;
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 
     qemuAgentClose(agent);
@@ -159,13 +159,13 @@ qemuProcessHandleAgentError(qemuAgentPtr agent ATTRIBUTE_UNUSED,
     VIR_DEBUG("Received error from agent on %p '%s'", vm, vm->def->name);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     priv = vm->privateData;
 
     priv->agentError = true;
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 }
 
@@ -228,7 +228,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
     virObjectRef(vm);
 
     ignore_value(virTimeMillisNow(&priv->agentStart));
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 
     agent = qemuAgentOpen(vm,
@@ -236,7 +236,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
                           &agentCallbacks);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     priv->agentStart = 0;
 
     if (virSecurityManagerClearSocketLabel(driver->securityManager,
@@ -287,7 +287,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     VIR_DEBUG("Received EOF on %p '%s'", vm, vm->def->name);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     priv = vm->privateData;
 
@@ -321,7 +321,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     }
 
 unlock:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
 cleanup:
     if (event)
@@ -346,14 +346,14 @@ qemuProcessHandleMonitorError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     VIR_DEBUG("Received error on %p '%s'", vm, vm->def->name);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     ((qemuDomainObjPrivatePtr) vm->privateData)->monError = true;
     event = virDomainEventControlErrorNewFromObj(vm);
     if (event)
         qemuDomainEventQueue(driver, event);
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 }
 
@@ -491,7 +491,7 @@ qemuProcessFindVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainDiskDefPtr disk;
     int ret = -1;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByPath(vm, path);
 
     if (!disk)
@@ -500,7 +500,7 @@ qemuProcessFindVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     ret = qemuProcessGetVolumeQcowPassphrase(conn, disk, secretRet, secretLen);
 
 cleanup:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     return ret;
 }
 
@@ -513,14 +513,14 @@ qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event;
     qemuDomainObjPrivatePtr priv;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     event = virDomainEventRebootNewFromObj(vm);
     priv = vm->privateData;
     if (priv->agent)
         qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_RESET);
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -550,7 +550,7 @@ qemuProcessFakeReboot(void *opaque)
     int ret = -1;
     VIR_DEBUG("vm=%p", vm);
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
 
@@ -599,7 +599,7 @@ cleanup:
                                          VIR_QEMU_PROCESS_KILL_FORCE));
         }
         if (virObjectUnref(vm))
-            virDomainObjUnlock(vm);
+            virObjectUnlock(vm);
     }
     if (event)
         qemuDomainEventQueue(driver, event);
@@ -641,7 +641,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
     VIR_DEBUG("vm=%p", vm);
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
 
     priv = vm->privateData;
     if (priv->gotShutdown) {
@@ -675,7 +675,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     qemuProcessShutdownOrReboot(driver, vm);
 
 unlock:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -694,7 +694,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
 
@@ -723,7 +723,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     }
 
 unlock:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -742,7 +742,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
 
@@ -778,7 +778,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     }
 
 unlock:
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -798,7 +798,7 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventRTCChangeNewFromObj(vm, offset);
 
     if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE)
@@ -807,7 +807,7 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
         VIR_WARN("unable to save domain status with RTC change");
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -828,7 +828,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr watchdogEvent = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     watchdogEvent = virDomainEventWatchdogNewFromObj(vm, action);
 
     if (action == VIR_DOMAIN_EVENT_WATCHDOG_PAUSE &&
@@ -872,7 +872,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     }
 
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 
     if (watchdogEvent || lifecycleEvent) {
         qemuDriverLock(driver);
@@ -902,7 +902,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     const char *devAlias;
     virDomainDiskDefPtr disk;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias);
 
     if (disk) {
@@ -934,7 +934,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
             VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
     }
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (ioErrorEvent || ioErrorEvent2 || lifecycleEvent) {
         qemuDriverLock(driver);
@@ -962,7 +962,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     const char *path;
     virDomainDiskDefPtr disk;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias);
 
     if (disk) {
@@ -984,7 +984,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             disk->mirroring = true;
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -1049,9 +1049,9 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             goto no_memory;
     }
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventGraphicsNewFromObj(vm, phase, localAddr, remoteAddr, authScheme, subject);
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -1102,7 +1102,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainDiskDefPtr disk;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByAlias(vm, devAlias);
 
     if (disk) {
@@ -1121,7 +1121,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         }
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -1140,7 +1140,7 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventPMWakeupNewFromObj(vm);
 
     /* Don't set domain status back to running if it wasn't paused
@@ -1162,7 +1162,7 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         }
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event || lifecycleEvent) {
         qemuDriverLock(driver);
@@ -1184,7 +1184,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventPMSuspendNewFromObj(vm);
 
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
@@ -1208,7 +1208,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SUSPEND);
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event || lifecycleEvent) {
         qemuDriverLock(driver);
@@ -1230,7 +1230,7 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventBalloonChangeNewFromObj(vm, actual);
 
     VIR_DEBUG("Updating balloon from %lld to %lld kb",
@@ -1240,7 +1240,7 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
         VIR_WARN("unable to save domain status with balloon change");
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event) {
         qemuDriverLock(driver);
@@ -1259,7 +1259,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     event = virDomainEventPMSuspendDiskNewFromObj(vm);
 
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
@@ -1283,7 +1283,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SUSPEND);
     }
 
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 
     if (event || lifecycleEvent) {
         qemuDriverLock(driver);
@@ -1338,7 +1338,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm)
     virObjectRef(vm);
 
     ignore_value(virTimeMillisNow(&priv->monStart));
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
     qemuDriverUnlock(driver);
 
     mon = qemuMonitorOpen(vm,
@@ -1347,7 +1347,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm)
                           &monitorCallbacks);
 
     qemuDriverLock(driver);
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     priv->monStart = 0;
 
     if (mon == NULL) {
@@ -3209,7 +3209,7 @@ qemuProcessReconnect(void *opaque)
     VIR_FREE(data);
 
     qemuDriverLock(driver);
-    virDomainObjLock(obj);
+    virObjectLock(obj);
 
 
     VIR_DEBUG("Reconnect monitor to %p '%s'", obj, obj->def->name);
@@ -3322,7 +3322,7 @@ endjob:
         obj = NULL;
 
     if (obj && virObjectUnref(obj))
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
 
     qemuDriverUnlock(driver);
 
@@ -3337,7 +3337,7 @@ error:
     if (obj) {
         if (!virDomainObjIsActive(obj)) {
             if (virObjectUnref(obj))
-                virDomainObjUnlock(obj);
+                virObjectUnlock(obj);
             qemuDriverUnlock(driver);
             return;
         }
@@ -3361,7 +3361,7 @@ error:
             if (!obj->persistent)
                 qemuDomainRemoveInactive(driver, obj);
             else
-                virDomainObjUnlock(obj);
+                virObjectUnlock(obj);
         }
     }
     qemuDriverUnlock(driver);
@@ -3410,7 +3410,7 @@ qemuProcessReconnectHelper(void *payload,
      * this early phase.
      */
 
-    virDomainObjLock(obj);
+    virObjectLock(obj);
 
     qemuDomainObjRestoreJob(obj, &data->oldjob);
 
@@ -3439,12 +3439,12 @@ qemuProcessReconnectHelper(void *payload,
             if (!obj->persistent)
                 qemuDomainRemoveInactive(src->driver, obj);
             else
-                virDomainObjUnlock(obj);
+                virObjectUnlock(obj);
         }
         goto error;
     }
 
-    virDomainObjUnlock(obj);
+    virObjectUnlock(obj);
 
     return;
 
@@ -4159,9 +4159,9 @@ qemuProcessKill(virQEMUDriverPtr driver,
 
     if (driver) {
         virObjectRef(vm);
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
         qemuDriverLock(driver);
-        virDomainObjLock(vm);
+        virObjectLock(vm);
         virObjectUnref(vm);
     }
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 3e082a4..15c1264 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -571,11 +571,11 @@ static int testOpenDefault(virConnectPtr conn) {
 
     domobj->persistent = 1;
     if (testDomainStartState(conn, domobj, VIR_DOMAIN_RUNNING_BOOTED) < 0) {
-        virDomainObjUnlock(domobj);
+        virObjectUnlock(domobj);
         goto error;
     }
 
-    virDomainObjUnlock(domobj);
+    virObjectUnlock(domobj);
 
     if (!(netdef = virNetworkDefParseString(defaultNetworkXML)))
         goto error;
@@ -916,11 +916,11 @@ static int testOpenFromFile(virConnectPtr conn,
 
         dom->persistent = 1;
         if (testDomainStartState(conn, dom, VIR_DOMAIN_RUNNING_BOOTED) < 0) {
-            virDomainObjUnlock(dom);
+            virObjectUnlock(dom);
             goto error;
         }
 
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     }
     VIR_FREE(domains);
 
@@ -1258,7 +1258,7 @@ static int testDomainIsActive(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1279,7 +1279,7 @@ static int testDomainIsPersistent(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1329,7 +1329,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
 
 cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     if (event)
         testDomainEventQueue(privconn, event);
     virDomainDefFree(def);
@@ -1360,7 +1360,7 @@ static virDomainPtr testLookupDomainByID(virConnectPtr conn,
 
 cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1386,7 +1386,7 @@ static virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
 
 cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1412,7 +1412,7 @@ static virDomainPtr testLookupDomainByName(virConnectPtr conn,
 
 cleanup:
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     return ret;
 }
 
@@ -1460,7 +1460,7 @@ static int testDestroyDomain(virDomainPtr domain)
     ret = 0;
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -1499,7 +1499,7 @@ static int testResumeDomain(virDomainPtr domain)
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event) {
         testDriverLock(privconn);
         testDomainEventQueue(privconn, event);
@@ -1541,7 +1541,7 @@ static int testPauseDomain(virDomainPtr domain)
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
 
     if (event) {
         testDriverLock(privconn);
@@ -1590,7 +1590,7 @@ static int testShutdownDomainFlags(virDomainPtr domain,
     ret = 0;
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -1666,7 +1666,7 @@ static int testRebootDomain(virDomainPtr domain,
     ret = 0;
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -1706,7 +1706,7 @@ static int testGetDomainInfo(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1737,7 +1737,7 @@ testDomainGetState(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -1838,7 +1838,7 @@ cleanup:
         unlink(path);
     }
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -1945,7 +1945,7 @@ cleanup:
     VIR_FREE(xml);
     VIR_FORCE_CLOSE(fd);
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -2015,7 +2015,7 @@ static int testDomainCoreDump(virDomainPtr domain,
 cleanup:
     VIR_FORCE_CLOSE(fd);
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -2048,7 +2048,7 @@ static unsigned long long testGetMaxMemory(virDomainPtr domain) {
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2075,7 +2075,7 @@ static int testSetMaxMemory(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2106,7 +2106,7 @@ static int testSetMemory(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2144,7 +2144,7 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2242,7 +2242,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2336,7 +2336,7 @@ static int testDomainGetVcpus(virDomainPtr domain,
     ret = maxinfo;
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2393,7 +2393,7 @@ static int testDomainPinVcpu(virDomainPtr domain,
     ret = 0;
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2424,7 +2424,7 @@ static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2493,7 +2493,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
 cleanup:
     virDomainDefFree(def);
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -2562,7 +2562,7 @@ static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -2607,7 +2607,7 @@ static int testDomainUndefineFlags(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     if (event)
         testDomainEventQueue(privconn, event);
     testDriverUnlock(privconn);
@@ -2641,7 +2641,7 @@ static int testDomainGetAutostart(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2668,7 +2668,7 @@ static int testDomainSetAutostart(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2720,7 +2720,7 @@ testDomainGetSchedulerParamsFlags(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2770,7 +2770,7 @@ testDomainSetSchedulerParamsFlags(virDomainPtr domain,
 
 cleanup:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2825,7 +2825,7 @@ static int testDomainBlockStats(virDomainPtr domain,
     ret = 0;
 error:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
@@ -2883,7 +2883,7 @@ static int testDomainInterfaceStats(virDomainPtr domain,
     ret = 0;
 error:
     if (privdom)
-        virDomainObjUnlock(privdom);
+        virObjectUnlock(privdom);
     return ret;
 }
 
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 448d292..c6fef69 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -185,7 +185,7 @@ umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaqu
     virDomainObjPtr vm = payload;
     const struct umlAutostartData *data = opaque;
 
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
         int ret;
@@ -205,7 +205,7 @@ umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaqu
                 umlDomainEventQueue(data->driver, event);
         }
     }
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 }
 
 static void
@@ -345,7 +345,7 @@ reread:
         if (e->mask & IN_DELETE) {
             VIR_DEBUG("Got inotify domain shutdown '%s'", name);
             if (!virDomainObjIsActive(dom)) {
-                virDomainObjUnlock(dom);
+                virObjectUnlock(dom);
                 continue;
             }
 
@@ -362,12 +362,12 @@ reread:
         } else if (e->mask & (IN_CREATE | IN_MODIFY)) {
             VIR_DEBUG("Got inotify domain startup '%s'", name);
             if (virDomainObjIsActive(dom)) {
-                virDomainObjUnlock(dom);
+                virObjectUnlock(dom);
                 continue;
             }
 
             if (umlReadPidFile(driver, dom) < 0) {
-                virDomainObjUnlock(dom);
+                virObjectUnlock(dom);
                 continue;
             }
 
@@ -409,7 +409,7 @@ reread:
             }
         }
         if (dom)
-            virDomainObjUnlock(dom);
+            virObjectUnlock(dom);
     }
 
 cleanup:
@@ -606,12 +606,12 @@ umlShutdownOneVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
     virDomainObjPtr dom = payload;
     struct uml_driver *driver = opaque;
 
-    virDomainObjLock(dom);
+    virObjectLock(dom);
     if (virDomainObjIsActive(dom)) {
         umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
         virDomainAuditStop(dom, "shutdown");
     }
-    virDomainObjUnlock(dom);
+    virObjectUnlock(dom);
 }
 
 /**
@@ -705,7 +705,7 @@ static void umlProcessAutoDestroyDom(void *payload,
         virDomainRemoveInactive(&data->driver->domains, dom);
 
     if (dom)
-        virDomainObjUnlock(dom);
+        virObjectUnlock(dom);
     if (event)
         umlDomainEventQueue(data->driver, event);
     virHashRemoveEntry(data->driver->autodestroy, uuidstr);
@@ -1320,7 +1320,7 @@ static virDomainPtr umlDomainLookupByID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1344,7 +1344,7 @@ static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1368,7 +1368,7 @@ static virDomainPtr umlDomainLookupByName(virConnectPtr conn,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -1390,7 +1390,7 @@ static int umlDomainIsActive(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1412,7 +1412,7 @@ static int umlDomainIsPersistent(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1433,7 +1433,7 @@ static int umlDomainIsUpdated(virDomainPtr dom)
 
 cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -1526,7 +1526,7 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         umlDomainEventQueue(driver, event);
     umlDriverUnlock(driver);
@@ -1564,7 +1564,7 @@ static int umlDomainShutdownFlags(virDomainPtr dom,
 cleanup:
     VIR_FREE(info);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1607,7 +1607,7 @@ umlDomainDestroyFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         umlDomainEventQueue(driver, event);
     umlDriverUnlock(driver);
@@ -1640,7 +1640,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return type;
 }
 
@@ -1668,7 +1668,7 @@ umlDomainGetMaxMemory(virDomainPtr dom)
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1701,7 +1701,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1740,7 +1740,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1779,7 +1779,7 @@ static int umlDomainGetInfo(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1811,7 +1811,7 @@ umlDomainGetState(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1841,7 +1841,7 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1897,7 +1897,7 @@ static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     if (event)
         umlDomainEventQueue(driver, event);
     umlDriverUnlock(driver);
@@ -1944,7 +1944,7 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) {
 cleanup:
     virDomainDefFree(def);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return dom;
 }
@@ -1986,7 +1986,7 @@ static int umlDomainUndefineFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
@@ -2099,7 +2099,7 @@ cleanup:
 
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
@@ -2211,7 +2211,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml) {
 cleanup:
     virDomainDeviceDefFree(dev);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
@@ -2254,7 +2254,7 @@ static int umlDomainGetAutostart(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
@@ -2320,7 +2320,7 @@ cleanup:
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
@@ -2388,7 +2388,7 @@ umlDomainBlockPeek(virDomainPtr dom,
 cleanup:
     VIR_FORCE_CLOSE(fd);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -2458,7 +2458,7 @@ umlDomainOpenConsole(virDomainPtr dom,
     ret = 0;
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     umlDriverUnlock(driver);
     return ret;
 }
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index fd9c473..e8a66de 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -198,7 +198,7 @@ vmwareLoadDomains(struct vmware_driver *driver)
                              VIR_DOMAIN_RUNNING_UNKNOWN);
         vm->persistent = 1;
 
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
 
         vmdef = NULL;
         vm = NULL;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 9c81df8..5c0e9ca 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -365,7 +365,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
     VIR_FREE(fileName);
     VIR_FREE(vmxPath);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     vmwareDriverUnlock(driver);
     return dom;
 }
@@ -410,7 +410,7 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
     ret = 0;
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     vmwareDriverUnlock(driver);
     return ret;
 }
@@ -466,7 +466,7 @@ vmwareDomainSuspend(virDomainPtr dom)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -515,7 +515,7 @@ vmwareDomainResume(virDomainPtr dom)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -563,7 +563,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -635,7 +635,7 @@ cleanup:
     VIR_FREE(vmx);
     VIR_FREE(vmxPath);
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     vmwareDriverUnlock(driver);
     return dom;
 }
@@ -673,7 +673,7 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
 
 cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     vmwareDriverUnlock(driver);
     return ret;
 }
@@ -726,7 +726,7 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     vmwareDriverUnlock(driver);
     return ret;
 }
@@ -759,7 +759,7 @@ vmwareDomainLookupByID(virConnectPtr conn, int id)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -784,7 +784,7 @@ vmwareGetOSType(virDomainPtr dom)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -811,7 +811,7 @@ vmwareDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -837,7 +837,7 @@ vmwareDomainLookupByName(virConnectPtr conn, const char *name)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return dom;
 }
 
@@ -859,7 +859,7 @@ vmwareDomainIsActive(virDomainPtr dom)
 
   cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -882,7 +882,7 @@ vmwareDomainIsPersistent(virDomainPtr dom)
 
   cleanup:
     if (obj)
-        virDomainObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -910,7 +910,7 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -948,9 +948,9 @@ static void vmwareDomainObjListUpdateDomain(void *payload, const void *name ATTR
 {
     struct vmware_driver *driver = data;
     virDomainObjPtr vm = payload;
-    virDomainObjLock(vm);
+    virObjectLock(vm);
     ignore_value(vmwareUpdateVMStatus(driver, vm));
-    virDomainObjUnlock(vm);
+    virObjectUnlock(vm);
 }
 
 static void
@@ -1045,7 +1045,7 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
@@ -1079,7 +1079,7 @@ vmwareDomainGetState(virDomainPtr dom,
 
   cleanup:
     if (vm)
-        virDomainObjUnlock(vm);
+        virObjectUnlock(vm);
     return ret;
 }
 
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 78eab29..eb9174d 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -364,7 +364,7 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test)
 
     virObjectUnref(test->server);
     if (test->mon) {
-        qemuMonitorUnlock(test->mon);
+        virObjectUnlock(test->mon);
         qemuMonitorClose(test->mon);
     }
 
@@ -496,7 +496,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
                                       json ? 1 : 0,
                                       &qemuCallbacks)))
         goto error;
-    qemuMonitorLock(test->mon);
+    virObjectLock(test->mon);
 
     if (virNetSocketAccept(test->server, &test->client) < 0)
         goto error;
-- 
1.8.0.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]