Re: [libvirt] [PATCH 09/14] util: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue

2019-08-26 Thread Ján Tomko

On Wed, Aug 21, 2019 at 05:11:38PM +0200, Ján Tomko wrote:

On Fri, Aug 16, 2019 at 12:39:30PM +0200, Peter Krempa wrote:

Return the parsed storage source via an pointer in arguments and return
an integer from the function. Describe the semantics with a comment for
the function and adjust callers to the new semantics.

Signed-off-by: Peter Krempa 
---
src/util/virstoragefile.c | 43 ---
src/util/virstoragefile.h |  3 ++-
tests/qemublocktest.c |  3 ++-
tests/virstoragetest.c|  2 +-
4 files changed, 32 insertions(+), 19 deletions(-)



This should've said:

Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH 09/14] util: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue

2019-08-21 Thread Ján Tomko

On Fri, Aug 16, 2019 at 12:39:30PM +0200, Peter Krempa wrote:

Return the parsed storage source via an pointer in arguments and return
an integer from the function. Describe the semantics with a comment for
the function and adjust callers to the new semantics.

Signed-off-by: Peter Krempa 
---
src/util/virstoragefile.c | 43 ---
src/util/virstoragefile.h |  3 ++-
tests/qemublocktest.c |  3 ++-
tests/virstoragetest.c|  2 +-
4 files changed, 32 insertions(+), 19 deletions(-)



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

[libvirt] [PATCH 09/14] util: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue

2019-08-16 Thread Peter Krempa
Return the parsed storage source via an pointer in arguments and return
an integer from the function. Describe the semantics with a comment for
the function and adjust callers to the new semantics.

Signed-off-by: Peter Krempa 
---
 src/util/virstoragefile.c | 43 ---
 src/util/virstoragefile.h |  3 ++-
 tests/qemublocktest.c |  3 ++-
 tests/virstoragetest.c|  2 +-
 4 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 192a79c025..8447c014f0 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3633,22 +3633,32 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr 
src,
 }


-virStorageSourcePtr
-virStorageSourceNewFromBackingAbsolute(const char *path)
+/**
+ * virStorageSourceNewFromBackingAbsolute
+ * @path: string representing absolute location of a storage source
+ * @src: filled with virStorageSource object representing @path
+ *
+ * Returns 0 on success and fills @src or -1 on error and reports appropriate
+ * error.
+ */
+int
+virStorageSourceNewFromBackingAbsolute(const char *path,
+   virStorageSourcePtr *src)
 {
 const char *json;
-virStorageSourcePtr ret = NULL;
 int rc;
 VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;

+*src = NULL;
+
 if (!(def = virStorageSourceNew()))
-return NULL;
+return -1;

 if (virStorageIsFile(path)) {
 def->type = VIR_STORAGE_TYPE_FILE;

 if (VIR_STRDUP(def->path, path) < 0)
-return NULL;
+return -1;
 } else {
 def->type = VIR_STORAGE_TYPE_NETWORK;

@@ -3663,7 +3673,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
 rc = virStorageSourceParseBackingColon(def, path);

 if (rc < 0)
-return NULL;
+return -1;

 virStorageSourceNetworkAssignDefaultPorts(def);

@@ -3676,8 +3686,8 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
 }
 }

-VIR_STEAL_PTR(ret, def);
-return ret;
+VIR_STEAL_PTR(*src, def);
+return 0;
 }


@@ -3702,14 +3712,15 @@ virStorageSourceNewFromBacking(virStorageSourcePtr 
parent,

 *backing = NULL;

-if (virStorageIsRelative(parent->backingStoreRaw))
-def = virStorageSourceNewFromBackingRelative(parent,
- parent->backingStoreRaw);
-else
-def = virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw);
-
-if (!def)
-return -1;
+if (virStorageIsRelative(parent->backingStoreRaw)) {
+if (!(def = virStorageSourceNewFromBackingRelative(parent,
+   
parent->backingStoreRaw)))
+return -1;
+} else {
+if (virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw,
+   ) < 0)
+return -1;
+}

 /* possibly update local type */
 if (def->type == VIR_STORAGE_TYPE_FILE) {
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 3a72c62ad7..2cceaf6954 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -473,7 +473,8 @@ int 
virStorageFileGetRelativeBackingPath(virStorageSourcePtr from,

 int virStorageFileCheckCompat(const char *compat);

-virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *path);
+int virStorageSourceNewFromBackingAbsolute(const char *path,
+   virStorageSourcePtr *src);

 bool virStorageSourceIsRelative(virStorageSourcePtr src);

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 9321531f6c..e5d77c423c 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -85,7 +85,8 @@ testBackingXMLjsonXML(const void *args)
 if (virAsprintf(, "json:%s", propsstr) < 0)
 return -1;

-if (!(jsonsrc = virStorageSourceNewFromBackingAbsolute(protocolwrapper))) {
+if (virStorageSourceNewFromBackingAbsolute(protocolwrapper,
+   ) < 0) {
 fprintf(stderr, "failed to parse disk json\n");
 return -1;
 }
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 1c7ba466f1..0495308318 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -613,7 +613,7 @@ testBackingParse(const void *args)
 VIR_AUTOFREE(char *) xml = NULL;
 VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;

-if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
+if (virStorageSourceNewFromBackingAbsolute(data->backing, ) < 0) {
 if (!data->expect)
 return 0;
 else
-- 
2.21.0

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