[virt-tools-list] [virt-viewer] app: Always add guest name comment

Christophe Fergeau cfergeau at redhat.com
Fri Aug 31 13:26:18 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Thu, Aug 30, 2018 at 01:56:27PM +0200, Victor Toso wrote:
> From: Victor Toso <me at victortoso.com>
> 
> Even when the user adds comments, we should place the guest's name
> unless it is present already.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1623756
> 
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
>  src/virt-viewer-app.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index cd0c7ad..e0e6e63 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -256,9 +256,13 @@ virt_viewer_app_save_config(VirtViewerApp *self)
>          if (error) {
>              g_debug("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);
> +        }
> +
> +        if (comment == NULL ||
> +                (comment != NULL && g_strstr_len(comment, -1, priv->guest_name) == NULL)) {
> +            /* Note that this function appends the guest's name string as last
> +             * comment in case there were comments there already */
> +            g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL);
>          }
>          g_free(comment);
>      }
> -- 
> 2.17.1
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180831/9cfce051/attachment.sig>


More information about the virt-tools-list mailing list