mirror of https://gitee.com/openkylin/libvirt.git
Add actions to virDomainLifecycle enum
Xen supports on_crash actions coredump-{destroy,restart}. libvirt cannot parse config returned by xend that contains either of these actions xen52 # xm li -l test | grep on_crash (on_crash coredump-restart) xen52 # virsh dumpxml test error: internal error unknown lifecycle type coredump-restart This patch adds a new virDomainLifecycleCrash enum and appends the new options to existing destroy, restart, preserve, and rename-restart options.
This commit is contained in:
parent
7fb3435186
commit
b9c10268e1
|
@ -366,6 +366,21 @@
|
|||
a new name</dd>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
on_crash supports these additional
|
||||
actions <span class="since">since 0.8.4</span>.
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt><code>coredump-destroy</code></dt>
|
||||
<dd>The crashed domain's core will be dumped, and then the
|
||||
domain will be terminated completely and all resources
|
||||
released</dd>
|
||||
<dt><code>coredump-restart</code></dt>
|
||||
<dd>The crashed domain's core will be dumped, and then the
|
||||
domain will be restarted with the same configuration</dd>
|
||||
</dl>
|
||||
|
||||
<h3><a name="elementsFeatures">Hypervisor features</a></h3>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -1177,7 +1177,7 @@
|
|||
</optional>
|
||||
<optional>
|
||||
<element name="on_crash">
|
||||
<ref name="offOptions"/>
|
||||
<ref name="crashOptions"/>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
|
@ -1198,6 +1198,29 @@
|
|||
<value>rename-restart</value>
|
||||
</choice>
|
||||
</define>
|
||||
<!--
|
||||
Options when a domain crashes:
|
||||
destroy: The domain is cleaned up
|
||||
restart: A new domain is started in place of the old one
|
||||
preserve: The domain will remain in memory until it is destroyed manually
|
||||
rename-restart: a variant of the previous one but where the old domain is
|
||||
renamed before being saved to allow a restart
|
||||
coredump-destroy: The crashed domain's core will be dumped, and then the
|
||||
domain will be terminated completely and all resources
|
||||
released
|
||||
coredump-restart: The crashed domain's core will be dumped, and then the
|
||||
domain will be restarted with the same configuration
|
||||
-->
|
||||
<define name="crashOptions">
|
||||
<choice>
|
||||
<value>destroy</value>
|
||||
<value>restart</value>
|
||||
<value>preserve</value>
|
||||
<value>rename-restart</value>
|
||||
<value>coredump-destroy</value>
|
||||
<value>coredump-restart</value>
|
||||
</choice>
|
||||
</define>
|
||||
<!--
|
||||
Specific setup for a qemu emulated character device. Note: this
|
||||
definition doesn't fully specify the constraints on this node.
|
||||
|
|
|
@ -83,6 +83,14 @@ VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
|
|||
"rename-restart",
|
||||
"preserve")
|
||||
|
||||
VIR_ENUM_IMPL(virDomainLifecycleCrash, VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
|
||||
"destroy",
|
||||
"restart",
|
||||
"rename-restart",
|
||||
"preserve",
|
||||
"coredump-destroy",
|
||||
"coredump-restart")
|
||||
|
||||
VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
|
||||
"disk",
|
||||
"filesystem",
|
||||
|
@ -3763,13 +3771,14 @@ error:
|
|||
static int virDomainLifecycleParseXML(xmlXPathContextPtr ctxt,
|
||||
const char *xpath,
|
||||
int *val,
|
||||
int defaultVal)
|
||||
int defaultVal,
|
||||
virLifecycleFromStringFunc convFunc)
|
||||
{
|
||||
char *tmp = virXPathString(xpath, ctxt);
|
||||
if (tmp == NULL) {
|
||||
*val = defaultVal;
|
||||
} else {
|
||||
*val = virDomainLifecycleTypeFromString(tmp);
|
||||
*val = convFunc(tmp);
|
||||
if (*val < 0) {
|
||||
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown lifecycle action %s"), tmp);
|
||||
|
@ -4253,15 +4262,19 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||
}
|
||||
|
||||
if (virDomainLifecycleParseXML(ctxt, "string(./on_reboot[1])",
|
||||
&def->onReboot, VIR_DOMAIN_LIFECYCLE_RESTART) < 0)
|
||||
&def->onReboot, VIR_DOMAIN_LIFECYCLE_RESTART,
|
||||
virDomainLifecycleTypeFromString) < 0)
|
||||
goto error;
|
||||
|
||||
if (virDomainLifecycleParseXML(ctxt, "string(./on_poweroff[1])",
|
||||
&def->onPoweroff, VIR_DOMAIN_LIFECYCLE_DESTROY) < 0)
|
||||
&def->onPoweroff, VIR_DOMAIN_LIFECYCLE_DESTROY,
|
||||
virDomainLifecycleTypeFromString) < 0)
|
||||
goto error;
|
||||
|
||||
if (virDomainLifecycleParseXML(ctxt, "string(./on_crash[1])",
|
||||
&def->onCrash, VIR_DOMAIN_LIFECYCLE_DESTROY) < 0)
|
||||
&def->onCrash,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
|
||||
virDomainLifecycleCrashTypeFromString) < 0)
|
||||
goto error;
|
||||
|
||||
tmp = virXPathString("string(./clock/@offset)", ctxt);
|
||||
|
@ -5396,9 +5409,10 @@ virDomainCpuSetParse(const char **str, char sep,
|
|||
static int
|
||||
virDomainLifecycleDefFormat(virBufferPtr buf,
|
||||
int type,
|
||||
const char *name)
|
||||
const char *name,
|
||||
virLifecycleToStringFunc convFunc)
|
||||
{
|
||||
const char *typeStr = virDomainLifecycleTypeToString(type);
|
||||
const char *typeStr = convFunc(type);
|
||||
if (!typeStr) {
|
||||
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected lifecycle type %d"), type);
|
||||
|
@ -6483,13 +6497,16 @@ char *virDomainDefFormat(virDomainDefPtr def,
|
|||
}
|
||||
|
||||
if (virDomainLifecycleDefFormat(&buf, def->onPoweroff,
|
||||
"on_poweroff") < 0)
|
||||
"on_poweroff",
|
||||
virDomainLifecycleTypeToString) < 0)
|
||||
goto cleanup;
|
||||
if (virDomainLifecycleDefFormat(&buf, def->onReboot,
|
||||
"on_reboot") < 0)
|
||||
"on_reboot",
|
||||
virDomainLifecycleTypeToString) < 0)
|
||||
goto cleanup;
|
||||
if (virDomainLifecycleDefFormat(&buf, def->onCrash,
|
||||
"on_crash") < 0)
|
||||
"on_crash",
|
||||
virDomainLifecycleCrashTypeToString) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virBufferAddLit(&buf, " <devices>\n");
|
||||
|
|
|
@ -663,6 +663,17 @@ enum virDomainLifecycleAction {
|
|||
VIR_DOMAIN_LIFECYCLE_LAST
|
||||
};
|
||||
|
||||
enum virDomainLifecycleCrashAction {
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_RESTART,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY,
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART,
|
||||
|
||||
VIR_DOMAIN_LIFECYCLE_CRASH_LAST
|
||||
};
|
||||
|
||||
/* Operating system configuration data & machine / arch */
|
||||
typedef struct _virDomainOSDef virDomainOSDef;
|
||||
typedef virDomainOSDef *virDomainOSDefPtr;
|
||||
|
@ -1135,10 +1146,14 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
|
|||
virDomainDiskDefPathIterator iter,
|
||||
void *opaque);
|
||||
|
||||
typedef const char* (*virLifecycleToStringFunc)(int type);
|
||||
typedef int (*virLifecycleFromStringFunc)(const char *type);
|
||||
|
||||
VIR_ENUM_DECL(virDomainVirt)
|
||||
VIR_ENUM_DECL(virDomainBoot)
|
||||
VIR_ENUM_DECL(virDomainFeature)
|
||||
VIR_ENUM_DECL(virDomainLifecycle)
|
||||
VIR_ENUM_DECL(virDomainLifecycleCrash)
|
||||
VIR_ENUM_DECL(virDomainDevice)
|
||||
VIR_ENUM_DECL(virDomainDeviceAddress)
|
||||
VIR_ENUM_DECL(virDomainDeviceAddressMode)
|
||||
|
|
|
@ -2206,7 +2206,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
|
|||
|
||||
tmp = sexpr_node(root, "domain/on_crash");
|
||||
if (tmp != NULL) {
|
||||
if ((def->onCrash = virDomainLifecycleTypeFromString(tmp)) < 0) {
|
||||
if ((def->onCrash = virDomainLifecycleCrashTypeFromString(tmp)) < 0) {
|
||||
virXendError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown lifecycle type %s"), tmp);
|
||||
goto error;
|
||||
|
@ -5693,7 +5693,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
|
|||
}
|
||||
virBufferVSprintf(&buf, "(on_reboot '%s')", tmp);
|
||||
|
||||
if (!(tmp = virDomainLifecycleTypeToString(def->onCrash))) {
|
||||
if (!(tmp = virDomainLifecycleCrashTypeToString(def->onCrash))) {
|
||||
virXendError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected lifecycle value %d"), def->onCrash);
|
||||
goto error;
|
||||
|
|
|
@ -803,7 +803,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
|
|||
|
||||
if (xenXMConfigGetString(conf, "on_crash", &str, "restart") < 0)
|
||||
goto cleanup;
|
||||
if ((def->onCrash = virDomainLifecycleTypeFromString(str)) < 0) {
|
||||
if ((def->onCrash = virDomainLifecycleCrashTypeFromString(str)) < 0) {
|
||||
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected value %s for on_crash"), str);
|
||||
goto cleanup;
|
||||
|
@ -2378,7 +2378,7 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
|
|||
goto no_memory;
|
||||
|
||||
|
||||
if (!(lifecycle = virDomainLifecycleTypeToString(def->onCrash))) {
|
||||
if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
|
||||
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected lifecycle action %d"), def->onCrash);
|
||||
goto cleanup;
|
||||
|
|
|
@ -153,17 +153,21 @@ actionShutdownLibvirt2XenapiEnum(enum virDomainLifecycleAction action)
|
|||
|
||||
|
||||
enum xen_on_crash_behaviour
|
||||
actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleAction action)
|
||||
actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleCrashAction action)
|
||||
{
|
||||
enum xen_on_crash_behaviour num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
|
||||
if (action == VIR_DOMAIN_LIFECYCLE_DESTROY)
|
||||
if (action == VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_DESTROY;
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_RESTART)
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_CRASH_RESTART)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_PRESERVE)
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_PRESERVE;
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_RESTART_RENAME)
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART;
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY;
|
||||
else if (action == VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART)
|
||||
num = XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART;
|
||||
return num;
|
||||
}
|
||||
|
||||
|
@ -218,18 +222,22 @@ xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action)
|
|||
}
|
||||
|
||||
|
||||
enum virDomainLifecycleAction
|
||||
enum virDomainLifecycleCrashAction
|
||||
xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action)
|
||||
{
|
||||
enum virDomainLifecycleAction num = VIR_DOMAIN_LIFECYCLE_RESTART;
|
||||
enum virDomainLifecycleCrashAction num = VIR_DOMAIN_LIFECYCLE_CRASH__RESTART;
|
||||
if (action == XEN_ON_CRASH_BEHAVIOUR_DESTROY)
|
||||
num = VIR_DOMAIN_LIFECYCLE_DESTROY;
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY;
|
||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_RESTART)
|
||||
num = VIR_DOMAIN_LIFECYCLE_RESTART;
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_RESTART;
|
||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_PRESERVE)
|
||||
num = VIR_DOMAIN_LIFECYCLE_PRESERVE;
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE;
|
||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART)
|
||||
num = VIR_DOMAIN_LIFECYCLE_RESTART_RENAME;
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME;
|
||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY)
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY;
|
||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART)
|
||||
num = VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART;
|
||||
return num;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ enum xen_on_normal_exit
|
|||
actionShutdownLibvirt2XenapiEnum(enum virDomainLifecycleAction action);
|
||||
|
||||
enum xen_on_crash_behaviour
|
||||
actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleAction action);
|
||||
actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleCrashAction action);
|
||||
|
||||
char *
|
||||
createXenAPIBootOrderString(int nboot, int *bootDevs);
|
||||
|
@ -56,7 +56,7 @@ enum virDomainBootOrder map2LibvirtBootOrder(char c);
|
|||
enum virDomainLifecycleAction
|
||||
xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action);
|
||||
|
||||
enum virDomainLifecycleAction
|
||||
enum virDomainLifecycleCrashAction
|
||||
xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action);
|
||||
|
||||
void getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen);
|
||||
|
|
Loading…
Reference in New Issue