Add validation and formatting of the blockdev props.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
{
g_autoptr(virJSONValue) serverprops = NULL;
const char *tlsAlias = src->tlsAlias;
+ const char *tlsHostname = src->tlsHostname;
virJSONValue *ret = NULL;
if (src->nhosts != 1) {
if (!serverprops)
return NULL;
- if (onlytarget)
+ if (onlytarget) {
tlsAlias = NULL;
+ tlsHostname = NULL;
+ }
if (virJSONValueObjectAdd(&ret,
"a:server", &serverprops,
"S:export", src->path,
"S:tls-creds", tlsAlias,
+ "S:tls-hostname", tlsHostname,
NULL) < 0)
return NULL;
}
}
+ if (src->tlsHostname) {
+ if (actualType != VIR_STORAGE_TYPE_NETWORK ||
+ src->protocol != VIR_STORAGE_NET_PROTOCOL_NBD) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'tlsHostname' field is supported only with NBD disks"));
+ return -1;
+ }
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_NBD_TLS_HOSTNAME)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'tlsHostname' field is not supported by this QEMU"));
+ return -1;
+ }
+ }
+
return 0;
}