mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lock_manager: Allow disabling configFile for virLockManagerPluginNew
In some cases we might want to not load the lock driver config. Alter virLockManagerPluginNew() and the lock drivers to cope with this fact. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
385eb8399b
commit
35b5b244da
@ -124,6 +124,7 @@ struct _virLockManagerParam {
|
|||||||
/**
|
/**
|
||||||
* virLockDriverInit:
|
* virLockDriverInit:
|
||||||
* @version: the libvirt requested plugin ABI version
|
* @version: the libvirt requested plugin ABI version
|
||||||
|
* @configFile: path to config file
|
||||||
* @flags: the libvirt requested plugin optional extras
|
* @flags: the libvirt requested plugin optional extras
|
||||||
*
|
*
|
||||||
* Allow the plugin to validate the libvirt requested
|
* Allow the plugin to validate the libvirt requested
|
||||||
@ -131,6 +132,9 @@ struct _virLockManagerParam {
|
|||||||
* to block its use in versions of libvirtd which are
|
* to block its use in versions of libvirtd which are
|
||||||
* too old to support key features.
|
* too old to support key features.
|
||||||
*
|
*
|
||||||
|
* The @configFile variable points to config file that the driver
|
||||||
|
* should load. If NULL, no config file should be loaded.
|
||||||
|
*
|
||||||
* NB: A plugin may be loaded multiple times, for different
|
* NB: A plugin may be loaded multiple times, for different
|
||||||
* libvirt drivers (eg QEMU, LXC, UML)
|
* libvirt drivers (eg QEMU, LXC, UML)
|
||||||
*
|
*
|
||||||
|
@ -371,8 +371,10 @@ static int virLockManagerLockDaemonInit(unsigned int version,
|
|||||||
driver->requireLeaseForDisks = true;
|
driver->requireLeaseForDisks = true;
|
||||||
driver->autoDiskLease = true;
|
driver->autoDiskLease = true;
|
||||||
|
|
||||||
if (virLockManagerLockDaemonLoadConfig(configFile) < 0)
|
if (configFile &&
|
||||||
|
virLockManagerLockDaemonLoadConfig(configFile) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (driver->autoDiskLease) {
|
if (driver->autoDiskLease) {
|
||||||
if (driver->fileLockSpaceDir &&
|
if (driver->fileLockSpaceDir &&
|
||||||
|
@ -450,8 +450,10 @@ static int virLockManagerSanlockInit(unsigned int version,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virLockManagerSanlockLoadConfig(driver, configFile) < 0)
|
if (configFile &&
|
||||||
|
virLockManagerSanlockLoadConfig(driver, configFile) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (driver->autoDiskLease && !driver->hostID) {
|
if (driver->autoDiskLease && !driver->hostID) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -105,6 +105,8 @@ static void virLockManagerLogParams(size_t nparams,
|
|||||||
/**
|
/**
|
||||||
* virLockManagerPluginNew:
|
* virLockManagerPluginNew:
|
||||||
* @name: the name of the plugin
|
* @name: the name of the plugin
|
||||||
|
* @driverName: the hypervisor driver that loads the plugin
|
||||||
|
* @configDir: path to dir where config files are stored
|
||||||
* @flag: optional plugin flags
|
* @flag: optional plugin flags
|
||||||
*
|
*
|
||||||
* Attempt to load the plugin $(libdir)/libvirt/lock-driver/@name.so
|
* Attempt to load the plugin $(libdir)/libvirt/lock-driver/@name.so
|
||||||
@ -130,11 +132,13 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
char *configFile = NULL;
|
char *configFile = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("name=%s driverName=%s configDir=%s flags=0x%x",
|
VIR_DEBUG("name=%s driverName=%s configDir=%s flags=0x%x",
|
||||||
name, driverName, configDir, flags);
|
name, NULLSTR(driverName), NULLSTR(configDir), flags);
|
||||||
|
|
||||||
if (virAsprintf(&configFile, "%s/%s-%s.conf",
|
if (driverName && configDir &&
|
||||||
configDir, driverName, name) < 0)
|
virAsprintf(&configFile, "%s/%s-%s.conf",
|
||||||
|
configDir, driverName, name) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (STREQ(name, "nop")) {
|
if (STREQ(name, "nop")) {
|
||||||
driver = &virLockDriverNop;
|
driver = &virLockDriverNop;
|
||||||
|
Loading…
Reference in New Issue
Block a user