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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 12, 2013 at 3:16 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:
> 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()

It would have been easier to go w/o a separate object but I went this
way since 'image' is a separate node in the config and I would assume
its for a reason. One reason that comes to mind is that in future
there might be some other options being added here?

>> +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?

I didn't know of this cause one thing i didn't do was to read the
docs. :( I'll try and update.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]