Re: [libvirt] [gconfig v2 3/4] config: Add vnc host setter

2016-08-03 Thread Christophe Fergeau
On Mon, Aug 01, 2016 at 11:52:39PM +0300, Visarion Alexandru wrote:
> From: Visarion Alexandru 
> 
> Learn to set the address that vnc is listening on.
> 
> We first remove the 'listen' attribute to avoid inconsistencies
> checks between the 'listen' attribute and the 'address'
> attribute of the 'listen' node.
> ---
>  .../libvirt-gconfig-domain-graphics-vnc.c  | 28 
> ++
>  .../libvirt-gconfig-domain-graphics-vnc.h  |  3 +++
>  libvirt-gconfig/libvirt-gconfig.sym|  1 +
>  3 files changed, 32 insertions(+)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c 
> b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> index fc26bb9..dc7641b 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> @@ -120,6 +120,34 @@ void 
> gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph
> NULL);
>  }
>  
> +/**
> + * gvir_config_domain_graphics_vnc_set_listen_address:
> + * @graphics: a #GVirConfigDomainGraphicsVnc
> + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen):
> + *
> + * This method is used to set the various listen nodes a 
> #GVirConfigDomainGraphicsVnc
> + * device can handle.
> +*/
> +void 
> gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc
>  *graphics,
> +GList *listens)
> +{
> +GList *it;
> +
> +g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics));
> +
> +gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics),
> +"listen");
> +gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics),
> +"listen", NULL);
> +
> +for (it = listens; it != NULL; it = it->next) {
> +g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data));
> +

gvir_config_domain_set_devices() warns but continues trying the other
devices, we probably can do the same here:

if (!GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)) {
g_warn_if_reached();
continue;
}

> +gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics),
> +  GVIR_CONFIG_OBJECT(it->data));
> +}
> +}
> +
>  void 
> gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc 
> *graphics,
>const char *password)
>  {
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h 
> b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
> index fe78621..f524dcc 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
> @@ -73,6 +73,9 @@ int 
> gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphi
>  void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc 
> *graphics,
>int port);
>  
> +void 
> gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc
>  *graphics,
> +GList *listens);

Indentation is off here, you need 4 more spaces.

> +
>  void 
> gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc 
> *graphics,
>const char *password);
>  
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym 
> b/libvirt-gconfig/libvirt-gconfig.sym
> index fab6059..117a648 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -768,6 +768,7 @@ global:
>   gvir_config_domain_graphics_listen_address_get_type;
>   gvir_config_domain_graphics_listen_address_new;
>   gvir_config_domain_graphics_listen_address_new_from_xml;
> + gvir_config_domain_graphics_vnc_set_listen_address;
>  } LIBVIRT_GCONFIG_0.2.2;

Be careful to the alphabetical sorting as in the other patches.

Acked-by: Christophe Fergeau 

Christophe


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [gconfig v2 3/4] config: Add vnc host setter

2016-08-01 Thread Visarion Alexandru
From: Visarion Alexandru 

Learn to set the address that vnc is listening on.

We first remove the 'listen' attribute to avoid inconsistencies
checks between the 'listen' attribute and the 'address'
attribute of the 'listen' node.
---
 .../libvirt-gconfig-domain-graphics-vnc.c  | 28 ++
 .../libvirt-gconfig-domain-graphics-vnc.h  |  3 +++
 libvirt-gconfig/libvirt-gconfig.sym|  1 +
 3 files changed, 32 insertions(+)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c 
b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
index fc26bb9..dc7641b 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
@@ -120,6 +120,34 @@ void 
gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph
NULL);
 }
 
+/**
+ * gvir_config_domain_graphics_vnc_set_listen_address:
+ * @graphics: a #GVirConfigDomainGraphicsVnc
+ * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen):
+ *
+ * This method is used to set the various listen nodes a 
#GVirConfigDomainGraphicsVnc
+ * device can handle.
+*/
+void 
gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc 
*graphics,
+GList *listens)
+{
+GList *it;
+
+g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics));
+
+gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics),
+"listen");
+gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics),
+"listen", NULL);
+
+for (it = listens; it != NULL; it = it->next) {
+g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data));
+
+gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics),
+  GVIR_CONFIG_OBJECT(it->data));
+}
+}
+
 void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc 
*graphics,
   const char *password)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h 
b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
index fe78621..f524dcc 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
@@ -73,6 +73,9 @@ int 
gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphi
 void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc 
*graphics,
   int port);
 
+void 
gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc 
*graphics,
+GList *listens);
+
 void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc 
*graphics,
   const char *password);
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym 
b/libvirt-gconfig/libvirt-gconfig.sym
index fab6059..117a648 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -768,6 +768,7 @@ global:
gvir_config_domain_graphics_listen_address_get_type;
gvir_config_domain_graphics_listen_address_new;
gvir_config_domain_graphics_listen_address_new_from_xml;
+   gvir_config_domain_graphics_vnc_set_listen_address;
 } LIBVIRT_GCONFIG_0.2.2;
 
 #  define new API here using predicted next version number 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list