On Sat, Mar 09, 2013 at 04:44:14PM +0200, Zeeshan Ali (Khattak) wrote: > From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx> > > 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
Attachment:
pgpNmEfoYeYZ8.pgp
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list