mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 18:45:16 +00:00
snapshot_conf: use alternate domain definition in virDomainSnapshotDefAssignExternalNames
Commit <ef3f3884a2432958bdd4ea0ce45509d47a91a453> introduced new argument for virDomainSnapshotAlignDisks() that allows passing alternate domain definition in case the snapshot parent.dom is NULL. In case of redefining snapshot it will not hit the part of code that unconditionally uses parent.dom as there will not be need to generate default external file names. It should be still fixed to make it safe. Future external snapshot revert code will use this to generate default file names and in this case it would crash. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
824e2a4a98
commit
a0853c89fe
@ -486,12 +486,14 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef *def,
|
|||||||
/**
|
/**
|
||||||
* virDomainSnapshotDefAssignExternalNames:
|
* virDomainSnapshotDefAssignExternalNames:
|
||||||
* @def: snapshot def object
|
* @def: snapshot def object
|
||||||
|
* @domdef: domain def object
|
||||||
*
|
*
|
||||||
* Generate default external file names for snapshot targets. Returns 0 on
|
* Generate default external file names for snapshot targets. Returns 0 on
|
||||||
* success, -1 on error.
|
* success, -1 on error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDef *def)
|
virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDef *def,
|
||||||
|
virDomainDef *domdef)
|
||||||
{
|
{
|
||||||
const char *origpath;
|
const char *origpath;
|
||||||
char *tmppath;
|
char *tmppath;
|
||||||
@ -514,7 +516,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDef *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(origpath = virDomainDiskGetSource(def->parent.dom->disks[i]))) {
|
if (!(origpath = virDomainDiskGetSource(domdef->disks[i]))) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("cannot generate external snapshot name for disk '%1$s' without source"),
|
_("cannot generate external snapshot name for disk '%1$s' without source"),
|
||||||
disk->name);
|
disk->name);
|
||||||
@ -702,7 +704,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Generate default external file names for external snapshot locations */
|
/* Generate default external file names for external snapshot locations */
|
||||||
if (virDomainSnapshotDefAssignExternalNames(snapdef) < 0)
|
if (virDomainSnapshotDefAssignExternalNames(snapdef, domdef) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user