[libvirt] [libvirt-glib v2] gconfig: API for SPICE image compression
Christophe Fergeau
cfergeau at redhat.com
Thu Mar 14 10:35:41 UTC 2013
Hey,
On Tue, Mar 12, 2013 at 10:56:31PM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at 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.
> ---
>
> V2:
>
> * No separate class for 'image' node.
> * Use trigraph extensions of glib-mkenums to assign desired nicks to enums rather than replacing '-' with '-' and viceversa at runtime.
>
> .../libvirt-gconfig-domain-graphics-spice.c | 39 +++++++++++++++++++++-
> .../libvirt-gconfig-domain-graphics-spice.h | 19 ++++++++++-
> libvirt-gconfig/libvirt-gconfig.sym | 8 +++++
> libvirt-gconfig/tests/test-domain-create.c | 7 ++++
> 4 files changed, 71 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..dc21b98 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
> @@ -17,10 +17,12 @@
> * 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 at gmail.com>
> + * Authors: Christophe Fergeau <cfergeau at gmail.com>
> + * Zeeshan Ali (Khattak) <zeeshanak at gnome.org>
> */
>
> #include <config.h>
> +#include <string.h>
I don't think this is needed.
>
> #include "libvirt-gconfig/libvirt-gconfig.h"
> #include "libvirt-gconfig/libvirt-gconfig-private.h"
> @@ -122,3 +124,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_add_child_with_attribute_enum
> + (GVIR_CONFIG_OBJECT(graphics),
> + "image",
> + "compression",
> + GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION,
> + compression);
> +}
gvir_config_object_replace_child_with_attribute_enum would be better here
as you don't want to add multiple <image> nodes if this method is called
several times. Obviously this _replace_child_with_attribute_enum helper
does not exist yet :(
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130314/0789bafa/attachment-0001.sig>
More information about the libvir-list
mailing list