diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 1fc2520be1..ffc8bdb344 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2853,9 +2853,16 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src, return -1; } - /* handle socket stored as a query */ - if (uri->query) - src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket=")); + if (uri->query) { + if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP || + src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) { + src->query = g_strdup(uri->query); + } else { + /* handle socket stored as a query */ + if (STRPREFIX(uri->query, "socket=")) + src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket=")); + } + } /* uri->path is NULL if the URI does not contain slash after host: * transport://host:port */ diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 10d5421150..6e8ebeba13 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1632,7 +1632,7 @@ mymain(void) "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", - "\n" + "\n" " \n" " \n" " \n" @@ -1647,7 +1647,7 @@ mymain(void) "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", - "\n" + "\n" " \n" " \n" " \n"