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
---
.../qemuargv2xml-disk-drive-network-iscsi-auth.xml | 2 +-
.../qemuargv2xml-disk-drive-network-rbd-auth.xml | 2 +-
tests/qemuargv2xmltest.c | 15 ++++++++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi-auth.xml
b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi-auth.xml
index 5ac4abf..35b3abc 100644
--- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi-auth.xml
+++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi-auth.xml
@@ -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'/>
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-rbd-auth.xml
b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-rbd-auth.xml
index ac2e942..4db031b 100644
--- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-rbd-auth.xml
+++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-rbd-auth.xml
@@ -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'/>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 6650cf0..8e0e711 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -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;
--
2.5.0