[virt-tools-list] [PATCH virt-viewer 3/3] Write vm name to config file as comment

Christophe Fergeau cfergeau at redhat.com
Mon Jun 23 15:47:23 UTC 2014


On Mon, Jun 23, 2014 at 05:46:13PM +0200, Christophe Fergeau wrote:
> On Thu, Jun 12, 2014 at 04:07:04PM -0500, Jonathon Jongsma 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 a986cba..482a4ee 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);
> > +        if (error) {
> > +            g_warning("Unable to get comment from key file: %s", error->message);
> > +            g_clear_error(&error);
> > +        } else {
> > +            if (!comment || strlen(comment) == 0)
> > +                g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL);
> > +        }
> 
> Why are you trying to preserve existing comments? In case the user added
> some of his own to the VM? This means if the user change the name of the
> VM without changing its UUId the comment won't get updated

Patch looks good to me btw, strlen(comment) could be *comment != '\0'

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140623/5fcdd81f/attachment.sig>


More information about the virt-tools-list mailing list