From 5f2fa393f721861132500f717ce509bb66afcdb7 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 16 Jan 2020 12:34:13 +0100 Subject: [PATCH] util: storagefile: Properly set transport type when parsing NBD strings 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 Reported-by: Ming Xie Reviewed-by: Eric Blake Tested-by: Richard W.M. Jones --- src/util/virstoragefile.c | 2 +- tests/virstoragetest.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 90e9b6796e..a08705603a 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -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]); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 2862758752..370e19252b 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1258,6 +1258,10 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("nbd://example.org:1234", "\n" " \n" -- 2.39.5