]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: backup: Fix logic for generating default backup filenames
authorPeter Krempa <pkrempa@redhat.com>
Mon, 15 May 2023 12:20:16 +0000 (14:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 16 May 2023 08:26:33 +0000 (10:26 +0200)
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>
src/conf/backup_conf.c
tests/domainbackupxml2xmlin/backup-push.xml
tests/domainbackupxml2xmlout/backup-push.xml

index 013c08cd6ece05d0c03795309484b5f989a0d9ed..e151c297385ae37db34593a77bceb5637d67076e 100644 (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);
     }
index 0bfec9b2702c4059d33d1e8dc68780af4b170e4d..a95833d407bf3b0f437f4ecd61b52a7852913d5d 100644 (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>
index 317dcf6e471924855fd3e7c3acd3a76ee3da6d95..fff7db716b4361511526760afd41e5762b24f05e 100644 (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>