Blame SOURCES/0039-Write-vm-name-to-config-file-as-comment.patch

4ab194
From 894ca98a86fb56b5dd0fae2631a5ad1a5db64416 Mon Sep 17 00:00:00 2001
4ab194
From: Jonathon Jongsma <jjongsma@redhat.com>
4ab194
Date: Mon, 20 Jan 2014 10:27:36 -0600
4ab194
Subject: [PATCH] Write vm name to config file as comment
4ab194
4ab194
---
4ab194
 src/virt-viewer-app.c | 14 ++++++++++++++
4ab194
 1 file changed, 14 insertions(+)
4ab194
4ab194
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
4ab194
index 9182fe4..aa574be 100644
4ab194
--- a/src/virt-viewer-app.c
4ab194
+++ b/src/virt-viewer-app.c
4ab194
@@ -242,6 +242,20 @@ virt_viewer_app_save_config(VirtViewerApp *self)
4ab194
         g_warning("failed to create config directory");
4ab194
     g_free(dir);
4ab194
 
4ab194
+    if (priv->uuid && priv->guest_name) {
4ab194
+        // if there's no comment for this uuid settings group, add a comment
4ab194
+        // with the vm name so user can make sense of it later.
4ab194
+        gchar *comment = g_key_file_get_comment(priv->config, priv->uuid, NULL, &error);
4ab194
+        if (error) {
4ab194
+            g_warning("Unable to get comment from key file: %s", error->message);
4ab194
+            g_clear_error(&error);
4ab194
+        } else {
4ab194
+            if (!comment || *comment == '\0')
4ab194
+                g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL);
4ab194
+        }
4ab194
+        g_free(comment);
4ab194
+    }
4ab194
+
4ab194
     if ((data = g_key_file_to_data(priv->config, NULL, &error)) == NULL ||
4ab194
         !g_file_set_contents(priv->config_file, data, -1, &error)) {
4ab194
         g_warning("Couldn't save configuration: %s", error->message);