It's only useful in the remote case, and removes duplication between GVirConfigDomainGraphicsSpice and GVirConfigDomainGraphicsVnc. Since the spice/vnc listen API was not in a libvirt-gconfig release, we can remove it without breaking API/ABI. --- .../libvirt-gconfig-domain-graphics-remote.c | 103 +++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-remote.h | 6 ++ .../libvirt-gconfig-domain-graphics-spice.c | 103 --------------------- .../libvirt-gconfig-domain-graphics-spice.h | 6 -- .../libvirt-gconfig-domain-graphics-vnc.c | 103 --------------------- .../libvirt-gconfig-domain-graphics-vnc.h | 6 -- libvirt-gconfig/libvirt-gconfig.h | 6 +- libvirt-gconfig/libvirt-gconfig.sym | 9 +- tests/test-gconfig.c | 6 +- 9 files changed, 118 insertions(+), 230 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c index 46b97f2..64928b6 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c @@ -93,3 +93,106 @@ int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote * return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), NULL, "port", 0); } + +/** + * gvir_config_domain_graphics_remote_set_listen: + * @graphics: a #GVirConfigDomainGraphicsRemote + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): listens + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsRemote + * device can handle. +*/ +void gvir_config_domain_graphics_remote_set_listen(GVirConfigDomainGraphicsRemote *graphics, + GList *listens) +{ + GList *it; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics)); + + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "listen"); + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "socket"); + 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)); + } +} + +/** + * gvir_config_domain_graphics_remote_add_listen_nodes: + * @graphics: a #GVirConfigDomainGraphicsRemote + * @listens: a #GVirConfigDomainGraphicsListen + * + * This method is used to add a listen node to a #GVirConfigDomainGraphicsRemote + * device can handle. +*/ +void gvir_config_domain_graphics_remote_add_listen(GVirConfigDomainGraphicsRemote *graphics, + GVirConfigDomainGraphicsListen *listen) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(listen)); +} + +struct ListenData { + GVirConfigXmlDoc *doc; + const gchar *schema; + GList *listen_devices; +}; + +static gboolean add_listen(xmlNodePtr node, gpointer opaque) +{ + struct ListenData* data = (struct ListenData*)opaque; + GVirConfigObject *object; + + if (g_strcmp0((const gchar *)node->name, "listen") != 0) + return TRUE; + + object = gvir_config_object_new_from_tree + (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, + data->doc, + data->schema, + node); + if (object != NULL) + data->listen_devices = g_list_append(data->listen_devices, object); + else + g_debug("Failed to parse %s node", node->name); + + return TRUE; +} + +/** + * gvir_config_domain_graphics_remote_get_listen: + * + * Gets all the listen not of #GVirConfigDomainGraphicsRemote + * + * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): + * a newly allocated #GList of #GVirConfigDomainGraphicsListen. + */ +GList * +gvir_config_domain_graphics_remote_get_listen(GVirConfigDomainGraphicsRemote *graphics) +{ + struct ListenData data; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics), NULL); + + g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); + g_return_val_if_fail(data.doc != NULL, NULL); + data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); + data.listen_devices = NULL; + + gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), + NULL, + add_listen, + &data); + g_clear_object(&data.doc); + + return data.listen_devices; +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h index cae8d21..f798501 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h @@ -64,6 +64,12 @@ GVirConfigDomainGraphicsRemote *gvir_config_domain_graphics_remote_new_from_xml( gboolean gvir_config_domain_graphics_remote_get_autoport(GVirConfigDomainGraphicsRemote *interface); int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote *interface); +void gvir_config_domain_graphics_remote_set_listen(GVirConfigDomainGraphicsRemote *graphics, + GList *listens); +void gvir_config_domain_graphics_remote_add_listen(GVirConfigDomainGraphicsRemote *graphics, + GVirConfigDomainGraphicsListen *listen); +GList *gvir_config_domain_graphics_remote_get_listen(GVirConfigDomainGraphicsRemote *graphics); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_REMOTE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 4538820..5590cf0 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -165,109 +165,6 @@ void gvir_config_domain_graphics_spice_set_image_compression compression); } -/** - * gvir_config_domain_graphics_spice_set_listen: - * @graphics: a #GVirConfigDomainGraphicsSpice - * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): listens - * - * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsSpice - * device can handle. -*/ -void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, - GList *listens) -{ - GList *it; - - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); - - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "listen"); - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "socket"); - 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)); - } -} - -/** - * gvir_config_domain_graphics_spice_add_listen: - * @graphics: a #GVirConfigDomainGraphicsSpice - * @listens: a #GVirConfigDomainGraphicsListen - * - * This method is used to add a listen node to a #GVirConfigDomainGraphicsSpice - * device can handle. -*/ -void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, - GVirConfigDomainGraphicsListen *listen) -{ - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(listen)); -} - -struct ListenData { - GVirConfigXmlDoc *doc; - const gchar *schema; - GList *listen_devices; -}; - -static gboolean add_listen(xmlNodePtr node, gpointer opaque) -{ - struct ListenData* data = (struct ListenData*)opaque; - GVirConfigObject *object; - - if (g_strcmp0((const gchar *)node->name, "listen") != 0) - return TRUE; - - object = gvir_config_object_new_from_tree - (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, - data->doc, - data->schema, - node); - if (object != NULL) - data->listen_devices = g_list_append(data->listen_devices, object); - else - g_debug("Failed to parse %s node", node->name); - - return TRUE; -} - -/** - * gvir_config_domain_graphics_spice_get_listen: - * - * Gets all the listen not of #GVirConfigDomainGraphicsSpice - * - * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): - * a newly allocated #GList of #GVirConfigDomainGraphicsListen. - */ -GList * -gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics) -{ - struct ListenData data; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), NULL); - - g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); - g_return_val_if_fail(data.doc != NULL, NULL); - data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); - data.listen_devices = NULL; - - gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), - NULL, - add_listen, - &data); - g_clear_object(&data.doc); - - return data.listen_devices; -} - void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index b33c693..9c790d7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -96,12 +96,6 @@ gvir_config_domain_graphics_spice_get_image_compression void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl); -void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, - GList *listens); -void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, - GVirConfigDomainGraphicsListen *listen); -GList *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); - G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 0927cc9..8bcaac7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -120,109 +120,6 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph NULL); } -/** - * gvir_config_domain_graphics_vnc_set_listen: - * @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(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_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "socket"); - 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)); - } -} - -/** - * gvir_config_domain_graphics_vnc_add_listen: - * @graphics: a #GVirConfigDomainGraphicsVnc - * @listens: a #GVirConfigDomainGraphicsListen - * - * This method is used to add a listen node to a #GVirConfigDomainGraphicsVnc - * device can handle. -*/ -void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, - GVirConfigDomainGraphicsListen *listen) -{ - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(listen)); -} - -struct ListenData { - GVirConfigXmlDoc *doc; - const gchar *schema; - GList *listen_devices; -}; - -static gboolean add_listen(xmlNodePtr node, gpointer opaque) -{ - struct ListenData* data = (struct ListenData*)opaque; - GVirConfigObject *object; - - if (g_strcmp0((const gchar *)node->name, "listen") != 0) - return TRUE; - - object = gvir_config_object_new_from_tree - (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, - data->doc, - data->schema, - node); - if (object != NULL) - data->listen_devices = g_list_append(data->listen_devices, object); - else - g_debug("Failed to parse %s node", node->name); - - return TRUE; -} - -/** - * gvir_config_domain_graphics_vnc_get_listen: - * - * Gets all the listen not of #GVirConfigDomainGraphicsVnc - * - * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): - * a newly allocated #GList of #GVirConfigDomainGraphicsListen. - */ -GList * -gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics) -{ - struct ListenData data; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); - - g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); - g_return_val_if_fail(data.doc != NULL, NULL); - data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); - data.listen_devices = NULL; - - gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), - NULL, - add_listen, - &data); - g_clear_object(&data.doc); - - return data.listen_devices; -} - 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 482070a..72ca287 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -73,12 +73,6 @@ 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(GVirConfigDomainGraphicsVnc *graphics, - GList *listens); -void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, - GVirConfigDomainGraphicsListen *listen); -GList *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); - void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password); diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 77611b8..2f65cfe 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -62,13 +62,13 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 975c9e1..6f10583 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -760,17 +760,14 @@ global: gvir_config_domain_graphics_local_get_display; gvir_config_domain_graphics_local_get_fullscreen; gvir_config_domain_graphics_local_get_type; + gvir_config_domain_graphics_remote_add_listen; gvir_config_domain_graphics_remote_get_autoport; + gvir_config_domain_graphics_remote_get_listen; gvir_config_domain_graphics_remote_get_port; gvir_config_domain_graphics_remote_get_type; - gvir_config_domain_graphics_spice_add_listen; - gvir_config_domain_graphics_spice_get_listen; + gvir_config_domain_graphics_remote_set_listen; gvir_config_domain_graphics_spice_get_tls_port; gvir_config_domain_graphics_spice_set_gl; - gvir_config_domain_graphics_spice_set_listen; - gvir_config_domain_graphics_vnc_add_listen; - gvir_config_domain_graphics_vnc_get_listen; - gvir_config_domain_graphics_vnc_set_listen; gvir_config_domain_hostdev_get_boot_order; gvir_config_domain_hostdev_get_readonly; diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index 7fc0704..36e444c 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -512,12 +512,12 @@ static void test_domain_device_graphics_listen(void) /* test listen setter */ listen_list = g_list_append(listen_list, address_listen); - gvir_config_domain_graphics_spice_set_listen(graphics, listen_list); + gvir_config_domain_graphics_remote_set_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), listen_list); g_object_unref(G_OBJECT(address_listen)); g_list_free(listen_list); - gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(none_listen)); - gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(unix_listen)); + gvir_config_domain_graphics_remote_add_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(none_listen)); + gvir_config_domain_graphics_remote_add_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(unix_listen)); g_object_unref(none_listen); g_object_unref(unix_listen); -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list