Re: [libvirt] [PATCH] util: storage: Fix parsing of 'exportname' from legacy NBD strings

2019-08-15 Thread Jiri Denemark
On Wed, Jul 31, 2019 at 17:22:48 +0200, Peter Krempa wrote:
> If the nbd export name contains a colon, our parser would not parse it
> properly as we split the string by colons. Modify the code to look up
> the exportname and copy any trailing characters as the export name is
> supposed to be at the end of the string.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1733044
> 
> Signed-off-by: Peter Krempa 
> ---
>  src/util/virstoragefile.c | 6 --
>  tests/virstoragetest.c| 8 
>  2 files changed, 12 insertions(+), 2 deletions(-)

Reviewed-by: Jiri Denemark 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] util: storage: Fix parsing of 'exportname' from legacy NBD strings

2019-08-14 Thread Peter Krempa
On Wed, Jul 31, 2019 at 17:22:48 +0200, Peter Krempa wrote:
> If the nbd export name contains a colon, our parser would not parse it
> properly as we split the string by colons. Modify the code to look up
> the exportname and copy any trailing characters as the export name is
> supposed to be at the end of the string.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1733044
> 
> Signed-off-by: Peter Krempa 
> ---
>  src/util/virstoragefile.c | 6 --
>  tests/virstoragetest.c| 8 
>  2 files changed, 12 insertions(+), 2 deletions(-)

Ping?


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] util: storage: Fix parsing of 'exportname' from legacy NBD strings

2019-07-31 Thread Peter Krempa
If the nbd export name contains a colon, our parser would not parse it
properly as we split the string by colons. Modify the code to look up
the exportname and copy any trailing characters as the export name is
supposed to be at the end of the string.

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

Signed-off-by: Peter Krempa 
---
 src/util/virstoragefile.c | 6 --
 tests/virstoragetest.c| 8 
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index a6de6a1e45..ffafeef9d8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2928,6 +2928,7 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
 virStorageSourcePtr src)
 {
 VIR_AUTOSTRINGLIST backing = NULL;
+const char *exportname;

 if (!(backing = virStringSplit(nbdstr, ":", 0)))
 return -1;
@@ -2975,8 +2976,9 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
 return -1;
 }

-if (backing[3] && STRPREFIX(backing[3], "exportname=")) {
-if (VIR_STRDUP(src->path, backing[3] + strlen("exportname=")) < 0)
+if ((exportname = strstr(nbdstr, "exportname="))) {
+exportname += strlen("exportname=");
+if (VIR_STRDUP(src->path, exportname) < 0)
 return -1;
 }

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index ef16b3c6e0..f558eea622 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -1262,6 +1262,14 @@ mymain(void)
"\n"
"  \n"
"\n");
+TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:",
+   "\n"
+   "  \n"
+   "\n");
+TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:test",
+   "\n"
+   "  \n"
+   "\n");
 TEST_BACKING_PARSE("nbd://example.org:1234",
"\n"
"  \n"
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list