[virt-tools-list] [PATCH virt-viewer v2 3/3] Write vm name to config file as comment
Fabiano Fidêncio
fabiano at fidencio.org
Tue Jul 22 14:06:59 UTC 2014
On Mon, Jun 30, 2014 at 10:49 PM, Jonathon Jongsma <jjongsma at redhat.com>
wrote:
> ---
> src/virt-viewer-app.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 6bd49f4..158a638 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -242,6 +242,20 @@ virt_viewer_app_save_config(VirtViewerApp *self)
> g_warning("failed to create config directory");
> g_free(dir);
>
> + if (priv->uuid && priv->guest_name) {
> + // if there's no comment for this uuid settings group, add a
> comment
> + // with the vm name so user can make sense of it later.
> + gchar* comment = g_key_file_get_comment(priv->config, priv->uuid,
> NULL, &error);
>
Coding style here, use: gchar *comment (...)
> + if (error) {
> + g_warning("Unable to get comment from key file: %s",
> error->message);
> + g_clear_error(&error);
> + } else {
> + if (!comment || *comment == '\0')
> + g_key_file_set_comment(priv->config, priv->uuid, NULL,
> priv->guest_name, NULL);
> + }
> + g_free(comment);
> + }
> +
> if ((data = g_key_file_to_data(priv->config, NULL, &error)) == NULL ||
> !g_file_set_contents(priv->config_file, data, -1, &error)) {
> g_warning("Couldn't save configuration: %s", error->message);
> --
> 1.9.3
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
--
Fabiano Fidêncio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140722/677d79bc/attachment.htm>
More information about the virt-tools-list
mailing list