[PATCH 05/10] qemu: Add support for 'tlsHostname' setting of virStorageSource

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add validation and formatting of the blockdev props.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c  |  6 +++++-
 src/qemu/qemu_domain.c | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index e5ff653a60..4195883a1e 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -843,6 +843,7 @@ qemuBlockStorageSourceGetNBDProps(virStorageSource *src,
 {
     g_autoptr(virJSONValue) serverprops = NULL;
     const char *tlsAlias = src->tlsAlias;
+    const char *tlsHostname = src->tlsHostname;
     virJSONValue *ret = NULL;

     if (src->nhosts != 1) {
@@ -856,13 +857,16 @@ qemuBlockStorageSourceGetNBDProps(virStorageSource *src,
     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;

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6b61fefb8f..ec6c17774b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4862,6 +4862,21 @@ qemuDomainValidateStorageSource(virStorageSource *src,
         }
     }

+    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;
 }

-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux