mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-25 04:42:20 +00:00
lxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal
Use the recently added job functions in lxcDomainLxcOpenNamespace, lxcDomainSendProcessSignal. Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
This commit is contained in:
parent
750b83137b
commit
6ce89dcae0
@ -3642,6 +3642,7 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
|
|||||||
unsigned int signum,
|
unsigned int signum,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virLXCDriverPtr driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virLXCDomainObjPrivatePtr priv;
|
virLXCDomainObjPrivatePtr priv;
|
||||||
pid_t victim;
|
pid_t victim;
|
||||||
@ -3664,10 +3665,13 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
|
|||||||
if (virDomainSendProcessSignalEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSendProcessSignalEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("domain is not running"));
|
"%s", _("domain is not running"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3680,13 +3684,13 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
|
|||||||
if (pid_value != 1) {
|
if (pid_value != 1) {
|
||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||||
_("Only the init process may be killed"));
|
_("Only the init process may be killed"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->initpid) {
|
if (!priv->initpid) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Init pid is not yet available"));
|
_("Init pid is not yet available"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
victim = priv->initpid;
|
victim = priv->initpid;
|
||||||
|
|
||||||
@ -3697,11 +3701,15 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to send %d signal to process %d"),
|
_("Unable to send %d signal to process %d"),
|
||||||
signum, victim);
|
signum, victim);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!virLXCDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
@ -5438,6 +5446,7 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr dom,
|
|||||||
int **fdlist,
|
int **fdlist,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virLXCDriverPtr driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virLXCDomainObjPrivatePtr priv;
|
virLXCDomainObjPrivatePtr priv;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -5454,22 +5463,30 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr dom,
|
|||||||
if (virDomainLxcOpenNamespaceEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainLxcOpenNamespaceEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("Domain is not running"));
|
"%s", _("Domain is not running"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->initpid) {
|
if (!priv->initpid) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Init pid is not yet available"));
|
_("Init pid is not yet available"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virProcessGetNamespaces(priv->initpid, &nfds, fdlist) < 0)
|
if (virProcessGetNamespaces(priv->initpid, &nfds, fdlist) < 0)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
ret = nfds;
|
ret = nfds;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!virLXCDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user