]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: Add support for type 'inet' in virStorageSourceParseBackingJSONSocketA...
authorPeter Krempa <pkrempa@redhat.com>
Mon, 19 Jun 2017 12:37:47 +0000 (14:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 20 Jun 2017 06:40:18 +0000 (08:40 +0200)
'SocketAddress' structure was changed to contain 'inet' instead of
'tcp' since qemu commit c5f1ae3ae7b. Existing entries have a backward
compatibility layer.

Libvirt will parse 'inet' and 'tcp' as equivalents.

src/util/virstoragefile.c
tests/virstoragetest.c

index 92bc561a27e5624042c480913da00ae84734065d..7f2a50fd16f77979b4836ebc5a683f37a4e85813 100644 (file)
@@ -2802,18 +2802,17 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
     const char *hostname = virJSONValueObjectGetString(json, "host");
     const char *port = virJSONValueObjectGetString(json, "port");
     const char *socket = virJSONValueObjectGetString(json, "socket");
-    int transport;
 
-    if ((transport = virStorageNetHostTransportTypeFromString(type)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unknown backing store transport protocol '%s'"), type);
+    if (!type) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("missing socket address type in "
+                         "JSON backing volume definition"));
         return -1;
     }
 
-    host->transport = transport;
+    if (STREQ(type, "tcp") || STREQ(type, "inet")) {
+        host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
 
-    switch ((virStorageNetHostTransport) transport) {
-    case VIR_STORAGE_NET_HOST_TRANS_TCP:
         if (!hostname) {
             virReportError(VIR_ERR_INVALID_ARG, "%s",
                            _("missing hostname for tcp backing server in "
@@ -2824,9 +2823,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
         if (VIR_STRDUP(host->name, hostname) < 0 ||
             VIR_STRDUP(host->port, port) < 0)
             return -1;
-        break;
+    } else if (STREQ(type, "unix")) {
+        host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
 
-    case VIR_STORAGE_NET_HOST_TRANS_UNIX:
         if (!socket) {
             virReportError(VIR_ERR_INVALID_ARG, "%s",
                            _("missing socket path for udp backing server in "
@@ -2834,13 +2833,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
             return -1;
         }
 
-
         if (VIR_STRDUP(host->socket, socket) < 0)
             return -1;
-        break;
-
-    case VIR_STORAGE_NET_HOST_TRANS_RDMA:
-    case VIR_STORAGE_NET_HOST_TRANS_LAST:
+    } else {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("backing store protocol '%s' is not yet supported"),
                        type);
index 70e24a1b70db33971dc53b9d43d2e4b4987932f9..11720828934e01e03d62a83295d2b4dd8d1776a8 100644 (file)
@@ -1431,7 +1431,7 @@ mymain(void)
                                                "{ \"type\":\"unix\","
                                                  "\"socket\":\"/path/socket\""
                                                "},"
-                                               "{ \"type\":\"tcp\","
+                                               "{ \"type\":\"inet\","
                                                  "\"host\":\"example.com\""
                                                "}"
                                              "]"