Displaying 17 results from an estimated 17 matches for "json_t".
2018 Aug 20
0
[PATCH 4/4] mltools: JSON: unify JSON_parser type with JSON.json_t.
.....c7631636c 100644
--- a/builder/utils.mli
+++ b/builder/utils.mli
@@ -29,7 +29,7 @@ and revision =
val string_of_revision : revision -> string
(** Convert a {!revision} into a string. *)
-val get_image_infos : string -> JSON_parser.json_parser_val
+val get_image_infos : string -> JSON.json_t
(** [get_image_infos path] Run qemu-img info on the image pointed at
path as JSON tree. *)
diff --git a/common/mltools/JSON_parser-c.c b/common/mltools/JSON_parser-c.c
index 32432dc5b..dce9f6a15 100644
--- a/common/mltools/JSON_parser-c.c
+++ b/common/mltools/JSON_parser-c.c
@@ -28,7 +28,12...
2018 Feb 12
0
[PATCH v2 1/1] Switch from YAJL to Jansson
...-#if defined(__GNUC__) && __GNUC__ >= 6 /* gcc >= 6 */
-#pragma GCC diagnostic ignored "-Wnull-dereference"
-#endif
-
#define Val_none (Val_int (0))
value virt_builder_yajl_tree_parse (value stringv);
static value
-convert_yajl_value (yajl_val val, int level)
+convert_json_t (json_t *val, int level)
{
CAMLparam0 ();
CAMLlocal4 (rv, lv, v, sv);
@@ -48,46 +41,51 @@ convert_yajl_value (yajl_val val, int level)
if (level > 20)
caml_invalid_argument ("too many levels of object/array nesting");
- if (YAJL_IS_OBJECT (val)) {
- const size_t le...
2018 Aug 22
3
Re: [PATCH 4/4] mltools: JSON: unify JSON_parser type with JSON.json_t.
...which is better than crashing /
> + * throwing an error.
> + */
> + rv = caml_alloc (1, JSON_STRING_TAG);
> + v = caml_copy_string ("");
> + Store_field (rv, 0, v);
> + }
NACK, this is not correct. null is a proper type of value in JSON, and
thus JSON.json_t must represent it as well.
This is even used in other parts, for example the check of backing
files of disks (see guestfs_impl_disk_has_backing_file).
--
Pino Toscano
2017 Nov 23
0
[PATCH 1/1] Switch from YAJL to Jansson
...-#if defined(__GNUC__) && __GNUC__ >= 6 /* gcc >= 6 */
-#pragma GCC diagnostic ignored "-Wnull-dereference"
-#endif
-
#define Val_none (Val_int (0))
value virt_builder_yajl_tree_parse (value stringv);
static value
-convert_yajl_value (yajl_val val, int level)
+convert_json_t (json_t *val, int level)
{
CAMLparam0 ();
CAMLlocal4 (rv, lv, v, sv);
@@ -48,46 +41,51 @@ convert_yajl_value (yajl_val val, int level)
if (level > 20)
caml_invalid_argument ("too many levels of object/array nesting");
- if (YAJL_IS_OBJECT (val)) {
- const size_t le...
2018 Aug 22
3
[PATCH v2 0/2] mltools: JSON: unify JSON & JSON parser.
v2:
- Added back the null value.
- Reran the tests.
Rich.
2018 Feb 12
2
[PATCH v2 0/1] RFC: switch from YAJL to Jansson
Hi,
recently, there was a discussion in the development list of libvirt on
switching to a different JSON library than YAJL [1]. Since we use YAJL,
and the points there IMHO apply to libguestfs as well, I decided to give
a try in switching to Jansson [2].
The result IMHO is nice, with the additional APIs of Jansson that
simplify some of our code. Unlike with YAJL, I did not set a minimum
2017 Nov 23
4
[PATCH 0/1] RFC: switch from YAJL to Jansson
Hi,
recently, there was a discussion in the development list of libvirt on
switching to a different JSON library than YAJL [1]. Since we use YAJL,
and the points there IMHO apply to libguestfs as well, I decided to give
a try in switching to Jansson [2].
The result IMHO is nice, with the additional APIs of Jansson that
simplify some of our code. Unlike with YAJL, I did not set a minimum
2018 Aug 22
0
Re: [PATCH 4/4] mltools: JSON: unify JSON_parser type with JSON.json_t.
...* throwing an error.
> > + */
> > + rv = caml_alloc (1, JSON_STRING_TAG);
> > + v = caml_copy_string ("");
> > + Store_field (rv, 0, v);
> > + }
>
> NACK, this is not correct. null is a proper type of value in JSON, and
> thus JSON.json_t must represent it as well.
>
> This is even used in other parts, for example the check of backing
> files of disks (see guestfs_impl_disk_has_backing_file).
Can you explain more about what a "null" JSON document looks like?
Rich.
--
Richard Jones, Virtualization Group, Red H...
2018 Aug 23
2
[PATCH 1/2] mltools: JSON: add json_parser_tree_parse_file
...e10a2b69d..be1f011d1 100644
--- a/common/mltools/JSON_parser-c.c
+++ b/common/mltools/JSON_parser-c.c
@@ -37,6 +37,7 @@
#define JSON_DICT_TAG 5
value virt_builder_json_parser_tree_parse (value stringv);
+value virt_builder_json_parser_tree_parse_file (value stringv);
static value
convert_json_t (json_t *val, int level)
@@ -142,3 +143,27 @@ virt_builder_json_parser_tree_parse (value stringv)
CAMLreturn (rv);
}
+
+value
+virt_builder_json_parser_tree_parse_file (value filev)
+{
+ CAMLparam1 (filev);
+ CAMLlocal1 (rv);
+ json_t *tree;
+ json_error_t err;
+
+ tree = json_load_file...
2014 Oct 10
4
[PATCH 1/3] Move JSON to mllib
...ceived a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(* Poor man's JSON generator. *)
+
+open Printf
+
+open Common_utils
+
+type field = string * json_t
+and json_t = String of string | Int of int
+and doc = field list
+
+(* JSON quoting. *)
+let json_quote str =
+ let str = replace_str str "\\" "\\\\" in
+ let str = replace_str str "\"" "\\\"" in
+ let str = replace_str str "'" &qu...
2018 Aug 20
6
[PATCH 0/4] mltools: JSON unification
An evolution of:
https://www.redhat.com/archives/libguestfs/2018-August/msg00155.html
2018 Sep 13
1
[PATCH] lib: direct: Query qemu binary for availability of KVM (RHBZ#1605071).
...h *g, void *datav, int check_for_errors)
{
diff --git a/lib/qemu.c b/lib/qemu.c
index 3e7f15946..212cda963 100644
--- a/lib/qemu.c
+++ b/lib/qemu.c
@@ -46,6 +46,19 @@
#include "guestfs-internal.h"
#include "guestfs_protocol.h"
+#ifdef HAVE_ATTRIBUTE_CLEANUP
+#define CLEANUP_JSON_T_DECREF __attribute__((cleanup(cleanup_json_t_decref)))
+
+static void
+cleanup_json_t_decref (void *ptr)
+{
+ json_decref (* (json_t **) ptr);
+}
+
+#else
+#define CLEANUP_JSON_T_DECREF
+#endif
+
struct qemu_data {
int generation; /* MEMO_GENERATION read from qemu.stat */
uint...
2017 Nov 23
1
Re: [PATCH 1/1] Switch from YAJL to Jansson
...;jansson.h>
>
> #include "guestfs.h"
> #include "guestfs-internal.h"
> #include "guestfs-internal-actions.h"
>
> #ifdef HAVE_ATTRIBUTE_CLEANUP
>-#define CLEANUP_YAJL_TREE_FREE __attribute__((cleanup(cleanup_yajl_tree_free)))
>+#define CLEANUP_JSON_T_DECREF __attribute__((cleanup(cleanup_json_t_decref)))
>
> static void
>-cleanup_yajl_tree_free (void *ptr)
>+cleanup_json_t_decref (void *ptr)
> {
>- yajl_tree_free (* (yajl_val *) ptr);
>+ json_decref (* (json_t **) ptr);
> }
>
Looks like you don't need to do thi...
2018 Sep 21
4
[PATCH v2] lib: Use qemu-img info -U option to avoid locking error.
...>qemu_img_supports_U_option = -1; /* not tested, see lib/info.c */
+
/* Start with large serial numbers so they are easy to spot
* inside the protocol.
*/
diff --git a/lib/info.c b/lib/info.c
index 2eadc1c11..74e4424b8 100644
--- a/lib/info.c
+++ b/lib/info.c
@@ -57,6 +57,7 @@ cleanup_json_t_decref (void *ptr)
#endif
static json_t *get_json_output (guestfs_h *g, const char *filename);
+static int qemu_img_supports_U_option (guestfs_h *g);
static void set_child_rlimits (struct command *);
char *
@@ -149,6 +150,11 @@ get_json_output (guestfs_h *g, const char *filename)
guest...
2018 Oct 02
0
Re: [PATCH v2] lib: Use qemu-img info -U option to avoid locking error.
...ested, see lib/info.c */
> +
> /* Start with large serial numbers so they are easy to spot
> * inside the protocol.
> */
> diff --git a/lib/info.c b/lib/info.c
> index 2eadc1c11..74e4424b8 100644
> --- a/lib/info.c
> +++ b/lib/info.c
> @@ -57,6 +57,7 @@ cleanup_json_t_decref (void *ptr)
> #endif
>
> static json_t *get_json_output (guestfs_h *g, const char *filename);
> +static int qemu_img_supports_U_option (guestfs_h *g);
> static void set_child_rlimits (struct command *);
>
> char *
> @@ -149,6 +150,11 @@ get_json_output (guestfs_h...
2018 Aug 17
0
[PATCH v3 1/4] mltools: Rename Yajl module as JSON_parser and move to common/mltools.
....gitignore
@@ -113,7 +113,6 @@ Makefile.in
/builder/virt-index-validate
/builder/virt-index-validate.1
/builder/*.xz
-/builder/yajl_tests
/cat/stamp-virt-*.pod
/cat/virt-cat
/cat/virt-cat.1
@@ -146,6 +145,7 @@ Makefile.in
/common/mltools/.depend
/common/mltools/getopt_tests
/common/mltools/JSON_tests
+/common/mltools/JSON_parser_tests
/common/mltools/tools_utils_tests
/common/mltools/oUnit-*
/common/mlutils/.depend
diff --git a/builder/Makefile.am b/builder/Makefile.am
index 7ede544b7..f64750c7f 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -45,8 +45,7 @@ EXTRA_DIST = \...
2018 Aug 17
8
[PATCH v3 4/4] v2v: Add --print-estimate option to print copy size
I rethought this again, as I think that it's a dangerous assumption to
bake qemu-img measure output into our API.
This patch series runs qemu-img measure behind the scenes, but then
parses the output and sums it to a single number which we print.
Doing that required a bit of reworking, moving the Jansson [JSON
parser] bindings from virt-builder into the common directory and
a couple of other