1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-11-03 08:24:18 +03:00

backupxml2xmltest: Call 'virDomainBackupAlignDisks' before formatting output

Call the post-processing function so that we can validate that it does
the correct thing.

virDomainBackupAlignDisks requires disk definitions to be present so
let's fake them by copying disks from the backup definition and add one
extra disk 'vdextradisk'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa
2020-07-07 16:38:00 +02:00
parent 1a7ce56ae1
commit 6f33e441e2
9 changed files with 50 additions and 1 deletions

View File

@@ -51,6 +51,23 @@ struct testCompareBackupXMLData {
};
static virDomainDiskDefPtr
testCompareBackupXMLGetFakeDomdisk(const char *dst)
{
virDomainDiskDefPtr domdisk = NULL;
if (!(domdisk = virDomainDiskDefNew(NULL)))
abort();
domdisk->dst = g_strdup(dst);
domdisk->src->type = VIR_STORAGE_TYPE_FILE;
domdisk->src->format = VIR_STORAGE_FILE_QCOW2;
domdisk->src->path = g_strdup_printf("/fake/%s.qcow2", dst);
return domdisk;
}
static int
testCompareBackupXML(const void *opaque)
{
@@ -63,6 +80,8 @@ testCompareBackupXML(const void *opaque)
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *actual = NULL;
unsigned int parseFlags = 0;
g_autoptr(virDomainDef) fakedef = NULL;
size_t i;
if (data->internal)
parseFlags |= VIR_DOMAIN_BACKUP_PARSE_INTERNAL;
@@ -80,6 +99,23 @@ testCompareBackupXML(const void *opaque)
return -1;
}
/* create a fake definition and fill it with disks */
if (!(fakedef = virDomainDefNew()))
return -1;
fakedef->ndisks = backup->ndisks + 1;
fakedef->disks = g_new0(virDomainDiskDefPtr, fakedef->ndisks);
for (i = 0; i < backup->ndisks; i++)
fakedef->disks[i] = testCompareBackupXMLGetFakeDomdisk(backup->disks[i].name);
fakedef->disks[fakedef->ndisks -1 ] = testCompareBackupXMLGetFakeDomdisk("vdextradisk");
if (virDomainBackupAlignDisks(backup, fakedef, "SUFFIX") < 0) {
VIR_TEST_VERBOSE("failed to align backup def '%s'", file_in);
return -1;
}
if (virDomainBackupDefFormat(&buf, backup, data->internal) < 0) {
VIR_TEST_VERBOSE("failed to format backup def '%s'", file_in);
return -1;