Add a new flag VIR_LXC_PROCESS_CLEANUP_AUTODESTROY to virLXCProcessCleanupFlags for skipping removal of the autodestroy callback so that fake reboot of the container doesn't need to fetch the connection and re-register it. Since virLXCProcessReboot is defined before virLXCProcessCleanupFlags, this patch also moves the flag enum typedef to the beginning of the file. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/lxc/lxc_process.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 753e9e0b9a..f9854ac138 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -56,6 +56,13 @@ VIR_LOG_INIT("lxc.lxc_process"); #define START_POSTFIX ": starting up\n" +typedef enum { + VIR_LXC_PROCESS_CLEANUP_RELEASE_SECLABEL = (1 << 0), + VIR_LXC_PROCESS_CLEANUP_RESTORE_SECLABEL = (1 << 1), + VIR_LXC_PROCESS_CLEANUP_REMOVE_TRANSIENT = (1 << 2), + VIR_LXC_PROCESS_CLEANUP_AUTODESTROY = (1 << 3), +} virLXCProcessCleanupFlags; + static void lxcProcessAutoDestroy(virDomainObj *dom, virConnectPtr conn) @@ -87,23 +94,21 @@ static int virLXCProcessReboot(virLXCDriver *driver, virDomainObj *vm) { - g_autoptr(virConnect) autoDestroyConn = virCloseCallbacksGetConn(driver->closeCallbacks, vm); + /* we want to keep the autodestroy callback registered */ + unsigned int stopFlags = ~(VIR_LXC_PROCESS_CLEANUP_AUTODESTROY); int reason = vm->state.reason; virDomainDef *savedDef; VIR_DEBUG("Faking reboot"); - if (autoDestroyConn) - virObjectRef(autoDestroyConn); - /* In a reboot scenario, we need to make sure we continue * to use the current 'def', and not switch to 'newDef'. * So temporarily hide the newDef and then reinstate it */ savedDef = g_steal_pointer(&vm->newDef); - virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, 0); + virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, stopFlags); vm->newDef = savedDef; - if (virLXCProcessStart(driver, vm, 0, NULL, autoDestroyConn, reason) < 0) { + if (virLXCProcessStart(driver, vm, 0, NULL, NULL, reason) < 0) { VIR_WARN("Unable to handle reboot of vm %s", vm->def->name); return -1; } @@ -126,12 +131,6 @@ lxcProcessRemoveDomainStatus(virLXCDriverConfig *cfg, } -typedef enum { - VIR_LXC_PROCESS_CLEANUP_RELEASE_SECLABEL = (1 << 0), - VIR_LXC_PROCESS_CLEANUP_RESTORE_SECLABEL = (1 << 1), - VIR_LXC_PROCESS_CLEANUP_REMOVE_TRANSIENT = (1 << 2), -} virLXCProcessCleanupFlags; - /** * virLXCProcessCleanup: * @driver: pointer to driver structure @@ -188,8 +187,9 @@ static void virLXCProcessCleanup(virLXCDriver *driver, } /* Stop autodestroy in case guest is restarted */ - virCloseCallbacksUnset(driver->closeCallbacks, vm, - lxcProcessAutoDestroy); + if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) { + virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoDestroy); + } if (priv->monitor) { virLXCMonitorClose(priv->monitor); -- 2.36.1