mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-13 19:25:13 +00:00
conf: checkpoint: Split virDomainCheckpointRedefinePrep into two functions
First one prepares and validates the definition, the second one actually either updates an existing checkpoint or assigns definition for the new one. This will allow driver code to add extra validation between those steps. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f37d306f6e
commit
93873c9bcc
@ -513,16 +513,11 @@ virDomainCheckpointDefFormat(virDomainCheckpointDefPtr def,
|
|||||||
|
|
||||||
int
|
int
|
||||||
virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
||||||
virDomainCheckpointDefPtr *defptr,
|
virDomainCheckpointDefPtr def,
|
||||||
virDomainMomentObjPtr *chk,
|
|
||||||
virDomainXMLOptionPtr xmlopt,
|
|
||||||
bool *update_current)
|
bool *update_current)
|
||||||
{
|
{
|
||||||
virDomainCheckpointDefPtr def = *defptr;
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virDomainMomentObjPtr parent = NULL;
|
virDomainMomentObjPtr parent = NULL;
|
||||||
virDomainMomentObjPtr other = NULL;
|
|
||||||
virDomainCheckpointDefPtr otherdef = NULL;
|
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
|
|
||||||
@ -550,12 +545,26 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
|||||||
if (virDomainCheckpointGetCurrent(vm->checkpoints) == NULL)
|
if (virDomainCheckpointGetCurrent(vm->checkpoints) == NULL)
|
||||||
*update_current = true;
|
*update_current = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virDomainMomentObjPtr
|
||||||
|
virDomainCheckpointRedefineCommit(virDomainObjPtr vm,
|
||||||
|
virDomainCheckpointDefPtr *defptr,
|
||||||
|
virDomainXMLOptionPtr xmlopt)
|
||||||
|
{
|
||||||
|
virDomainCheckpointDefPtr def = *defptr;
|
||||||
|
virDomainMomentObjPtr other = NULL;
|
||||||
|
virDomainCheckpointDefPtr otherdef = NULL;
|
||||||
|
virDomainMomentObjPtr chk = NULL;
|
||||||
|
|
||||||
other = virDomainCheckpointFindByName(vm->checkpoints, def->parent.name);
|
other = virDomainCheckpointFindByName(vm->checkpoints, def->parent.name);
|
||||||
if (other) {
|
if (other) {
|
||||||
otherdef = virDomainCheckpointObjGetDef(other);
|
otherdef = virDomainCheckpointObjGetDef(other);
|
||||||
if (!virDomainDefCheckABIStability(otherdef->parent.dom,
|
if (!virDomainDefCheckABIStability(otherdef->parent.dom,
|
||||||
def->parent.dom, xmlopt))
|
def->parent.dom, xmlopt))
|
||||||
return -1;
|
return NULL;
|
||||||
|
|
||||||
/* Drop and rebuild the parent relationship, but keep all
|
/* Drop and rebuild the parent relationship, but keep all
|
||||||
* child relations by reusing chk. */
|
* child relations by reusing chk. */
|
||||||
@ -563,8 +572,11 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
|||||||
virObjectUnref(otherdef);
|
virObjectUnref(otherdef);
|
||||||
other->def = &(*defptr)->parent;
|
other->def = &(*defptr)->parent;
|
||||||
*defptr = NULL;
|
*defptr = NULL;
|
||||||
*chk = other;
|
chk = other;
|
||||||
|
} else {
|
||||||
|
chk = virDomainCheckpointAssignDef(vm->checkpoints, def);
|
||||||
|
*defptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return chk;
|
||||||
}
|
}
|
||||||
|
@ -90,10 +90,14 @@ virDomainCheckpointDefFormat(virDomainCheckpointDefPtr def,
|
|||||||
int
|
int
|
||||||
virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr checkpoint);
|
virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr checkpoint);
|
||||||
|
|
||||||
int virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
int
|
||||||
virDomainCheckpointDefPtr *def,
|
virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
|
||||||
virDomainMomentObjPtr *checkpoint,
|
virDomainCheckpointDefPtr def,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
|
||||||
bool *update_current);
|
bool *update_current);
|
||||||
|
|
||||||
|
virDomainMomentObjPtr
|
||||||
|
virDomainCheckpointRedefineCommit(virDomainObjPtr vm,
|
||||||
|
virDomainCheckpointDefPtr *defptr,
|
||||||
|
virDomainXMLOptionPtr xmlopt);
|
||||||
|
|
||||||
VIR_ENUM_DECL(virDomainCheckpoint);
|
VIR_ENUM_DECL(virDomainCheckpoint);
|
||||||
|
@ -86,6 +86,7 @@ virDomainCheckpointDefFormat;
|
|||||||
virDomainCheckpointDefNew;
|
virDomainCheckpointDefNew;
|
||||||
virDomainCheckpointDefParseString;
|
virDomainCheckpointDefParseString;
|
||||||
virDomainCheckpointFormatConvertXMLFlags;
|
virDomainCheckpointFormatConvertXMLFlags;
|
||||||
|
virDomainCheckpointRedefineCommit;
|
||||||
virDomainCheckpointRedefinePrep;
|
virDomainCheckpointRedefinePrep;
|
||||||
virDomainCheckpointTypeFromString;
|
virDomainCheckpointTypeFromString;
|
||||||
virDomainCheckpointTypeToString;
|
virDomainCheckpointTypeToString;
|
||||||
|
@ -377,22 +377,14 @@ qemuCheckpointRedefine(virQEMUDriverPtr driver,
|
|||||||
virDomainCheckpointDefPtr *def,
|
virDomainCheckpointDefPtr *def,
|
||||||
bool *update_current)
|
bool *update_current)
|
||||||
{
|
{
|
||||||
virDomainMomentObjPtr chk = NULL;
|
if (virDomainCheckpointRedefinePrep(vm, *def, update_current) < 0)
|
||||||
|
|
||||||
if (virDomainCheckpointRedefinePrep(vm, def, &chk, driver->xmlopt,
|
|
||||||
update_current) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* XXX Should we validate that the redefined checkpoint even
|
/* XXX Should we validate that the redefined checkpoint even
|
||||||
* makes sense, such as checking that qemu-img recognizes the
|
* makes sense, such as checking that qemu-img recognizes the
|
||||||
* checkpoint bitmap name in at least one of the domain's disks? */
|
* checkpoint bitmap name in at least one of the domain's disks? */
|
||||||
|
|
||||||
if (chk)
|
return virDomainCheckpointRedefineCommit(vm, def, driver->xmlopt);
|
||||||
return chk;
|
|
||||||
|
|
||||||
chk = virDomainCheckpointAssignDef(vm->checkpoints, *def);
|
|
||||||
*def = NULL;
|
|
||||||
return chk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8989,9 +8989,10 @@ testDomainCheckpointCreateXML(virDomainPtr domain,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (redefine) {
|
if (redefine) {
|
||||||
if (virDomainCheckpointRedefinePrep(vm, &def, &chk,
|
if (virDomainCheckpointRedefinePrep(vm, def, &update_current) < 0)
|
||||||
privconn->xmlopt,
|
goto cleanup;
|
||||||
&update_current) < 0)
|
|
||||||
|
if (!(chk = virDomainCheckpointRedefineCommit(vm, &def, privconn->xmlopt)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
if (!(def->parent.dom = virDomainDefCopy(vm->def,
|
if (!(def->parent.dom = virDomainDefCopy(vm->def,
|
||||||
@ -9002,9 +9003,7 @@ testDomainCheckpointCreateXML(virDomainPtr domain,
|
|||||||
|
|
||||||
if (virDomainCheckpointAlignDisks(def) < 0)
|
if (virDomainCheckpointAlignDisks(def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!chk) {
|
|
||||||
if (!(chk = virDomainCheckpointAssignDef(vm->checkpoints, def)))
|
if (!(chk = virDomainCheckpointAssignDef(vm->checkpoints, def)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user