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
char *tmp;
struct stat sb;
size_t i;
+ size_t j;
for (i = 0; i < def->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
}
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;