qemuAppendDomainMemoryMachineParams: Refactor formatting of 'dump-guest-core'

Use virTristateSwitchFromBool to fill in the default if user didn't
request it explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-10-19 14:14:33 +02:00
parent c7c5d65183
commit ecb8c93196

View File

@ -6625,15 +6625,13 @@ qemuAppendDomainMemoryMachineParams(virBuffer *buf,
const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
virTristateSwitch dump = def->mem.dump_core;
size_t i;
if (def->mem.dump_core) {
virBufferAsprintf(buf, ",dump-guest-core=%s",
virTristateSwitchTypeToString(def->mem.dump_core));
} else {
virBufferAsprintf(buf, ",dump-guest-core=%s",
cfg->dumpGuestCore ? "on" : "off");
}
if (dump == VIR_TRISTATE_SWITCH_ABSENT)
dump = virTristateSwitchFromBool(cfg->dumpGuestCore);
virBufferAsprintf(buf, ",dump-guest-core=%s", virTristateSwitchTypeToString(dump));
if (def->mem.nosharepages)
virBufferAddLit(buf, ",mem-merge=off");