locking: relax PID requirement

Some hypervisors like Xen do not have PIDs associated with domains.
Relax the requirement for PID != 0 in the locking code so it can
be used by hypervisors that do not represent domains as a process
running on the host.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
Jim Fehlig 2015-04-16 11:32:42 -06:00
parent fa19aca168
commit ee3eddb332
3 changed files with 11 additions and 14 deletions

View File

@ -678,7 +678,7 @@ virLockDaemonClientFree(void *opaque)
signum = SIGKILL; signum = SIGKILL;
else else
signum = 0; signum = 0;
if (virProcessKill(priv->clientPid, signum) < 0) { if (priv->clientPid != 0 && virProcessKill(priv->clientPid, signum) < 0) {
if (errno == ESRCH) if (errno == ESRCH)
break; break;

View File

@ -62,7 +62,7 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNU
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
@ -120,7 +120,7 @@ virLockSpaceProtocolDispatchCreateResource(virNetServerPtr server ATTRIBUTE_UNUS
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
@ -169,7 +169,7 @@ virLockSpaceProtocolDispatchDeleteResource(virNetServerPtr server ATTRIBUTE_UNUS
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
@ -218,7 +218,7 @@ virLockSpaceProtocolDispatchNew(virNetServerPtr server ATTRIBUTE_UNUSED,
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
@ -273,9 +273,9 @@ virLockSpaceProtocolDispatchRegister(virNetServerPtr server ATTRIBUTE_UNUSED,
goto cleanup; goto cleanup;
} }
if (priv->ownerPid) { if (!args->owner.id) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have already been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
} }
@ -320,7 +320,7 @@ virLockSpaceProtocolDispatchReleaseResource(virNetServerPtr server ATTRIBUTE_UNU
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;
@ -370,7 +370,7 @@ virLockSpaceProtocolDispatchRestrict(virNetServerPtr server ATTRIBUTE_UNUSED,
goto cleanup; goto cleanup;
} }
if (!priv->ownerPid) { if (!priv->ownerId) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("lock owner details have not been registered")); _("lock owner details have not been registered"));
goto cleanup; goto cleanup;

View File

@ -466,11 +466,8 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
_("Missing ID parameter for domain object")); _("Missing ID parameter for domain object"));
return -1; return -1;
} }
if (priv->pid == 0) { if (priv->pid == 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", VIR_DEBUG("Missing PID parameter for domain object");
_("Missing PID parameter for domain object"));
return -1;
}
if (!priv->name) { if (!priv->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing name parameter for domain object")); _("Missing name parameter for domain object"));