Blame SOURCES/libvirt-util-storagefile-Properly-set-transport-type-when-parsing-NBD-strings.patch

a41c76
From c8d5d7684ae855f75e3bba3f72b5b3f973ccdea2 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <c8d5d7684ae855f75e3bba3f72b5b3f973ccdea2@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Fri, 17 Jan 2020 13:16:57 +0100
a41c76
Subject: [PATCH] util: storagefile: Properly set transport type when parsing
a41c76
 NBD strings
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
When parsing legacy NBD backing file strings such as
a41c76
'nbd:unix:/tmp/sock:exportname=/' we'd fail to set the transport to
a41c76
VIR_STORAGE_NET_HOST_TRANS_UNIX. This started to be a problem once we
a41c76
actually started to generate config of the backing store on the command
a41c76
line with -blockdev as the JSON code would try to format it as TCP and
a41c76
fail with:
a41c76
a41c76
 internal error: argument key 'host' must not have null value
a41c76
a41c76
Set the type properly and add a test.
a41c76
a41c76
This bug was found by the libguestfs test suite in:
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1791614
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reported-by: Ming Xie <mxie@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
Tested-by: Richard W.M. Jones <rjones@redhat.com>
a41c76
(cherry picked from commit 5f2fa393f721861132500f717ce509bb66afcdb7)
a41c76
Message-Id: <79e24a6416d5bfbba6cdb2764b29663c2f8ccd45.1579263320.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
a41c76
---
a41c76
 src/util/virstoragefile.c | 2 +-
a41c76
 tests/virstoragetest.c    | 4 ++++
a41c76
 2 files changed, 5 insertions(+), 1 deletion(-)
a41c76
a41c76
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
a41c76
index 1397f532fd..7a2af0ad94 100644
a41c76
--- a/src/util/virstoragefile.c
a41c76
+++ b/src/util/virstoragefile.c
a41c76
@@ -2964,7 +2964,7 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
a41c76
         }
a41c76
 
a41c76
         src->hosts->socket = g_strdup(backing[2]);
a41c76
-
a41c76
+        src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
a41c76
    } else {
a41c76
         src->hosts->name = g_strdup(backing[1]);
a41c76
 
a41c76
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
a41c76
index 2862758752..370e19252b 100644
a41c76
--- a/tests/virstoragetest.c
a41c76
+++ b/tests/virstoragetest.c
a41c76
@@ -1258,6 +1258,10 @@ mymain(void)
a41c76
                        "<source protocol='nbd' name=':test'>\n"
a41c76
                        "  <host name='example.org' port='6000'/>\n"
a41c76
                        "</source>\n");
a41c76
+    TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/",
a41c76
+                       "<source protocol='nbd' name='/'>\n"
a41c76
+                       "  <host transport='unix' socket='/tmp/sock'/>\n"
a41c76
+                       "</source>\n");
a41c76
     TEST_BACKING_PARSE("nbd://example.org:1234",
a41c76
                        "<source protocol='nbd'>\n"
a41c76
                        "  <host name='example.org' port='1234'/>\n"
a41c76
-- 
a41c76
2.25.0
a41c76