/**
* qemuBlockStorageSourceBuildJSONSocketAddress
* @host: the virStorageNetHostDefPtr definition to build
- * @legacy: use 'tcp' instead of 'inet' for compatibility reasons
+ * @legacy: use old field names/values
*
* Formats @hosts into a json object conforming to the 'SocketAddress' type
* in qemu.
*
+ * For compatibility with old approach used in the gluster driver of old qemus
+ * use the old spelling for TCP transport and, the path field of the unix socket.
+ *
* Returns a virJSONValuePtr for a single server.
*/
static virJSONValuePtr
virJSONValuePtr server = NULL;
virJSONValuePtr ret = NULL;
const char *transport;
+ const char *field;
char *port = NULL;
switch ((virStorageNetHostTransport) host->transport) {
break;
case VIR_STORAGE_NET_HOST_TRANS_UNIX:
+ if (legacy)
+ field = "s:socket";
+ else
+ field = "s:path";
+
if (virJSONValueObjectCreate(&server,
"s:type", "unix",
- "s:socket", host->socket,
+ field, host->socket,
NULL) < 0)
goto cleanup;
break;
} else if (STREQ(type, "unix")) {
host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
- if (!(socket = virJSONValueObjectGetString(json, "socket"))) {
+ socket = virJSONValueObjectGetString(json, "path");
+
+ /* check for old spelling for gluster protocol */
+ if (!socket)
+ socket = virJSONValueObjectGetString(json, "socket");
+
+ if (!socket) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("missing socket path for udp backing server in "
"JSON backing volume definition"));