[PATCH 10/12] qemu: block: Add JSON props generator for ssh storage backing

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

 



---
 src/qemu/qemu_block.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 5f28c4dd6..6f6d294bf 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -892,6 +892,38 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
     return ret;
 }

+
+static virJSONValuePtr
+qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src)
+{
+    virJSONValuePtr serverprops;
+    virJSONValuePtr ret = NULL;
+    const char *username = NULL;
+
+    if (src->nhosts != 1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("sheepdog protocol accepts only one host"));
+        return NULL;
+    }
+
+    serverprops = qemuBlockStorageSourceBuildJSONInetSocketAddress(&src->hosts[0]);
+    if (!serverprops)
+        return NULL;
+
+    if (src->auth)
+        username = src->auth->username;
+
+    ignore_value(virJSONValueObjectCreate(&ret,
+                                          "s:driver", "ssh",
+                                          "s:path", src->path,
+                                          "a:server", serverprops,
+                                          "S:user", username,
+                                          NULL));
+
+    return ret;
+}
+
+
 /**
  * qemuBlockStorageSourceGetBackendProps:
  * @src: disk source
@@ -962,6 +994,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
             break;

         case VIR_STORAGE_NET_PROTOCOL_SSH:
+            if (!(fileprops = qemuBlockStorageSourceGetSshProps(src)))
+                return NULL;
+            break;
+
         case VIR_STORAGE_NET_PROTOCOL_NONE:
         case VIR_STORAGE_NET_PROTOCOL_LAST:
             break;
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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