提交 54972be8 编写于 作者: J Jiri Denemark

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

Commit v1.2.4-52-gda879e59 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: NJiri Denemark <jdenemar@redhat.com>
上级 6beb75d9
...@@ -104,7 +104,8 @@ static int virDomainLockManagerAddImage(virLockManagerPtr lock, ...@@ -104,7 +104,8 @@ static int virDomainLockManagerAddImage(virLockManagerPtr lock,
static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin, static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
const char *uri, const char *uri,
virDomainObjPtr dom, virDomainObjPtr dom,
bool withResources) bool withResources,
unsigned int flags)
{ {
virLockManagerPtr lock; virLockManagerPtr lock;
size_t i; size_t i;
...@@ -138,7 +139,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin, ...@@ -138,7 +139,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN, VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
ARRAY_CARDINALITY(params), ARRAY_CARDINALITY(params),
params, params,
0))) flags)))
goto error; goto error;
if (withResources) { if (withResources) {
...@@ -177,7 +178,8 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin, ...@@ -177,7 +178,8 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p paused=%d fd=%p", VIR_DEBUG("plugin=%p dom=%p paused=%d fd=%p",
plugin, dom, paused, fd); 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; return -1;
if (paused) if (paused)
...@@ -201,7 +203,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin, ...@@ -201,7 +203,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%p", VIR_DEBUG("plugin=%p dom=%p state=%p",
plugin, dom, state); plugin, dom, state);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true))) if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true, 0)))
return -1; return -1;
ret = virLockManagerRelease(lock, state, 0); ret = virLockManagerRelease(lock, state, 0);
...@@ -221,7 +223,7 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin, ...@@ -221,7 +223,7 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%s", VIR_DEBUG("plugin=%p dom=%p state=%s",
plugin, dom, NULLSTR(state)); plugin, dom, NULLSTR(state));
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true))) if (!(lock = virDomainLockManagerNew(plugin, uri, dom, true, 0)))
return -1; return -1;
ret = virLockManagerAcquire(lock, state, 0, dom->def->onLockFailure, NULL); ret = virLockManagerAcquire(lock, state, 0, dom->def->onLockFailure, NULL);
...@@ -240,7 +242,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin, ...@@ -240,7 +242,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p state=%p", VIR_DEBUG("plugin=%p dom=%p state=%p",
plugin, dom, state); plugin, dom, state);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true))) if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true, 0)))
return -1; return -1;
ret = virLockManagerInquire(lock, state, 0); ret = virLockManagerInquire(lock, state, 0);
...@@ -260,7 +262,7 @@ int virDomainLockImageAttach(virLockManagerPluginPtr plugin, ...@@ -260,7 +262,7 @@ int virDomainLockImageAttach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p src=%p", plugin, dom, src); 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; return -1;
if (virDomainLockManagerAddImage(lock, src) < 0) if (virDomainLockManagerAddImage(lock, src) < 0)
...@@ -297,7 +299,7 @@ int virDomainLockImageDetach(virLockManagerPluginPtr plugin, ...@@ -297,7 +299,7 @@ int virDomainLockImageDetach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p src=%p", plugin, dom, src); 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; return -1;
if (virDomainLockManagerAddImage(lock, src) < 0) if (virDomainLockManagerAddImage(lock, src) < 0)
...@@ -334,7 +336,7 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin, ...@@ -334,7 +336,7 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p lease=%p", VIR_DEBUG("plugin=%p dom=%p lease=%p",
plugin, dom, lease); plugin, dom, lease);
if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false))) if (!(lock = virDomainLockManagerNew(plugin, uri, dom, false, 0)))
return -1; return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0) if (virDomainLockManagerAddLease(lock, lease) < 0)
...@@ -362,7 +364,7 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin, ...@@ -362,7 +364,7 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
VIR_DEBUG("plugin=%p dom=%p lease=%p", VIR_DEBUG("plugin=%p dom=%p lease=%p",
plugin, dom, lease); plugin, dom, lease);
if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false))) if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false, 0)))
return -1; return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0) if (virDomainLockManagerAddLease(lock, lease) < 0)
......
...@@ -65,6 +65,11 @@ typedef enum { ...@@ -65,6 +65,11 @@ typedef enum {
VIR_LOCK_MANAGER_ACQUIRE_RESTRICT = (1 << 1), VIR_LOCK_MANAGER_ACQUIRE_RESTRICT = (1 << 1),
} virLockManagerAcquireFlags; } virLockManagerAcquireFlags;
typedef enum {
/* virLockManagerNew called for a freshly started domain */
VIR_LOCK_MANAGER_NEW_STARTED = (1 << 0),
} virLockManagerNewFlags;
enum { enum {
VIR_LOCK_MANAGER_PARAM_TYPE_STRING, VIR_LOCK_MANAGER_PARAM_TYPE_STRING,
VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING, VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING,
...@@ -142,13 +147,18 @@ typedef int (*virLockDriverDeinit)(void); ...@@ -142,13 +147,18 @@ typedef int (*virLockDriverDeinit)(void);
* @type: the type of process to be supervised * @type: the type of process to be supervised
* @nparams: number of metadata parameters * @nparams: number of metadata parameters
* @params: extra 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 * Initialize a new context to supervise a process, usually
* a virtual machine. The lock driver implementation can use * a virtual machine. The lock driver implementation can use
* the <code>privateData</code> field of <code>man</code> * the <code>privateData</code> field of <code>man</code>
* to store a pointer to any driver specific state. * 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 * A process of VIR_LOCK_MANAGER_START_DOMAIN will be
* given the following parameters * given the following parameters
* *
......
...@@ -439,7 +439,7 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock, ...@@ -439,7 +439,7 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
virLockManagerLockDaemonPrivatePtr priv; virLockManagerLockDaemonPrivatePtr priv;
size_t i; size_t i;
virCheckFlags(0, -1); virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
if (VIR_ALLOC(priv) < 0) if (VIR_ALLOC(priv) < 0)
return -1; return -1;
......
...@@ -455,7 +455,7 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock, ...@@ -455,7 +455,7 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
size_t i; size_t i;
int resCount = 0; int resCount = 0;
virCheckFlags(0, -1); virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
if (!driver) { if (!driver) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -497,8 +497,11 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock, ...@@ -497,8 +497,11 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
* if it returns any other error (rv < 0), then we cannot fail due * 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 * 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 * called from all over the place (it will usually fail). It merely
* updates privateData. */ * updates privateData.
if (sanlock_inquire(-1, priv->vm_pid, 0, &resCount, NULL) >= 0) * 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; priv->registered = true;
lock->privateData = priv; lock->privateData = priv;
......
...@@ -287,7 +287,7 @@ virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin) ...@@ -287,7 +287,7 @@ virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin)
* virLockManagerNew: * virLockManagerNew:
* @driver: the lock manager 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: bitwise-OR of virLockManagerNewFlags
* *
* Create a new context to supervise a process, usually * Create a new context to supervise a process, usually
* a virtual machine. * a virtual machine.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册