[libvirt] [PATCH v4 3/6] libvirt-gconfig: Accept on/off as boolean attributes

Christophe Fergeau cfergeau at redhat.com
Thu Apr 21 14:18:48 UTC 2016


On Fri, Apr 15, 2016 at 02:38:21PM +0100, Zeeshan Ali (Khattak) wrote:
> gvir_config_object_get_attribute_boolean() currently only accepts yes/no
> as boolean attribute values. Let's also accept on/off as valid values
> too.

As said in 4/6, I prefer to have the "on"/"off" check in the getter
rather than here.

Christophe

> 
> This will come handy in a following patch that adds 'hostdev' handling
> API.
> ---
>  libvirt-gconfig/libvirt-gconfig-object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
> index 6225de2..f44cc4c 100644
> --- a/libvirt-gconfig/libvirt-gconfig-object.c
> +++ b/libvirt-gconfig/libvirt-gconfig-object.c
> @@ -690,9 +690,9 @@ gvir_config_object_get_attribute_boolean(GVirConfigObject *object,
>      const char *str;
>  
>      str = gvir_config_object_get_attribute(object, node_name, attr_name);
> -    if (g_strcmp0(str, "yes") == 0) {
> +    if (g_strcmp0(str, "yes") == 0 || g_strcmp0(str, "on") == 0) {
>          return TRUE;
> -    } else if (g_strcmp0(str, "no") == 0) {
> +    } else if (g_strcmp0(str, "no") == 0 || g_strcmp0(str, "off") == 0) {
>          return FALSE;
>      } else {
>          return default_value;
> -- 
> 2.5.5
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160421/245228e3/attachment-0001.sig>


More information about the libvir-list mailing list