mirror of https://gitee.com/openkylin/libvirt.git
conf: checkpoint: Prepare internals for missing domain definition
Conditionalize code which assumes that the domain definition stored in the checkpoint is present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
9fd8ba3b2d
commit
392eacfeb1
|
@ -460,10 +460,10 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf,
|
||||||
virBufferAddLit(buf, "</disks>\n");
|
virBufferAddLit(buf, "</disks>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) &&
|
if (def->parent.dom && !(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN)) {
|
||||||
virDomainDefFormatInternal(def->parent.dom, xmlopt,
|
if (virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0)
|
||||||
buf, domainflags) < 0)
|
return -1;
|
||||||
return -1;
|
}
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</domaincheckpoint>\n");
|
virBufferAddLit(buf, "</domaincheckpoint>\n");
|
||||||
|
@ -495,23 +495,24 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
||||||
virDomainCheckpointDefPtr def,
|
virDomainCheckpointDefPtr def,
|
||||||
bool *update_current)
|
bool *update_current)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virDomainMomentObjPtr parent = NULL;
|
virDomainMomentObjPtr parent = NULL;
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
|
||||||
|
|
||||||
if (virDomainCheckpointCheckCycles(vm->checkpoints, def, vm->def->name) < 0)
|
if (virDomainCheckpointCheckCycles(vm->checkpoints, def, vm->def->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!def->parent.dom ||
|
if (def->parent.dom) {
|
||||||
memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) {
|
if (memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
_("definition for checkpoint %s must use uuid %s"),
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
def->parent.name, uuidstr);
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
return -1;
|
_("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 &&
|
if (def->parent.parent_name &&
|
||||||
(parent = virDomainCheckpointFindByName(vm->checkpoints,
|
(parent = virDomainCheckpointFindByName(vm->checkpoints,
|
||||||
|
|
|
@ -87,11 +87,6 @@ testCompareXMLToXMLFiles(const char *inxml,
|
||||||
formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE;
|
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,
|
if (!(actual = virDomainCheckpointDefFormat(def,
|
||||||
driver.xmlopt,
|
driver.xmlopt,
|
||||||
formatflags)))
|
formatflags)))
|
||||||
|
|
Loading…
Reference in New Issue