1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

conf: backup: Fix logic for generating default backup filenames

If the 'disk->store' property is already allocated which happens e.g.
when the disk is described by the backup XML but the optional filename
is not filled in 'virDomainBackupDefAssignStore' would not fill in the
default location.

Fix the logic to do it also if a 'virStorageSource' categorizes as
empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-05-15 14:20:16 +02:00
parent de48ade195
commit 1222ada2af
3 changed files with 9 additions and 2 deletions

View File

@ -424,7 +424,8 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDef *disk,
}
}
if (!disk->store) {
if (!disk->store ||
virStorageSourceIsEmpty(disk->store)) {
if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_FILE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("refusing to generate file name for disk '%1$s'"),
@ -432,7 +433,9 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDef *disk,
return -1;
}
disk->store = virStorageSourceNew();
if (!disk->store)
disk->store = virStorageSourceNew();
disk->store->type = VIR_STORAGE_TYPE_FILE;
disk->store->path = g_strdup_printf("%s.%s", src->path, suffix);
}

View File

@ -5,6 +5,7 @@
<driver type='raw'/>
<target file='/path/to/file'/>
</disk>
<disk name='vdb' type='file' backupmode='full'/>
<disk name='hda' backup='no'/>
</disks>
</domainbackup>

View File

@ -5,6 +5,9 @@
<driver type='raw'/>
<target file='/path/to/file'/>
</disk>
<disk name='vdb' backup='yes' type='file' backupmode='full'>
<target file='/fake/vdb.qcow2.SUFFIX'/>
</disk>
<disk name='hda' backup='no'/>
<disk name='vdextradisk' backup='no'/>
</disks>