sanlock: Don't spam logs with "target pid not found"

Commit v1.2.4-52-gda879e5 fixed issues with domains started before
sanlock driver was enabled by checking whether a running domain is
registered with sanlock and if it's not, sanlock driver is basically
ignored for the domain.

However, it was checking this even for domain which has just been
started and no sanlock_* API was called for them yet. This results in

    cmd 9 target pid 2135544 not found

error messages to appear in sanlock.log whenever we start a new domain.

This patch avoids this useless check for freshly started domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2015-03-06 15:58:55 +01:00
parent 6beb75d96d
commit 54972be843
5 changed files with 31 additions and 16 deletions

View File

@ -104,7 +104,8 @@ static int virDomainLockManagerAddImage(virLockManagerPtr lock,
static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
const char *uri,
virDomainObjPtr dom,
bool withResources)
bool withResources,
unsigned int flags)
{
virLockManagerPtr lock;
size_t i;
@ -138,7 +139,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
ARRAY_CARDINALITY(params),
params,
0)))
flags)))
goto error;
if (withResources) {
@ -177,7 +178,8 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p paused=%d fd=%p",
plugin, dom, paused, fd);
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true)))
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true,
VIR_LOCK_MANAGER_NEW_STARTED)))
return -1;
if (paused)
@ -201,7 +203,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%p",
plugin, dom, state);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true)))
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true, 0)))
return -1;
ret = virLockManagerRelease(lock, state, 0);
@ -221,7 +223,7 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%s",
plugin, dom, NULLSTR(state));
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true)))
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true, 0)))
return -1;
ret = virLockManagerAcquire(lock, state, 0, dom->def->onLockFailure, NULL);
@ -240,7 +242,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%p",
plugin, dom, state);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true)))
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true, 0)))
return -1;
ret = virLockManagerInquire(lock, state, 0);
@ -260,7 +262,7 @@ int virDomainLockImageAttach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p src=%p", plugin, dom, src);
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false)))
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false, 0)))
return -1;
if (virDomainLockManagerAddImage(lock, src) < 0)
@ -297,7 +299,7 @@ int virDomainLockImageDetach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p src=%p", plugin, dom, src);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false)))
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false, 0)))
return -1;
if (virDomainLockManagerAddImage(lock, src) < 0)
@ -334,7 +336,7 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p lease=%p",
plugin, dom, lease);
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false)))
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false, 0)))
return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0)
@ -362,7 +364,7 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p lease=%p",
plugin, dom, lease);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false)))
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false, 0)))
return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0)

View File

@ -65,6 +65,11 @@ typedef enum {
VIR_LOCK_MANAGER_ACQUIRE_RESTRICT = (1 << 1),
} virLockManagerAcquireFlags;
typedef enum {
/* virLockManagerNew called for a freshly started domain */
VIR_LOCK_MANAGER_NEW_STARTED = (1 << 0),
} virLockManagerNewFlags;
enum {
VIR_LOCK_MANAGER_PARAM_TYPE_STRING,
VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING,
@ -142,13 +147,18 @@ typedef int (*virLockDriverDeinit)(void);
* @type: the type of process to be supervised
* @nparams: number of metadata parameters
* @params: extra metadata parameters
* @flags: optional flags, currently unused
* @flags: bitwise-OR of virLockManagerNewFlags
*
* Initialize a new context to supervise a process, usually
* a virtual machine. The lock driver implementation can use
* the <code>privateData</code> field of <code>man</code>
* to store a pointer to any driver specific state.
*
* If @flags contains VIR_LOCK_MANAGER_NEW_STARTED, this API is called for
* a domain that has just been started and may therefore skip some actions.
* Specifically, checking whether the domain is registered with a lock
* daemon is useless in this case.
*
* A process of VIR_LOCK_MANAGER_START_DOMAIN will be
* given the following parameters
*

View File

@ -439,7 +439,7 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
virLockManagerLockDaemonPrivatePtr priv;
size_t i;
virCheckFlags(0, -1);
virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
if (VIR_ALLOC(priv) < 0)
return -1;

View File

@ -455,7 +455,7 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
size_t i;
int resCount = 0;
virCheckFlags(0, -1);
virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
if (!driver) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -497,8 +497,11 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
* if it returns any other error (rv < 0), then we cannot fail due
* to back-compat. So this whole call is non-fatal, because it's
* called from all over the place (it will usually fail). It merely
* updates privateData. */
if (sanlock_inquire(-1, priv->vm_pid, 0, &resCount, NULL) >= 0)
* updates privateData.
* If the process has just been started, we are pretty sure it is not
* registered. */
if (!(flags & VIR_LOCK_MANAGER_NEW_STARTED) &&
sanlock_inquire(-1, priv->vm_pid, 0, &resCount, NULL) >= 0)
priv->registered = true;
lock->privateData = priv;

View File

@ -287,7 +287,7 @@ virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin)
* virLockManagerNew:
* @driver: the lock manager implementation to use
* @type: the type of process to be supervised
* @flags: optional flags, currently unused
* @flags: bitwise-OR of virLockManagerNewFlags
*
* Create a new context to supervise a process, usually
* a virtual machine.