提交 73ed1d74 编写于 作者: C Cole Robinson

tests: qemuargv2xml: hardcode disk auth usage

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
上级 b25027ba
......@@ -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'/>
......
......@@ -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'/>
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册