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

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

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@xxxxxxxxxx>
---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux