]> xenbits.xensource.com Git - libvirt.git/commitdiff
backupxml2xmltest: Call 'virDomainBackupAlignDisks' before formatting output
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Jul 2020 14:38:00 +0000 (16:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 8 Jul 2020 06:40:30 +0000 (08:40 +0200)
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>
tests/domainbackupxml2xmlout/backup-pull-encrypted.xml
tests/domainbackupxml2xmlout/backup-pull-internal-invalid.xml
tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
tests/domainbackupxml2xmlout/backup-pull.xml
tests/domainbackupxml2xmlout/backup-push-encrypted.xml
tests/domainbackupxml2xmlout/backup-push-seclabel.xml
tests/domainbackupxml2xmlout/backup-push.xml
tests/domainbackupxml2xmlout/empty.xml
tests/genericxml2xmltest.c

index ea9dcf72b95da0d4d4ec48f3a28bec5d3af88036..3c3042111df689fd5119fff14f1d18ae11ba1c83 100644 (file)
@@ -26,5 +26,6 @@
         </encryption>
       </scratch>
     </disk>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index ba8f7ca3ab962036cc6c6f94f0988f024540931c..9702978ce0b7d8b30a86f1b6c90e324d01d66bfe 100644 (file)
@@ -26,6 +26,7 @@
         </encryption>
       </scratch>
     </disk>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
   <privateData>
     <objects>
index 450f007d3ade82b3b6ae6f0f5ef0d220b6566a46..38330394f7cd5a65d9308d4d3a9e248f3037b299 100644 (file)
@@ -14,5 +14,6 @@
         <seclabel model='dac' relabel='no'/>
       </scratch>
     </disk>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index 24fce9c0e7c3812c98513dffdd04847e0287edb2..4952270a5aff946c76ad80e3726be21fbdb34a2d 100644 (file)
@@ -6,5 +6,6 @@
       <scratch file='/path/to/file'/>
     </disk>
     <disk name='hda' backup='no'/>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index a95534096458e97983e50f9487e3c42d5d015291..2a5aad93cd5c780cf6bfa9a1712e13d43d97f449 100644 (file)
@@ -25,5 +25,6 @@
         </encryption>
       </target>
     </disk>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index 9986889ba3b6b485ebe2994bc230ec8ae29be3f3..59af3e6a6c9cdfaf829a114efb9d5b7b41b2705d 100644 (file)
@@ -13,5 +13,6 @@
         <seclabel model='dac' relabel='no'/>
       </target>
     </disk>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index 1997c814ae4d165e1e3597c05ec8e444afa9824d..bc11a93d94792a17553286c5345c19c203734b38 100644 (file)
@@ -6,5 +6,6 @@
       <target file='/path/to/file'/>
     </disk>
     <disk name='hda' backup='no'/>
+    <disk name='vdextradisk' backup='no'/>
   </disks>
 </domainbackup>
index b1ba4953be212fa5b0b85688d865391acdc72126..52d2b4f0af50c247f3e852df29c8ad151b25052f 100644 (file)
@@ -1 +1,7 @@
-<domainbackup mode='push'/>
+<domainbackup mode='push'>
+  <disks>
+    <disk name='vdextradisk' backup='yes' type='file'>
+      <target file='/fake/vdextradisk.qcow2.SUFFIX'/>
+    </disk>
+  </disks>
+</domainbackup>
index 2c1e8616ddc86923b636ad2d7d3400dfb5d08822..8b9b0bafb6b45f9993a05b1591f7f7049f74a5e7 100644 (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;