mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
Change function signature for creating new lock manager instances
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 Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
5f2f8d4180
commit
4ee8672146
@ -124,7 +124,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
|
|||||||
|
|
||||||
memcpy(params[0].value.uuid, dom->def->uuid, VIR_UUID_BUFLEN);
|
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,
|
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
|
||||||
ARRAY_CARDINALITY(params),
|
ARRAY_CARDINALITY(params),
|
||||||
params,
|
params,
|
||||||
|
@ -39,11 +39,11 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LOCKING
|
#define VIR_FROM_THIS VIR_FROM_LOCKING
|
||||||
|
|
||||||
#define CHECK_PLUGIN(field, errret) \
|
#define CHECK_DRIVER(field, errret) \
|
||||||
if (!plugin->driver->field) { \
|
if (!driver->field) { \
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||||
_("Missing '%s' field in lock manager driver"), \
|
_("Missing '%s' field in lock manager driver"), \
|
||||||
#field); \
|
#field); \
|
||||||
return errret; \
|
return errret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,9 +265,16 @@ bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("plugin=%p", plugin);
|
||||||
|
|
||||||
|
return plugin->driver;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virLockManagerNew:
|
* virLockManagerNew:
|
||||||
* @plugin: the plugin implementation to use
|
* @driver: the lock manager implementation to use
|
||||||
* @type: the type of process to be supervised
|
* @type: the type of process to be supervised
|
||||||
* @flags: optional flags, currently unused
|
* @flags: optional flags, currently unused
|
||||||
*
|
*
|
||||||
@ -276,27 +283,27 @@ bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin)
|
|||||||
*
|
*
|
||||||
* Returns a new lock manager context
|
* Returns a new lock manager context
|
||||||
*/
|
*/
|
||||||
virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin,
|
virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
|
||||||
unsigned int type,
|
unsigned int type,
|
||||||
size_t nparams,
|
size_t nparams,
|
||||||
virLockManagerParamPtr params,
|
virLockManagerParamPtr params,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virLockManagerPtr lock;
|
virLockManagerPtr lock;
|
||||||
VIR_DEBUG("plugin=%p type=%u nparams=%zu params=%p flags=%x",
|
VIR_DEBUG("driver=%p type=%u nparams=%zu params=%p flags=%x",
|
||||||
plugin, type, nparams, params, flags);
|
driver, type, nparams, params, flags);
|
||||||
virLockManagerLogParams(nparams, params);
|
virLockManagerLogParams(nparams, params);
|
||||||
|
|
||||||
CHECK_PLUGIN(drvNew, NULL);
|
CHECK_DRIVER(drvNew, NULL);
|
||||||
|
|
||||||
if (VIR_ALLOC(lock) < 0) {
|
if (VIR_ALLOC(lock) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
return NULL;
|
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);
|
VIR_FREE(lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,9 @@ void virLockManagerPluginUnref(virLockManagerPluginPtr plugin);
|
|||||||
const char *virLockManagerPluginGetName(virLockManagerPluginPtr plugin);
|
const char *virLockManagerPluginGetName(virLockManagerPluginPtr plugin);
|
||||||
bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin);
|
bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin);
|
||||||
|
|
||||||
|
virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin);
|
||||||
|
|
||||||
virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin,
|
virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
|
||||||
unsigned int type,
|
unsigned int type,
|
||||||
size_t nparams,
|
size_t nparams,
|
||||||
virLockManagerParamPtr params,
|
virLockManagerParamPtr params,
|
||||||
|
Loading…
Reference in New Issue
Block a user