[libvirt] [libvirt-glib] gconfig: API for SPICE image compression options

Christophe Fergeau cfergeau at redhat.com
Tue Mar 12 13:16:59 UTC 2013


On Sat, Mar 09, 2013 at 04:44:14PM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> This patch adds API to set/get image compression options on
> domain/graphics[@type='spice'] nodes.
> 
> Also included are simple tests for this API.

Do we really need a dedicated gobject for this? I would have gone with
gvir_config_domain_graphics_spice_[gs]et_image_compression()

> +void gvir_config_domain_graphics_spice_image_set_compression
> +    (GVirConfigDomainGraphicsSpiceImage *image,
> +     GVirConfigDomainGraphicsSpiceImageCompression compression)
> +{
> +    const char *str;
> +    char *value;
> +    guint8 i;
> +
> +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE_IMAGE(image));
> +
> +    str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION,
> +                                     compression);
> +    g_return_if_fail(str != NULL);
> +
> +    value = g_strdup(str);
> +    /* glib-mkenum replaces '_' by default '-' in enum nicks and in this case
> +     * we don't want that as libvirt use '_' rather than '-' for SPICE image
> +     * compression attribute (unlike other attributes).
> +     */
> +    for (i = 0; i < strlen(str); i++) {
> +        if (value[i] == '-')
> +            value[i] = '_';
> +    }

Did you try something like
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;

as described on
https://developer.gnome.org/gobject/stable/glib-mkenums.html
rather than doing it by hand at runtime?

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/20130312/729adf23/attachment-0001.sig>


More information about the libvir-list mailing list