mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
Revert "lxc: Prevent shutting down the host"
This reverts commit c9c87376f2b2197ad774533ad6a6dd2f631ca105. Now that we force all containers to have a root filesystem, there is no way the host's /dev is ever exposed Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
c131525bec
commit
edd87fa2ea
@ -2778,19 +2778,13 @@ lxcDomainShutdownFlags(virDomainPtr dom,
|
|||||||
virLXCDriverPtr driver = dom->conn->privateData;
|
virLXCDriverPtr driver = dom->conn->privateData;
|
||||||
virLXCDomainObjPrivatePtr priv;
|
virLXCDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainFSDefPtr root;
|
|
||||||
char *vroot = NULL;
|
char *vroot = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc = 0;
|
int rc;
|
||||||
bool methodSignal;
|
|
||||||
bool methodInitctl;
|
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
|
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
|
||||||
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
|
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
|
||||||
|
|
||||||
methodSignal = !!(flags & VIR_DOMAIN_SHUTDOWN_SIGNAL);
|
|
||||||
methodInitctl = !!(flags & VIR_DOMAIN_SHUTDOWN_INITCTL);
|
|
||||||
|
|
||||||
lxcDriverLock(driver);
|
lxcDriverLock(driver);
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
lxcDriverUnlock(driver);
|
lxcDriverUnlock(driver);
|
||||||
@ -2804,7 +2798,6 @@ lxcDomainShutdownFlags(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
root = virDomainGetRootFilesystem(vm->def);
|
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
@ -2824,31 +2817,27 @@ lxcDomainShutdownFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root && root->src) {
|
if (flags == 0 ||
|
||||||
if (flags == 0)
|
(flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
|
||||||
methodSignal = methodInitctl = true;
|
if ((rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF,
|
||||||
} else if (methodInitctl) {
|
vroot)) < 0) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("Cannot shutdown container using initctl "
|
|
||||||
"without separated namespace"));
|
|
||||||
goto cleanup;
|
|
||||||
} else {
|
|
||||||
methodSignal = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (methodInitctl) {
|
|
||||||
rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF, vroot);
|
|
||||||
if (rc < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (rc == 0 && !methodSignal) {
|
}
|
||||||
|
if (rc == 0 && flags != 0 &&
|
||||||
|
((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("Container does not provide an initctl pipe"));
|
_("Container does not provide an initctl pipe"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
rc = 0;
|
||||||
}
|
}
|
||||||
if (rc == 0 && methodSignal) {
|
|
||||||
ret = kill(priv->initpid, SIGTERM);
|
if (rc == 0 &&
|
||||||
if (ret < 0 && errno != ESRCH) {
|
(flags == 0 ||
|
||||||
|
(flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) {
|
||||||
|
if (kill(priv->initpid, SIGTERM) < 0 &&
|
||||||
|
errno != ESRCH) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to send SIGTERM to init pid %llu"),
|
_("Unable to send SIGTERM to init pid %llu"),
|
||||||
(unsigned long long)priv->initpid);
|
(unsigned long long)priv->initpid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user