]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storagefile: Properly set transport type when parsing NBD strings
authorPeter Krempa <pkrempa@redhat.com>
Thu, 16 Jan 2020 11:34:13 +0000 (12:34 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 17 Jan 2020 11:34:10 +0000 (12:34 +0100)
When parsing legacy NBD backing file strings such as
'nbd:unix:/tmp/sock:exportname=/' we'd fail to set the transport to
VIR_STORAGE_NET_HOST_TRANS_UNIX. This started to be a problem once we
actually started to generate config of the backing store on the command
line with -blockdev as the JSON code would try to format it as TCP and
fail with:

 internal error: argument key 'host' must not have null value

Set the type properly and add a test.

This bug was found by the libguestfs test suite in:

https://bugzilla.redhat.com/show_bug.cgi?id=1791614

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reported-by: Ming Xie <mxie@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
src/util/virstoragefile.c
tests/virstoragetest.c

index 90e9b6796e2f0ad15ec26230b85151fa1a1acaea..a08705603adab6a04943203cf7b18cde4c676c85 100644 (file)
@@ -2964,7 +2964,7 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
         }
 
         src->hosts->socket = g_strdup(backing[2]);
-
+        src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
    } else {
         src->hosts->name = g_strdup(backing[1]);
 
index 2862758752f00842cd7fa4a67e79d74adcef2353..370e19252bbb7ff1ef2349f5989f64df9658ab56 100644 (file)
@@ -1258,6 +1258,10 @@ mymain(void)
                        "<source protocol='nbd' name=':test'>\n"
                        "  <host name='example.org' port='6000'/>\n"
                        "</source>\n");
+    TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/",
+                       "<source protocol='nbd' name='/'>\n"
+                       "  <host transport='unix' socket='/tmp/sock'/>\n"
+                       "</source>\n");
     TEST_BACKING_PARSE("nbd://example.org:1234",
                        "<source protocol='nbd'>\n"
                        "  <host name='example.org' port='1234'/>\n"