[libvirt] [libvirt-glib 11/37] Implement gvir_config_os_set_os_type

Marc-André Lureau marcandre.lureau at gmail.com
Fri Nov 11 14:58:40 UTC 2011


On Thu, Nov 10, 2011 at 9:33 PM, Christophe Fergeau <cfergeau at redhat.com> wrote:
> ---
>  libvirt-gconfig/libvirt-gconfig-os.c |   14 ++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-os.h |    6 ++++++
>  libvirt-gconfig/libvirt-gconfig.sym  |    1 +
>  3 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c
> index b47e859..d4a04ae 100644
> --- a/libvirt-gconfig/libvirt-gconfig-os.c
> +++ b/libvirt-gconfig/libvirt-gconfig-os.c
> @@ -27,6 +27,7 @@
>  #include <libxml/tree.h>
>
>  #include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
>
>  extern gboolean debugFlag;
>
> @@ -78,3 +79,16 @@ GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error)
>                                              NULL, xml, error);
>     return GVIR_CONFIG_OS(object);
>  }
> +
> +void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type)
> +{
> +    xmlNodePtr node;
> +    const char *type_str;
> +
> +    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "type");
> +    if (node == NULL)
> +        return;

I would use a couple of g_return_if_fail so that we get warnings of
something going wrong instead of silently returning.

Same in previous code actually.

> +    type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_TYPE, type);
> +    if (type_str != NULL)
> +        xmlNodeSetContent(node, (xmlChar*)type_str);
> +}

Perhaps the warning for invalid enum could be put in
gvir_config_genum_get_nick().


-- 
Marc-André Lureau




More information about the libvir-list mailing list