From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> To allow a virLockManagerPtr to be created directly from a driver table struct, replace the virLockManagerPluginPtr parameter with a virLockDriverPtr parameter. * src/locking/domain_lock.c, src/locking/lock_manager.c, src/locking/lock_manager.h: Replace plugin param with a driver in virLockManagerNew --- src/locking/domain_lock.c | 2 +- src/locking/lock_manager.c | 25 ++++++++++++++++--------- src/locking/lock_manager.h | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c index de1937c..0ce74ff 100644 --- a/src/locking/domain_lock.c +++ b/src/locking/domain_lock.c @@ -124,7 +124,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin, memcpy(params[0].value.uuid, dom->def->uuid, VIR_UUID_BUFLEN); - if (!(lock = virLockManagerNew(plugin, + if (!(lock = virLockManagerNew(virLockManagerPluginGetDriver(plugin), VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN, ARRAY_CARDINALITY(params), params, diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index 4ee7f44..f257707 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -43,8 +43,8 @@ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define CHECK_PLUGIN(field, errret) \ - if (!plugin->driver->field) { \ +#define CHECK_DRIVER(field, errret) \ + if (!driver->field) { \ virLockError(VIR_ERR_INTERNAL_ERROR, \ _("Missing '%s' field in lock manager driver"), \ #field); \ @@ -268,9 +268,16 @@ bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin) } +virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin) +{ + VIR_DEBUG("plugin=%p", plugin); + + return plugin->driver; +} + /** * virLockManagerNew: - * @plugin: the plugin implementation to use + * @driver: the lock manager implementation to use * @type: the type of process to be supervised * @flags: optional flags, currently unused * @@ -279,27 +286,27 @@ bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin) * * Returns a new lock manager context */ -virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin, +virLockManagerPtr virLockManagerNew(virLockDriverPtr driver, unsigned int type, size_t nparams, virLockManagerParamPtr params, unsigned int flags) { virLockManagerPtr lock; - VIR_DEBUG("plugin=%p type=%u nparams=%zu params=%p flags=%u", - plugin, type, nparams, params, flags); + VIR_DEBUG("driver=%p type=%u nparams=%zu params=%p flags=%u", + driver, type, nparams, params, flags); virLockManagerLogParams(nparams, params); - CHECK_PLUGIN(drvNew, NULL); + CHECK_DRIVER(drvNew, NULL); if (VIR_ALLOC(lock) < 0) { virReportOOMError(); return NULL; } - lock->driver = plugin->driver; + lock->driver = driver; - if (plugin->driver->drvNew(lock, type, nparams, params, flags) < 0) { + if (driver->drvNew(lock, type, nparams, params, flags) < 0) { VIR_FREE(lock); return NULL; } diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h index 0fb3bb7..5afb0d0 100644 --- a/src/locking/lock_manager.h +++ b/src/locking/lock_manager.h @@ -37,8 +37,9 @@ void virLockManagerPluginUnref(virLockManagerPluginPtr plugin); const char *virLockManagerPluginGetName(virLockManagerPluginPtr plugin); bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin); +virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin); -virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin, +virLockManagerPtr virLockManagerNew(virLockDriverPtr driver, unsigned int type, size_t nparams, virLockManagerParamPtr params, -- 1.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list