[libvirt] [PATCH libvirt-glib v2 1/2] Add gvir_config_object_replace_child_with_attribute_enum()

From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> Internal libvirt-gconfig helper to replace enum XML attributes. --- libvirt-gconfig/libvirt-gconfig-object-private.h | 5 +++++ libvirt-gconfig/libvirt-gconfig-object.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index 830517c..91355fb 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -74,6 +74,11 @@ void gvir_config_object_replace_child_with_attribute(GVirConfigObject *object, const char *child_name, const char *attr_name, const char *attr_value); +void gvir_config_object_replace_child_with_attribute_enum(GVirConfigObject *object, + const char *child_name, + const char *attr_name, + GType attr_type, + unsigned int attr_value); void gvir_config_object_delete_child(GVirConfigObject *object, const char *child_name, const char *ns_href); diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index ac0545c..c4e4271 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -459,6 +459,20 @@ gvir_config_object_replace_child_with_attribute(GVirConfigObject *object, g_object_unref(G_OBJECT(child)); } +G_GNUC_INTERNAL void +gvir_config_object_replace_child_with_attribute_enum(GVirConfigObject *object, + const char *child_name, + const char *attr_name, + GType attr_type, + unsigned int attr_value) +{ + GVirConfigObject *child; + + child = gvir_config_object_replace_child(object, child_name); + gvir_config_object_set_attribute_with_type(child, attr_name, attr_type, attr_value, NULL); + g_object_unref(G_OBJECT(child)); +} + struct NodeMatch { const char *name; const char *ns; -- 1.8.1.4

From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> This patch adds API to set/get image compression configuration on domain/graphics[@type='spice'] nodes. Also included are simple tests for this API. --- .../libvirt-gconfig-domain-graphics-spice.c | 38 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-spice.h | 19 ++++++++++- libvirt-gconfig/libvirt-gconfig.sym | 8 +++++ libvirt-gconfig/tests/test-domain-create.c | 7 ++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index d090a3a..d17a394 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -17,7 +17,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Christophe Fergeau <cfergeau@gmail.com> + * Authors: Christophe Fergeau <cfergeau@gmail.com> + * Zeeshan Ali (Khattak) <zeeshanak@gnome.org> */ #include <config.h> @@ -122,3 +123,38 @@ void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpic "tlsPort", G_TYPE_INT, port, NULL); } + +/** + * gvir_config_domain_graphics_spice_get_image_compression: + * @graphics: a #GVirConfigDomainGraphicsSpice + * + * Returns: (type GVirConfigDomainGraphicsSpiceImageCompression): image + * compression configuration of @graphics + */ +int +gvir_config_domain_graphics_spice_get_image_compression(GVirConfigDomainGraphicsSpice *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF); + + return gvir_config_object_get_attribute_genum + (GVIR_CONFIG_OBJECT(graphics), + "image", + "compression", + GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ); +} + +void gvir_config_domain_graphics_spice_set_image_compression + (GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsSpiceImageCompression compression) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_replace_child_with_attribute_enum + (GVIR_CONFIG_OBJECT(graphics), + "image", + "compression", + GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION, + compression); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index c82615b..7e70cd4 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -17,7 +17,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Christophe Fergeau <cfergeau@gmail.com> + * Authors: Christophe Fergeau <cfergeau@gmail.com> + * Zeeshan Ali (Khattak) <zeeshanak@gnome.org> */ #if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD) @@ -56,6 +57,15 @@ struct _GVirConfigDomainGraphicsSpiceClass gpointer padding[20]; }; +typedef enum { + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_GLZ, /*< nick=auto_glz >*/ + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ, /*< nick=auto_lz >*/ + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_QUIC, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LZ, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF +} GVirConfigDomainGraphicsSpiceImageCompression; + GType gvir_config_domain_graphics_spice_get_type(void); GVirConfigDomainGraphicsSpice *gvir_config_domain_graphics_spice_new(void); @@ -75,6 +85,13 @@ void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *g void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpice *graphics, int port); +void gvir_config_domain_graphics_spice_set_image_compression + (GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsSpiceImageCompression compression); +int +gvir_config_domain_graphics_spice_get_image_compression + (GVirConfigDomainGraphicsSpice *graphics); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index d9cff90..a1b2cc1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -504,4 +504,12 @@ LIBVIRT_GCONFIG_0.1.5 { gvir_config_domain_smartcard_passthrough_set_source; } LIBVIRT_GCONFIG_0.1.4; +LIBVIRT_GCONFIG_0.1.6 { + global: + gvir_config_domain_graphics_spice_get_image_compression; + gvir_config_domain_graphics_spice_set_image_compression; + + gvir_config_domain_graphics_spice_image_compression_get_type; +} LIBVIRT_GCONFIG_0.1.5; + # .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 4c94b2a..20fedc5 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -288,6 +288,13 @@ int main(int argc, char **argv) graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); g_assert(gvir_config_domain_graphics_spice_get_port(graphics) == 1234); + + /* SPICE image compression configuration */ + gvir_config_domain_graphics_spice_set_image_compression + (graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ); + g_assert(gvir_config_domain_graphics_spice_get_image_compression(graphics) == + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ); + devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics)); /* video node */ -- 1.8.1.4

ACK On Thu, Mar 14, 2013 at 03:53:47PM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
This patch adds API to set/get image compression configuration on domain/graphics[@type='spice'] nodes.
Also included are simple tests for this API. --- .../libvirt-gconfig-domain-graphics-spice.c | 38 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-spice.h | 19 ++++++++++- libvirt-gconfig/libvirt-gconfig.sym | 8 +++++ libvirt-gconfig/tests/test-domain-create.c | 7 ++++ 4 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index d090a3a..d17a394 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -17,7 +17,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Christophe Fergeau <cfergeau@gmail.com> + * Authors: Christophe Fergeau <cfergeau@gmail.com> + * Zeeshan Ali (Khattak) <zeeshanak@gnome.org> */
#include <config.h> @@ -122,3 +123,38 @@ void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpic "tlsPort", G_TYPE_INT, port, NULL); } + +/** + * gvir_config_domain_graphics_spice_get_image_compression: + * @graphics: a #GVirConfigDomainGraphicsSpice + * + * Returns: (type GVirConfigDomainGraphicsSpiceImageCompression): image + * compression configuration of @graphics + */ +int +gvir_config_domain_graphics_spice_get_image_compression(GVirConfigDomainGraphicsSpice *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF); + + return gvir_config_object_get_attribute_genum + (GVIR_CONFIG_OBJECT(graphics), + "image", + "compression", + GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ); +} + +void gvir_config_domain_graphics_spice_set_image_compression + (GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsSpiceImageCompression compression) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_replace_child_with_attribute_enum + (GVIR_CONFIG_OBJECT(graphics), + "image", + "compression", + GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION, + compression); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index c82615b..7e70cd4 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -17,7 +17,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Christophe Fergeau <cfergeau@gmail.com> + * Authors: Christophe Fergeau <cfergeau@gmail.com> + * Zeeshan Ali (Khattak) <zeeshanak@gnome.org> */
#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD) @@ -56,6 +57,15 @@ struct _GVirConfigDomainGraphicsSpiceClass gpointer padding[20]; };
+typedef enum { + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_GLZ, /*< nick=auto_glz >*/ + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ, /*< nick=auto_lz >*/ + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_QUIC, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LZ, + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF +} GVirConfigDomainGraphicsSpiceImageCompression; + GType gvir_config_domain_graphics_spice_get_type(void);
GVirConfigDomainGraphicsSpice *gvir_config_domain_graphics_spice_new(void); @@ -75,6 +85,13 @@ void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *g void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpice *graphics, int port);
+void gvir_config_domain_graphics_spice_set_image_compression + (GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsSpiceImageCompression compression); +int +gvir_config_domain_graphics_spice_get_image_compression + (GVirConfigDomainGraphicsSpice *graphics); + G_END_DECLS
#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index d9cff90..a1b2cc1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -504,4 +504,12 @@ LIBVIRT_GCONFIG_0.1.5 { gvir_config_domain_smartcard_passthrough_set_source; } LIBVIRT_GCONFIG_0.1.4;
+LIBVIRT_GCONFIG_0.1.6 { + global: + gvir_config_domain_graphics_spice_get_image_compression; + gvir_config_domain_graphics_spice_set_image_compression; + + gvir_config_domain_graphics_spice_image_compression_get_type; +} LIBVIRT_GCONFIG_0.1.5; + # .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 4c94b2a..20fedc5 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -288,6 +288,13 @@ int main(int argc, char **argv) graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); g_assert(gvir_config_domain_graphics_spice_get_port(graphics) == 1234); + + /* SPICE image compression configuration */ + gvir_config_domain_graphics_spice_set_image_compression + (graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ); + g_assert(gvir_config_domain_graphics_spice_get_image_compression(graphics) == + GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ); + devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics));
/* video node */ -- 1.8.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

ACK On Thu, Mar 14, 2013 at 03:53:46PM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
Internal libvirt-gconfig helper to replace enum XML attributes. --- libvirt-gconfig/libvirt-gconfig-object-private.h | 5 +++++ libvirt-gconfig/libvirt-gconfig-object.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index 830517c..91355fb 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -74,6 +74,11 @@ void gvir_config_object_replace_child_with_attribute(GVirConfigObject *object, const char *child_name, const char *attr_name, const char *attr_value); +void gvir_config_object_replace_child_with_attribute_enum(GVirConfigObject *object, + const char *child_name, + const char *attr_name, + GType attr_type, + unsigned int attr_value); void gvir_config_object_delete_child(GVirConfigObject *object, const char *child_name, const char *ns_href); diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index ac0545c..c4e4271 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -459,6 +459,20 @@ gvir_config_object_replace_child_with_attribute(GVirConfigObject *object, g_object_unref(G_OBJECT(child)); }
+G_GNUC_INTERNAL void +gvir_config_object_replace_child_with_attribute_enum(GVirConfigObject *object, + const char *child_name, + const char *attr_name, + GType attr_type, + unsigned int attr_value) +{ + GVirConfigObject *child; + + child = gvir_config_object_replace_child(object, child_name); + gvir_config_object_set_attribute_with_type(child, attr_name, attr_type, attr_value, NULL); + g_object_unref(G_OBJECT(child)); +} + struct NodeMatch { const char *name; const char *ns; -- 1.8.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)