[libvirt] virGetLastError() disagrees with virConnGetLastError()

If you edit virsh sources, you should find that on 'virsh dump Domain-0 /var/tmp/foo', the conn error is correctly set, but the thread-load error is not set. Isn't this a bug? regards john

On Mon, Feb 02, 2009 at 03:10:23PM -0500, John Levon wrote:
If you edit virsh sources, you should find that on 'virsh dump Domain-0 /var/tmp/foo', the conn error is correctly set, but the thread-load error is not set. Isn't this a bug?
I can't reproduce this problem with current CVS. I made the following change to the 'dump' method in virsh.c diff -u -p -u -r1.189 virsh.c --- virsh.c 30 Jan 2009 15:43:05 -0000 1.189 +++ virsh.c 3 Feb 2009 11:12:13 -0000 @@ -1340,6 +1340,15 @@ cmdDump(vshControl *ctl, const vshCmd *c ret = FALSE; } + virErrorPtr err1 = virGetLastError(); + virErrorPtr err2 = virConnGetLastError(ctl->conn); + + fprintf(stderr, "%p %p\n", err1, err2); + if (err1) + fprintf(stderr, "%d %s\n", err1->code, err1->message); + if (err2) + fprintf(stderr, "%d %s\n", err2->code, err2->message); + virDomainFree(dom); return ret; } And when I run it, i see: # ./virsh dump Domain-0 foo libvir: Xen Daemon error : POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') error: Failed to core dump domain Domain-0 to foo 0xa5c9450 0xa5c9248 11 POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') 11 POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') So, AFAICT, both the global and per-connection error object are correctly set. Was that change I made to virsh.c the same thing you were testing ? Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Feb 03, 2009 at 11:14:24AM +0000, Daniel P. Berrange wrote:
I can't reproduce this problem with current CVS.
I made the following change to the 'dump' method in virsh.c
The difference is I have it /after/ the virDomainFree (actually in virCommandRun). I hadn't noticed this before. error: Failed to core dump domain Domain-0 to /var/tmp/a 0 80a90ac 11 POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') virsh: error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') Perhaps it's the case that there's no guarantees as to the error state after a successful call. I'm trying to "save" the error messages in virsh until a command actually failed. That way any incidental errors along the way aren't shown. It looks like I might need to save the last error in the error handler with virCopyLastError(), then use that in vshCommandRun(). regards john

On Tue, Feb 03, 2009 at 11:16:20AM -0500, John Levon wrote:
On Tue, Feb 03, 2009 at 11:14:24AM +0000, Daniel P. Berrange wrote:
I can't reproduce this problem with current CVS.
I made the following change to the 'dump' method in virsh.c
The difference is I have it /after/ the virDomainFree (actually in virCommandRun). I hadn't noticed this before.
error: Failed to core dump domain Domain-0 to /var/tmp/a 0 80a90ac 11 POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') virsh: error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0')
Perhaps it's the case that there's no guarantees as to the error state after a successful call.
The problem you're hitting is that the last error is only valid until the next public API call. virDomainFree is a public API call, so you can't expect to access the last error, from the virDomainCoreDump after you call virDomainFree. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Feb 03, 2009 at 04:20:25PM +0000, Daniel P. Berrange wrote:
11 POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0') virsh: error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Cannot dump core for privileged domain 0')
Perhaps it's the case that there's no guarantees as to the error state after a successful call.
The problem you're hitting is that the last error is only valid until the next public API call. virDomainFree is a public API call, so you can't expect to access the last error, from the virDomainCoreDump after you call virDomainFree.
I think you're saying what I'm saying, right? regards john
participants (2)
-
Daniel P. Berrange
-
John Levon