mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
conf: snapshot: Avoid autogenerating duplicate snapshot names
The snapshot name generator truncates the original file name after a '.' and replaces the suffix with the snapshot name. If two disks source images differ only in the suffix portion, the generated name will be duplicate. Since this is a corner case just error out stating that a duplicate name was generated. The user can work around this situation by providing the file names explicitly. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283085
This commit is contained in:
parent
4319444d05
commit
b60af444cc
@ -445,6 +445,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
|
||||
char *tmp;
|
||||
struct stat sb;
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
|
||||
@ -491,6 +492,17 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
|
||||
}
|
||||
|
||||
VIR_FREE(tmppath);
|
||||
|
||||
/* verify that we didn't generate a duplicate name */
|
||||
for (j = 0; j < i; j++) {
|
||||
if (STREQ_NULLABLE(disk->src->path, def->disks[j].src->path)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("cannot generate external snapshot name for "
|
||||
"disk '%s': collision with disk '%s'"),
|
||||
disk->name, def->disks[j].name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user