From 1222ada2afe62279ce4c8844694b3cb756ddd60b Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 15 May 2023 14:20:16 +0200 Subject: conf: backup: Fix logic for generating default backup filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/conf/backup_conf.c | 7 +++++-- tests/domainbackupxml2xmlin/backup-push.xml | 1 + tests/domainbackupxml2xmlout/backup-push.xml | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 013c08cd6e..e151c29738 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -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); } diff --git a/tests/domainbackupxml2xmlin/backup-push.xml b/tests/domainbackupxml2xmlin/backup-push.xml index 0bfec9b270..a95833d407 100644 --- a/tests/domainbackupxml2xmlin/backup-push.xml +++ b/tests/domainbackupxml2xmlin/backup-push.xml @@ -5,6 +5,7 @@ + diff --git a/tests/domainbackupxml2xmlout/backup-push.xml b/tests/domainbackupxml2xmlout/backup-push.xml index 317dcf6e47..fff7db716b 100644 --- a/tests/domainbackupxml2xmlout/backup-push.xml +++ b/tests/domainbackupxml2xmlout/backup-push.xml @@ -5,6 +5,9 @@ + + + -- cgit v1.2.1