static int virLXCProcessReconnectDomain(virDomainObjPtr vm, void *opaque) { virLXCDriverPtr driver = opaque; virLXCDomainObjPrivatePtr priv; int ret = -1; virObjectLock(vm); VIR_DEBUG("Reconnect id=%d pid=%d state=%d", vm->def->id, vm->pid, vm->state.state); priv = vm->privateData; if (vm->pid != 0) { vm->def->id = vm->pid; virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNKNOWN); if (!driver->nactive && driver->inhibitCallback) driver->inhibitCallback(true, driver->inhibitOpaque); driver->nactive++; if (!(priv->monitor = virLXCProcessConnectMonitor(driver, vm))) goto error; if (virLXCUpdateActiveUsbHostdevs(driver, vm->def) < 0) goto error; if (virSecurityManagerReserveLabel(driver->securityManager, vm->def, vm->pid) < 0) goto error; /* now that we know it's reconnected call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { char *xml = virDomainDefFormat(vm->def, 0); int hookret; /* we can't stop the operation even if the script raised an error */ hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, VIR_HOOK_LXC_OP_RECONNECT, VIR_HOOK_SUBOP_BEGIN, NULL, xml, NULL); VIR_FREE(xml); if (hookret < 0) goto error; } } else { vm->def->id = -1; } ret = 0; cleanup: virObjectUnlock(vm); return ret; error: virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); virDomainAuditStop(vm, "failed"); goto cleanup; }
static int virSecurityStackReserveLabel(virSecurityManagerPtr mgr, virDomainObjPtr vm) { virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr); int rc = 0; if (virSecurityManagerReserveLabel(priv->primary, vm) < 0) rc = -1; #if 0 /* XXX See note in GenLabel */ if (virSecurityManagerReserveLabel(priv->secondary, vm) < 0) rc = -1; #endif return rc; }