]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: add is_default checkers for string and timer_mode types
authorRoger Pau Monne <roger.pau@citrix.com>
Fri, 22 Dec 2017 16:32:19 +0000 (16:32 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 12 Jan 2018 15:40:50 +0000 (15:40 +0000)
Those types are missing a helper to check whether a definition of the
type holds the default value. This will be required by a later patch
that will implement deprecation of fields inside of a libxl type.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Rebased over changes to libxl_internal.h

tools/libxl/idl.py
tools/libxl/libxl_internal.h
tools/libxl/libxl_types.idl

index 437049ebb9bded14f948880f98571ba99dfba924..a4a084e1ce84442bbb6b7e936a52e7b1e1a5d698 100644 (file)
@@ -302,7 +302,8 @@ string = Builtin("char *", namespace = None, copy_fn = "libxl_string_copy", disp
                  json_gen_fn = "libxl__string_gen_json",
                  json_parse_type = "JSON_STRING | JSON_NULL",
                  json_parse_fn = "libxl__string_parse_json",
-                 autogenerate_json = False)
+                 autogenerate_json = False,
+                 check_default_fn="libxl__string_is_default")
 
 class Array(Type):
     """An array of the same type"""
index 8366fee25f048cde6bab9f482efd31420c20f4b0..60f012be8ab9ce96d3631ce3e81182f296a8d074 100644 (file)
@@ -4303,6 +4303,16 @@ static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info
     return libxl_defbool_val(b_info->acpi) &&
            libxl_defbool_val(b_info->u.hvm.acpi);
 }
+
+static inline bool libxl__timer_mode_is_default(libxl_timer_mode *tm)
+{
+    return *tm == LIBXL_TIMER_MODE_DEFAULT;
+}
+
+static inline bool libxl__string_is_default(char **s)
+{
+    return *s == NULL;
+}
 #endif
 
 /*
index a32c751b0e7a39e4c32f479fcd15987f2c760d16..094303f1512216de46f98adfeb71dc5b784a169c 100644 (file)
@@ -172,7 +172,8 @@ libxl_timer_mode = Enumeration("timer_mode", [
     (1, "no_delay_for_missed_ticks"),
     (2, "no_missed_ticks_pending"),
     (3, "one_missed_tick_pending"),
-    ], init_val = "LIBXL_TIMER_MODE_DEFAULT")
+    ], init_val = "LIBXL_TIMER_MODE_DEFAULT",
+       check_default_fn = "libxl__timer_mode_is_default")
 
 libxl_bios_type = Enumeration("bios_type", [
     (0, "unknown"),