From: Ashish Mittal <Ashish.Mittal(a)veritas.com>
Add a test case to verify TLS arguments are parsed correctly for
a VxHS disk. This includes saving off a found tls-creds into the
storage source @tlsAlias field since that's what's used to link
the TLS object for the authentication credentials and the disk.
Test case verifies that XML is generated correctly for a VxHS disk
having TLS enabled.
Signed-off-by: Ashish Mittal <Ashish.Mittal(a)veritas.com>
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/util/virstoragefile.c | 9 +++++++++
tests/virstoragetest.c | 12 ++++++++++++
2 files changed, 21 insertions(+)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 9cd648d36..1fcd7a028 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3225,6 +3225,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src,
{
const char *vdisk_id = virJSONValueObjectGetString(json, "vdisk-id");
virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
+ const char *haveTLS = virJSONValueObjectGetString(json, "tls-creds");
if (!vdisk_id || !server) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -3243,6 +3244,14 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src,
return -1;
src->nhosts = 1;
+ if (haveTLS) {
+ VIR_FREE(src->tlsAlias);
+ if (VIR_STRDUP(src->tlsAlias, haveTLS) < 0)
+ return -1;
+
+ src->haveTLS = VIR_TRISTATE_BOOL_YES;
+ }
+
if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts,
server) < 0)
return -1;
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index ffebd4dc1..75ad6330b 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -1603,6 +1603,18 @@ mymain(void)
"<source protocol='vxhs'
name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n"
" <host name='example.com'
port='9999'/>\n"
"</source>\n");
+
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\","
+
"\"vdisk-id\":\"c6718f6b-0401-441d-a8c3-1f0064d75ee0\","
+ "\"server\": {
\"type\":\"tcp\","
+
"\"host\":\"example.com\","
+
"\"port\":\"9999\""
+ "},"
+
"\"tls-creds\":\"objvirtio-disk0_tls0\""
+ "}"
+ "}",
+ "<source protocol='vxhs'
name='c6718f6b-0401-441d-a8c3-1f0064d75ee0' tls='yes'>\n"
+ " <host name='example.com'
port='9999'/>\n"
+ "</source>\n");
#endif /* WITH_YAJL */
cleanup:
--
2.13.5