[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH libvirt-glib 4/5] Add APIs for setting virt type and appending devices



On Wed, Nov 30, 2011 at 04:52:06PM +0000, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> Add gvir_config_domain_get_virt_type and

_set_virt_type

> gvir_config_domain_virt_type_get_type
> 
> * libvirt-gconfig-domain.c, libvirt-gconfig-domain.h,
>   libvirt-gconfig.h, libvirt-gconfig.sym: Add new APIs
> ---
>  libvirt-gconfig/libvirt-gconfig-domain.c |   32 ++++++++++++++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-domain.h |   10 +++++++++
>  libvirt-gconfig/libvirt-gconfig.h        |    2 +-
>  libvirt-gconfig/libvirt-gconfig.sym      |    2 +
>  4 files changed, 45 insertions(+), 1 deletions(-)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
> index b54d12c..8fb1a2b 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain.c
> @@ -175,6 +175,23 @@ GVirConfigDomain *gvir_config_domain_new(void)
>      return GVIR_CONFIG_DOMAIN(object);
>  }
>  
> +
> +void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomainVirtType type)
> +{
> +    xmlNodePtr node;
> +    const char *type_str;
> +
> +    g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_FILESYS(domain));

Extra _FILESYS here I think
> +
> +    node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(domain));
> +    g_return_if_fail(node != NULL);
> +    type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_VIRT_TYPE,
> +                                          type);
> +    g_return_if_fail(type_str != NULL);
> +    xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str);

gvir_config_node_set_attribute_with_type

> +}
> +
> +
>  char *gvir_config_domain_get_name(GVirConfigDomain *domain)
>  {
>      return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(domain),
> @@ -306,3 +323,18 @@ void gvir_config_domain_set_devices(GVirConfigDomain *domain,
>      gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain), devices_node);
>      g_object_unref(G_OBJECT(devices_node));
>  }
> +
> +void gvir_config_domain_add_device(GVirConfigDomain *domain,
> +                                   GVirConfigDomainDevice *device)
> +{
> +    GVirConfigObject *devices_node;
> +
> +    g_return_if_fail(GVIR_IS_CONFIG_DOMAIN(domain));
> +
> +    devices_node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
> +                                                "devices");
> +
> +    gvir_config_object_attach(devices_node, GVIR_CONFIG_OBJECT(device));


> +    gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain), devices_node);

gvir_config_object_add_child will have attached it already if needed, this
should be dropped or we'll get duplicated nodes in the xml tree
Actually I'm not sure the addition of this function was meant to be in this
commit. It's missing from libvirt-gconfig.sym, and is not used in this
commit so I'd rather have it in a separate commit.

> +    g_object_unref(G_OBJECT(devices_node));
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
> index 08682aa..c97ff46 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain.h
> +++ b/libvirt-gconfig/libvirt-gconfig-domain.h
> @@ -59,12 +59,20 @@ struct _GVirConfigDomainClass
>      gpointer padding[20];
>  };
>  
> +typedef enum {
> +    GVIR_CONFIG_DOMAIN_VIRT_XEN,
> +    GVIR_CONFIG_DOMAIN_VIRT_QEMU,
> +    GVIR_CONFIG_DOMAIN_VIRT_KVM,
> +    GVIR_CONFIG_DOMAIN_VIRT_KQEMU,
> +    GVIR_CONFIG_DOMAIN_VIRT_LXC,
> +} GVirConfigDomainVirtType;
>  
>  GType gvir_config_domain_get_type(void);
>  
>  GVirConfigDomain *gvir_config_domain_new_from_xml(const gchar *xml, GError **error);
>  GVirConfigDomain *gvir_config_domain_new(void);
>  
> +void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomainVirtType type);
>  char *gvir_config_domain_get_name(GVirConfigDomain *domain);
>  void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name);
>  guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain);
> @@ -81,6 +89,8 @@ void gvir_config_domain_set_os(GVirConfigDomain *domain,
>                                 GVirConfigDomainOs *os);
>  void gvir_config_domain_set_devices(GVirConfigDomain *domain,
>                                      GList *devices);
> +void gvir_config_domain_add_device(GVirConfigDomain *domain,
> +                                   GVirConfigDomainDevice *device);
>  
>  G_END_DECLS
>  
> diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
> index ed7623c..8525065 100644
> --- a/libvirt-gconfig/libvirt-gconfig.h
> +++ b/libvirt-gconfig/libvirt-gconfig.h
> @@ -29,7 +29,6 @@
>  #include <libvirt-gconfig/libvirt-gconfig-main.h>
>  #include <libvirt-gconfig/libvirt-gconfig-object.h>
>  #include <libvirt-gconfig/libvirt-gconfig-capabilities.h>
> -#include <libvirt-gconfig/libvirt-gconfig-domain.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h>
> @@ -43,6 +42,7 @@
>  #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-video.h>
> +#include <libvirt-gconfig/libvirt-gconfig-domain.h>

I disagree on this sorting, but no big deal :)

>  #include <libvirt-gconfig/libvirt-gconfig-enum-types.h>
>  #include <libvirt-gconfig/libvirt-gconfig-helpers.h>
>  #include <libvirt-gconfig/libvirt-gconfig-interface.h>
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index e895cb0..9b74c35 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -21,6 +21,8 @@ LIBVIRT_GCONFIG_0.0.1 {
>  	gvir_config_domain_set_os;
>  	gvir_config_domain_get_vcpus;
>  	gvir_config_domain_set_vcpus;
> +	gvir_config_domain_get_virt_type;

_set_virt_type

> +	gvir_config_domain_virt_type_get_type;
>  
>  	gvir_config_domain_clock_get_type;
>  	gvir_config_domain_clock_offset_get_type;
> -- 
> 1.7.6.4
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpPY3QDhnzDG.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]