mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-03 21:05:46 +00:00
virLXCProcessReboot: Remove the need to re-register autodestroy callback
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@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
6d155a5a8e
commit
8eeb284499
@ -56,6 +56,13 @@ VIR_LOG_INIT("lxc.lxc_process");
|
|||||||
|
|
||||||
#define START_POSTFIX ": starting up\n"
|
#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
|
static void
|
||||||
lxcProcessAutoDestroy(virDomainObj *dom,
|
lxcProcessAutoDestroy(virDomainObj *dom,
|
||||||
virConnectPtr conn)
|
virConnectPtr conn)
|
||||||
@ -87,23 +94,21 @@ static int
|
|||||||
virLXCProcessReboot(virLXCDriver *driver,
|
virLXCProcessReboot(virLXCDriver *driver,
|
||||||
virDomainObj *vm)
|
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;
|
int reason = vm->state.reason;
|
||||||
virDomainDef *savedDef;
|
virDomainDef *savedDef;
|
||||||
|
|
||||||
VIR_DEBUG("Faking reboot");
|
VIR_DEBUG("Faking reboot");
|
||||||
|
|
||||||
if (autoDestroyConn)
|
|
||||||
virObjectRef(autoDestroyConn);
|
|
||||||
|
|
||||||
/* In a reboot scenario, we need to make sure we continue
|
/* In a reboot scenario, we need to make sure we continue
|
||||||
* to use the current 'def', and not switch to 'newDef'.
|
* to use the current 'def', and not switch to 'newDef'.
|
||||||
* So temporarily hide the newDef and then reinstate it
|
* So temporarily hide the newDef and then reinstate it
|
||||||
*/
|
*/
|
||||||
savedDef = g_steal_pointer(&vm->newDef);
|
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;
|
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);
|
VIR_WARN("Unable to handle reboot of vm %s", vm->def->name);
|
||||||
return -1;
|
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:
|
* virLXCProcessCleanup:
|
||||||
* @driver: pointer to driver structure
|
* @driver: pointer to driver structure
|
||||||
@ -188,8 +187,9 @@ static void virLXCProcessCleanup(virLXCDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Stop autodestroy in case guest is restarted */
|
/* Stop autodestroy in case guest is restarted */
|
||||||
virCloseCallbacksUnset(driver->closeCallbacks, vm,
|
if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) {
|
||||||
lxcProcessAutoDestroy);
|
virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoDestroy);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->monitor) {
|
if (priv->monitor) {
|
||||||
virLXCMonitorClose(priv->monitor);
|
virLXCMonitorClose(priv->monitor);
|
||||||
|
Loading…
Reference in New Issue
Block a user