[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl_internal: functions to check default values for builtin types
commit 47925f378394cd1351b4f1992bd75bed7e3ace93 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Wed Jun 11 17:35:07 2014 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Thu Jul 10 13:06:34 2014 +0100 libxl_internal: functions to check default values for builtin types They will be used in later patch to determine whether we should generate JSON output for a type. If that type has default value we just skip generating JSON output. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/libxl.c | 3 +-- tools/libxl/libxl_cpuid.c | 5 +++++ tools/libxl/libxl_internal.c | 6 ++++++ tools/libxl/libxl_internal.h | 24 ++++++++++++++++++++++++ tools/libxl/libxl_nocpuid.c | 5 +++++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 39f1c28..c272b8d 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2860,8 +2860,7 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, nic->model = strdup("rtl8139"); if (!nic->model) return ERROR_NOMEM; } - if (!nic->mac[0] && !nic->mac[1] && !nic->mac[2] && - !nic->mac[3] && !nic->mac[4] && !nic->mac[5]) { + if (libxl__mac_is_default(&nic->mac)) { const uint8_t *r; libxl_uuid uuid; diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c index 1f2bcd5..1706357 100644 --- a/tools/libxl/libxl_cpuid.c +++ b/tools/libxl/libxl_cpuid.c @@ -14,6 +14,11 @@ #include "libxl_internal.h" +int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) +{ + return !libxl_cpuid_policy_list_length(pl); +} + void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list) { int i, j; diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 6c94d3e..81f8985 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -307,6 +307,12 @@ _hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b) return 0; } +_hidden int libxl__mac_is_default(libxl_mac *mac) +{ + return (!(*mac)[0] && !(*mac)[1] && !(*mac)[2] && + !(*mac)[3] && !(*mac)[4] && !(*mac)[5]); +} + _hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *lock) { pthread_mutexattr_t attr; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e8f2abb..7750dc5 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1549,6 +1549,8 @@ struct libxl__xen_console_reader { _hidden int libxl__parse_mac(const char *s, libxl_mac mac); /* compare mac address @a and @b. 0 if the same, -ve if a<b and +ve if a>b */ _hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b); +/* return true if mac address is all zero (the default value) */ +_hidden int libxl__mac_is_default(libxl_mac *mac); /* init a recursive mutex */ _hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *lock); @@ -3097,6 +3099,10 @@ _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uint32_t domid, #define LIBXL__DEFBOOL_STR_DEFAULT "<default>" #define LIBXL__DEFBOOL_STR_FALSE "False" #define LIBXL__DEFBOOL_STR_TRUE "True" +static inline int libxl__defbool_is_default(libxl_defbool *db) +{ + return !db->val; +} /* * Inserts "elm_new" into the sorted list "head". @@ -3193,6 +3199,24 @@ int libxl__random_bytes(libxl__gc *gc, uint8_t *buf, size_t len); #define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)])) #endif +/* This always return false, there's no "default value" for hw cap */ +static inline int libxl__hwcap_is_default(libxl_hwcap *hwcap) +{ + return 0; +} + +static inline int libxl__string_list_is_empty(libxl_string_list *psl) +{ + return !libxl_string_list_length(psl); +} + +static inline int libxl__key_value_list_is_empty(libxl_key_value_list *pkvl) +{ + return !libxl_key_value_list_length(pkvl); +} + +int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl); + #endif /* diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libxl/libxl_nocpuid.c index eb525fc..96e6e2e 100644 --- a/tools/libxl/libxl_nocpuid.c +++ b/tools/libxl/libxl_nocpuid.c @@ -14,6 +14,11 @@ #include "libxl_internal.h" +int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) +{ + return 1; +} + void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list) { } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |