Revert "lxcDomainShutdownFlags: Cleanup @flags usage"

This reverts commit aa4619337ccc0b171a3a4d17540da89429243c36.

This patch was accidentally pushed prematurely, and has incorrect
logic for which shutdown methods to attempt.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-01-06 14:58:59 -07:00
parent 8531301d19
commit f3e359d665

View File

@ -2701,8 +2701,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
virDomainObjPtr vm; virDomainObjPtr vm;
char *vroot = NULL; char *vroot = NULL;
int ret = -1; int ret = -1;
int rc = 0; int rc;
bool useInitctl = false, initctlRequested, signalRequested;
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL | virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1); VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
@ -2731,24 +2730,25 @@ lxcDomainShutdownFlags(virDomainPtr dom,
(unsigned long long)priv->initpid) < 0) (unsigned long long)priv->initpid) < 0)
goto cleanup; goto cleanup;
initctlRequested = flags & VIR_DOMAIN_SHUTDOWN_INITCTL; if (flags == 0 ||
signalRequested = flags & VIR_DOMAIN_SHUTDOWN_SIGNAL; (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
if ((rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF,
if (initctlRequested || !flags) vroot)) < 0) {
useInitctl = true;
if (useInitctl) {
rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF, vroot);
if (rc < 0 && !signalRequested)
goto cleanup; goto cleanup;
if (rc == 0 && !signalRequested) { }
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 && !useInitctl) { if (rc == 0 &&
(flags == 0 ||
(flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) {
if (kill(priv->initpid, SIGTERM) < 0 && if (kill(priv->initpid, SIGTERM) < 0 &&
errno != ESRCH) { errno != ESRCH) {
virReportSystemError(errno, virReportSystemError(errno,