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

Re: [libvirt] [PATCH libvirt-glib v2 4/8] Add API for appending a new device to the domain



On Thu, Dec 01, 2011 at 11:01:01AM +0000, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> The gvir_config_domain_set_devices API replaces the entire
> list of devices, but when building up a config incrementally
> it is useful to append device one at a time. Thus we need
> a gvir_config_domain_add_device method
> 
> * libvirt-gconfig/libvirt-gconfig-domain.c,
>   libvirt-gconfig/libvirt-gconfig-domain.h,
>   libvirt-gconfig/libvirt-gconfig.syms: gvir_config_domain_add_device
> ---
>  libvirt-gconfig/libvirt-gconfig-domain.c |   14 ++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-domain.h |    3 +++
>  libvirt-gconfig/libvirt-gconfig.sym      |    1 +
>  3 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
> index 0ceb5d5..ab40cb3 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain.c
> @@ -317,3 +317,17 @@ 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));

Can you sneak in a g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DEVICE(device));
? ACK with this added

> +
> +    devices_node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
> +                                                "devices");
> +
> +    gvir_config_object_attach(devices_node, GVIR_CONFIG_OBJECT(device));
> +    g_object_unref(G_OBJECT(devices_node));
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
> index 459c308..4cbc1f0 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain.h
> +++ b/libvirt-gconfig/libvirt-gconfig-domain.h
> @@ -29,6 +29,7 @@
>  
>  #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-os.h>
> +#include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
>  
>  G_BEGIN_DECLS
>  
> @@ -89,6 +90,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.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index c637a9e..738f625 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -7,6 +7,7 @@ LIBVIRT_GCONFIG_0.0.1 {
>  	gvir_config_capabilities_new;
>  	gvir_config_capabilities_new_from_xml;
>  
> +	gvir_config_domain_add_device;
>  	gvir_config_domain_get_type;
>  	gvir_config_domain_new;
>  	gvir_config_domain_new_from_xml;
> -- 
> 1.7.6.4
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgp1cT0GLO1Ko.pgp
Description: PGP signature


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