[libvirt] [PATCH 06/10] tests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted

Peter Krempa posted 10 patches 6 years, 11 months ago
[libvirt] [PATCH 06/10] tests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted
Posted by Peter Krempa 6 years, 11 months ago
Rather than skipping output on failure fail loudly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemucapsprobemock.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c
index f26fa6b285..a0d2acb69a 100644
--- a/tests/qemucapsprobemock.c
+++ b/tests/qemucapsprobemock.c
@@ -86,9 +86,12 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,

     ret = realQemuMonitorJSONIOProcessLine(mon, line, msg);

-    if (ret == 0 &&
-        (value = virJSONValueFromString(line)) &&
-        (json = virJSONValueToString(value, 1))) {
+    if (ret == 0) {
+        if (!(value = virJSONValueFromString(line)) ||
+            !(json = virJSONValueToString(value, true))) {
+            fprintf(stderr, "Failed to reformat reply string '%s'\n", line);
+            abort();
+        }

         if (first) {
             first = false;
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/10] tests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted
Posted by John Ferlan 6 years, 11 months ago

On 06/04/2018 09:58 AM, Peter Krempa wrote:
> Rather than skipping output on failure fail loudly.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  tests/qemucapsprobemock.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

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