]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemuargv2xml: hardcode disk auth usage
authorCole Robinson <crobinso@redhat.com>
Tue, 16 Feb 2016 16:49:07 +0000 (11:49 -0500)
committerCole Robinson <crobinso@redhat.com>
Wed, 17 Feb 2016 16:07:21 +0000 (11:07 -0500)
If a qemuargv has iscsi or ceph secrets on the command line, we will
convert that to XML like:

  <auth username='myname'>
    <secret type='iscsi'/>
  </auth>

This is not valid XML, as either a UUID or usage must be specified in
the secret block. It's not clear though how the argv2xml code can do
anything correct here, since XML like this requires a libvirt secret
object to have already been defined.

The current test suite handles this by blanking out any <secret> block
in the XML. This avoids domainschematest failures.

Instead of blanking, let's hardcode a usage= name. This lets us test
the other bits of generated <secret> XML, and is a step towards wiring
up VIR_TEST_REGENERATE_OUTPUT

tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi-auth.xml
tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-rbd-auth.xml
tests/qemuargv2xmltest.c

index 5ac4abfdb26f3bd0e112a22ef4a27a3c98d7ff59..35b3abc5073448f51eca3afd779da26cb75ec07f 100644 (file)
@@ -17,7 +17,7 @@
     <disk type='network' device='disk'>
       <driver name='qemu' type='raw'/>
       <auth username='myname'>
-        <secret type='iscsi' usage='mycluster_myname'/>
+        <secret type='iscsi' usage='qemuargv2xml_usage'/>
       </auth>
       <source protocol='iscsi' name='iqn.1992-01.com.example'>
         <host name='example.org' port='6000'/>
index ac2e942090c64769b328dc4159bd645bb21838a6..4db031b70bac2950872c508d3fc9d8471bbfb9df 100644 (file)
@@ -23,7 +23,7 @@
     <disk type='network' device='disk'>
       <driver name='qemu' type='raw'/>
       <auth username='myname'>
-        <secret type='ceph' usage='mycluster_myname'/>
+        <secret type='ceph' usage='qemuargv2xml_usage'/>
       </auth>
       <source protocol='rbd' name='pool/image'>
         <host name='mon1.example.org' port='6321'/>
index 6650cf0344d5cd6d4be6244674b5f9e8f46ba650..8e0e71100d014f4aa74747e7ebd80e3ab8d72e96 100644 (file)
@@ -24,7 +24,6 @@ static virQEMUDriver driver;
 static int blankProblemElements(char *data)
 {
     if (virtTestClearLineRegex("<memory.*>[[:digit:]]+</memory>", data) < 0 ||
-        virtTestClearLineRegex("<secret.*>", data) < 0 ||
         virtTestClearLineRegex("<currentMemory.*>[[:digit:]]+</currentMemory>",
                                data) < 0)
         return -1;
@@ -33,12 +32,26 @@ static int blankProblemElements(char *data)
 
 static int testSanitizeDef(virDomainDefPtr vmdef)
 {
+    size_t i = 0;
     int ret = -1;
 
     /* Remove UUID randomness */
     if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", vmdef->uuid) < 0)
         goto fail;
 
+    /* qemuargv2xml doesn't know what to set for a secret usage/uuid,
+     * so hardcode usage='qemuargv2xml_usage' to appead the schema checker */
+    for (i = 0; i < vmdef->ndisks; i++) {
+        virDomainDiskDefPtr disk = vmdef->disks[i];
+
+        if (disk->src->auth) {
+            disk->src->auth->secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
+            if (VIR_STRDUP(disk->src->auth->secret.usage,
+                          "qemuargv2xml_usage") < 0)
+                goto fail;
+        }
+    }
+
     ret = 0;
  fail:
     return ret;