[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V3 4/5] libxl: fix mapping of lifecycle actions
The libxl driver was blindly assigning libvirt's virDomainLifecycleAction to libxl's libxl_action_on_shutdown, when in fact the various actions take on different values in these enums. Introduce helpers to properly map the enum values. Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx> --- src/libxl/libxl_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 1dbdd9c..a9139bf 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -102,6 +102,62 @@ libxlDriverConfigDispose(void *obj) VIR_FREE(cfg->autoDumpDir); } + +static libxl_action_on_shutdown +libxlActionFromVirLifecycle(virDomainLifecycleAction action) +{ + switch (action) { + case VIR_DOMAIN_LIFECYCLE_DESTROY: + return LIBXL_ACTION_ON_SHUTDOWN_DESTROY; + + case VIR_DOMAIN_LIFECYCLE_RESTART: + return LIBXL_ACTION_ON_SHUTDOWN_RESTART; + + case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: + return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME; + + case VIR_DOMAIN_LIFECYCLE_PRESERVE: + return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE; + + case VIR_DOMAIN_LIFECYCLE_LAST: + break; + } + + return 0; +} + + +static libxl_action_on_shutdown +libxlActionFromVirLifecycleCrash(virDomainLifecycleCrashAction action) +{ + + switch (action) { + case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: + return LIBXL_ACTION_ON_SHUTDOWN_DESTROY; + + case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: + return LIBXL_ACTION_ON_SHUTDOWN_RESTART; + + case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME: + return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME; + + case VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE: + return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE; + + case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY: + return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY; + + case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART: + return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART; + + case VIR_DOMAIN_LIFECYCLE_CRASH_LAST: + break; + } + + return 0; +} + + static int libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps) { @@ -1436,9 +1492,9 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports, if (libxlMakePCIList(def, d_config) < 0) return -1; - d_config->on_reboot = def->onReboot; - d_config->on_poweroff = def->onPoweroff; - d_config->on_crash = def->onCrash; + d_config->on_reboot = libxlActionFromVirLifecycle(def->onReboot); + d_config->on_poweroff = libxlActionFromVirLifecycle(def->onPoweroff); + d_config->on_crash = libxlActionFromVirLifecycleCrash(def->onCrash); return 0; } -- 1.8.4.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |