Coniditonalize code which assumes that the domain definition stored in the checkpoint is present. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/checkpoint_conf.c | 31 +++++++++++++------------ tests/qemudomaincheckpointxml2xmltest.c | 5 ---- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 73fdb78e7a..2071494d52 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -475,10 +475,10 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "</disks>\n"); } - if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) && - virDomainDefFormatInternal(def->parent.dom, xmlopt, - buf, domainflags) < 0) - return -1; + if (def->parent.dom && !(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN)) { + if (virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0) + return -1; + } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</domaincheckpoint>\n"); @@ -510,23 +510,24 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, virDomainCheckpointDefPtr def, bool *update_current) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; virDomainMomentObjPtr parent = NULL; - virUUIDFormat(vm->def->uuid, uuidstr); - if (virDomainCheckpointCheckCycles(vm->checkpoints, def, vm->def->name) < 0) return -1; - if (!def->parent.dom || - memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) { - virReportError(VIR_ERR_INVALID_ARG, - _("definition for checkpoint %s must use uuid %s"), - def->parent.name, uuidstr); - return -1; + if (def->parent.dom) { + if (memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(vm->def->uuid, uuidstr); + virReportError(VIR_ERR_INVALID_ARG, + _("definition for checkpoint %s must use uuid %s"), + def->parent.name, uuidstr); + return -1; + } + + if (virDomainCheckpointAlignDisks(def) < 0) + return -1; } - if (virDomainCheckpointAlignDisks(def) < 0) - return -1; if (def->parent.parent_name && (parent = virDomainCheckpointFindByName(vm->checkpoints, diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomaincheckpointxml2xmltest.c index a5a5b59205..8b4b75d753 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -87,11 +87,6 @@ testCompareXMLToXMLFiles(const char *inxml, formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE; } - /* Parsing XML does not populate the domain definition; work - * around that by not requesting domain on output */ - if (!def->parent.dom) - formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN; - if (!(actual = virDomainCheckpointDefFormat(def, driver.xmlopt, formatflags))) -- 2.28.0