static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
const char *uri,
virDomainObjPtr dom,
- bool withResources)
+ bool withResources,
+ unsigned int flags)
{
virLockManagerPtr lock;
size_t i;
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
ARRAY_CARDINALITY(params),
params,
- 0)))
+ flags)))
goto error;
if (withResources) {
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)
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);
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);
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);
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)
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)
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)
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)
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,
* @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
*
size_t i;
int resCount = 0;
- virCheckFlags(0, -1);
+ virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
if (!driver) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
* 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;