Re: [PATCH] virt-login-shell joins users into lxc container.

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

 



On Fri, Jul 26, 2013 at 12:26:36PM -0400, Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 07/26/2013 07:40 AM, Daniel P. Berrange wrote:
> > On Fri, Jul 26, 2013 at 07:38:31AM -0400, Daniel J Walsh wrote:
> >> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
> >> 
> >> I can't seem to get the error reporting to turn on, what am I doing
> >> wrong.,
> >> 
> >> if (virInitialize() < 0) { fprintf(stderr, _("Failed to initialize
> >> libvirt")); return EXIT_FAILURE; }
> >> 
> >> if (virErrorInitialize() < 0) { fprintf(stderr, _("Failed to initialize
> >> libvirt Error Handling")); return EXIT_FAILURE; }
> >> 
> >> virSetErrorFunc(NULL, NULL);
> >> 
> >> 
> >> virReportSystemError(EINVAL, "%s", _("Test"));
> >> 
> >> And I get no output, I thought I would get error on stderr?
> > 
> > You would, except that you just turned off printing to stderr by calling
> > virSetErrorFunc in that way.
> > 
> > 
> > Daniel
> > 
> Am I misreading this?
> * virSetErrorFunc:
> * @userData: pointer to the user data provided in the handler callback
> * @handler: the function to get called in case of error or NULL
> *
> * Set a library global error handling function, if @handler is NULL,
> * it will reset to default printing on stderr. The error raised there
> * are those for which no handler at the connection level could caught.
> */
> Looks like setting handler to Null reset default printing on stderr?
> But I am getting no output whether or not I set this.

Oh, whoops, I'm back to front.

The actual reason you're having trouble is that you're using
virReportError from outside the context of any public API
calls.

virReportError does not actually print any errors, it just
records them. It requires a seprate call to virDispatchError
to trigger the print to stderr.  This is usually taken care
of by the public API methods.

You'll have to take care of it yourself though. If you
have a centralized error handling return point eg

    ...success...
     return 0;

   error:
      return -1;
   }

Then you'd put a virDispatchError call just after the
'error:' label

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]