]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Add JSON props generator for sheepdog storage backing
authorPeter Krempa <pkrempa@redhat.com>
Mon, 23 Oct 2017 16:44:35 +0000 (18:44 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 7 Nov 2017 15:12:52 +0000 (16:12 +0100)
src/qemu/qemu_block.c

index 83e048efe5a96893ee72ef3ba1b3e892966b9f42..5932c30c32053217be064197eac57f274811e79a 100644 (file)
@@ -873,6 +873,33 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src)
 }
 
 
+static virJSONValuePtr
+qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
+{
+    virJSONValuePtr serverprops;
+    virJSONValuePtr ret = NULL;
+
+    if (src->nhosts != 1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("sheepdog protocol accepts only one host"));
+        return NULL;
+    }
+
+    serverprops = qemuBlockStorageSourceBuildJSONSocketAddress(&src->hosts[0],
+                                                               false);
+    if (!serverprops)
+        return NULL;
+
+    /* libvirt does not support the 'snap-id' and 'tag' properties */
+    ignore_value(virJSONValueObjectCreate(&ret,
+                                          "s:driver", "sheepdog",
+                                          "a:server", serverprops,
+                                          "s:vdi", src->path,
+                                          NULL));
+
+    return ret;
+}
+
 /**
  * qemuBlockStorageSourceGetBackendProps:
  * @src: disk source
@@ -938,6 +965,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
             break;
 
         case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
+            if (!(fileprops = qemuBlockStorageSourceGetSheepdogProps(src)))
+                return NULL;
+            break;
+
         case VIR_STORAGE_NET_PROTOCOL_SSH:
         case VIR_STORAGE_NET_PROTOCOL_NONE:
         case VIR_STORAGE_NET_PROTOCOL_LAST: