mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add a 'nop' lock driver implementation.
To allow hypervisor drivers to assume that a lock driver impl will be guaranteed to exist, provide a 'nop' impl that is compiled into the library * src/Makefile.am: Add nop driver * src/locking/lock_driver_nop.c, src/locking/lock_driver_nop.h: Nop lock driver implementation * src/locking/lock_manager.c: Enable direct access of 'nop' driver, instead of dlopen()ing it.
This commit is contained in:
parent
6a943419c5
commit
db98851c24
@ -94,7 +94,9 @@ DRIVER_SOURCES = \
|
|||||||
fdstream.c fdstream.h \
|
fdstream.c fdstream.h \
|
||||||
$(NODE_INFO_SOURCES) \
|
$(NODE_INFO_SOURCES) \
|
||||||
libvirt.c libvirt_internal.h \
|
libvirt.c libvirt_internal.h \
|
||||||
locking/lock_manager.c locking/lock_manager.h
|
locking/lock_manager.c locking/lock_manager.h \
|
||||||
|
locking/lock_driver.h \
|
||||||
|
locking/lock_driver_nop.h locking/lock_driver_nop.c
|
||||||
|
|
||||||
|
|
||||||
# XML configuration format handling sources
|
# XML configuration format handling sources
|
||||||
|
115
src/locking/lock_driver_nop.c
Normal file
115
src/locking/lock_driver_nop.c
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* lock_driver_nop.c: A lock driver which locks nothing
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "lock_driver_nop.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int virLockManagerNopInit(unsigned int version,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("version=%u flags=%u", version, flags);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virLockManagerNopDeinit(void)
|
||||||
|
{
|
||||||
|
VIR_DEBUG(" ");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int virLockManagerNopNew(virLockManagerPtr lock ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int type ATTRIBUTE_UNUSED,
|
||||||
|
size_t nparams ATTRIBUTE_UNUSED,
|
||||||
|
virLockManagerParamPtr params ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virLockManagerNopAddResource(virLockManagerPtr lock ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int type ATTRIBUTE_UNUSED,
|
||||||
|
const char *name ATTRIBUTE_UNUSED,
|
||||||
|
size_t nparams ATTRIBUTE_UNUSED,
|
||||||
|
virLockManagerParamPtr params ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int virLockManagerNopAcquire(virLockManagerPtr lock ATTRIBUTE_UNUSED,
|
||||||
|
const char *state ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virLockManagerNopRelease(virLockManagerPtr lock ATTRIBUTE_UNUSED,
|
||||||
|
char **state,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
*state = NULL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virLockManagerNopInquire(virLockManagerPtr lock ATTRIBUTE_UNUSED,
|
||||||
|
char **state,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
|
||||||
|
*state = NULL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void virLockManagerNopFree(virLockManagerPtr lock ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virLockDriver virLockDriverNop =
|
||||||
|
{
|
||||||
|
.version = VIR_LOCK_MANAGER_VERSION,
|
||||||
|
.flags = 0,
|
||||||
|
|
||||||
|
.drvInit = virLockManagerNopInit,
|
||||||
|
.drvDeinit = virLockManagerNopDeinit,
|
||||||
|
|
||||||
|
.drvNew = virLockManagerNopNew,
|
||||||
|
.drvFree = virLockManagerNopFree,
|
||||||
|
|
||||||
|
.drvAddResource = virLockManagerNopAddResource,
|
||||||
|
|
||||||
|
.drvAcquire = virLockManagerNopAcquire,
|
||||||
|
.drvRelease = virLockManagerNopRelease,
|
||||||
|
|
||||||
|
.drvInquire = virLockManagerNopInquire,
|
||||||
|
};
|
30
src/locking/lock_driver_nop.h
Normal file
30
src/locking/lock_driver_nop.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* lock_driver_nop.h: A lock driver which locks nothing
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIR_LOCK_DRIVER_NOP_H__
|
||||||
|
# define __VIR_LOCK_DRIVER_NOP_H__
|
||||||
|
|
||||||
|
# include "lock_driver.h"
|
||||||
|
|
||||||
|
extern virLockDriver virLockDriverNop;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __VIR_LOCK_DRIVER_NOP_H__ */
|
@ -22,6 +22,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "lock_manager.h"
|
#include "lock_manager.h"
|
||||||
|
#include "lock_driver_nop.h"
|
||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -123,6 +124,9 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
const char *moddir = getenv("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
|
const char *moddir = getenv("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
|
||||||
char *modfile = NULL;
|
char *modfile = NULL;
|
||||||
|
|
||||||
|
if (STREQ(name, "nop")) {
|
||||||
|
driver = &virLockDriverNop;
|
||||||
|
} else {
|
||||||
if (moddir == NULL)
|
if (moddir == NULL)
|
||||||
moddir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR;
|
moddir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR;
|
||||||
|
|
||||||
@ -153,6 +157,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
_("Missing plugin initialization symbol 'virLockDriverImpl'"));
|
_("Missing plugin initialization symbol 'virLockDriverImpl'"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, flags) < 0) {
|
if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, flags) < 0) {
|
||||||
virLockError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virLockError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user