提交 6ce89dca 编写于 作者: K Katerina Koukiou 提交者: Michal Privoznik

lxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal

Use the recently added job functions in lxcDomainLxcOpenNamespace,
lxcDomainSendProcessSignal.
Signed-off-by: NKaterina Koukiou <k.koukiou@gmail.com>
上级 750b8313
...@@ -3642,6 +3642,7 @@ lxcDomainSendProcessSignal(virDomainPtr dom, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册