mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
src/xenxs: Refactor code formating event actions config
introduce function xenFormatXMEventActions(virConfPtr conf,.........); which formats event actions instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
This commit is contained in:
parent
a7de003a94
commit
c849d01c5e
@ -1776,6 +1776,41 @@ xenFormatXMTimeOffset(virConfPtr conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def)
|
||||||
|
{
|
||||||
|
const char *lifecycle = NULL;
|
||||||
|
|
||||||
|
if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unexpected lifecycle action %d"), def->onPoweroff);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (xenXMConfigSetString(conf, "on_poweroff", lifecycle) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(lifecycle = virDomainLifecycleTypeToString(def->onReboot))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unexpected lifecycle action %d"), def->onReboot);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unexpected lifecycle action %d"), def->onCrash);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
||||||
either 32, or 64 on a platform where long is big enough. */
|
either 32, or 64 on a platform where long is big enough. */
|
||||||
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
|
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
|
||||||
@ -1789,7 +1824,6 @@ xenFormatXM(virConnectPtr conn,
|
|||||||
int hvm = 0;
|
int hvm = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *cpus = NULL;
|
char *cpus = NULL;
|
||||||
const char *lifecycle;
|
|
||||||
virConfValuePtr diskVal = NULL;
|
virConfValuePtr diskVal = NULL;
|
||||||
virConfValuePtr netVal = NULL;
|
virConfValuePtr netVal = NULL;
|
||||||
|
|
||||||
@ -1928,33 +1962,8 @@ xenFormatXM(virConnectPtr conn,
|
|||||||
if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0)
|
if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) {
|
if (xenFormatXMEventActions(conf, def) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("unexpected lifecycle action %d"), def->onPoweroff);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (xenXMConfigSetString(conf, "on_poweroff", lifecycle) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
|
||||||
if (!(lifecycle = virDomainLifecycleTypeToString(def->onReboot))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("unexpected lifecycle action %d"), def->onReboot);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
|
||||||
if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("unexpected lifecycle action %d"), def->onCrash);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (hvm) {
|
if (hvm) {
|
||||||
if (def->emulator &&
|
if (def->emulator &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user