[Libvir] possible bug in virDomainLookupByID

I'm experiencing an odd problem in virDomainLookupByID when using 0.1.3 that does not exist when using 0.1.1. Perhaps this is a side effect of switching the backend connection? I'm curious is anyone else has seen this and/or if you have any suggestions for fixing it. The attached code generates the problem that I'm seeing. Specifically, after upgrading to 0.1.3, calling virDomainLookupByID twice results in a failure on the second call. This behavior was not seen in 0.1.1. Any thoughts? Thanks, bryan PS... This problem is seen in XenAccess. Thanks to Daniele Sgandurra for bringing it to my attention. #include <stdio.h> #include <string.h> #include <libvirt/libvirt.h> #include <libvirt/virterror.h> #include <libxml/parser.h> #include <libxml/tree.h> char *get_xml_info (int id) { virConnectPtr conn = NULL; virDomainPtr dom = NULL; char *xml_data = NULL; /* NULL means connect to local Xen hypervisor */ conn = virConnectOpenReadOnly(NULL); if (NULL == conn) { printf("ERROR: Failed to connect to hypervisor\n"); goto error_exit; } /* Find the domain of the given id */ dom = virDomainLookupByID(conn, id); if (NULL == dom) { virErrorPtr error = virConnGetLastError(conn); printf("(%d) %s\n", error->code, error->message); printf("ERROR: Failed to find Domain %d\n", id); goto error_exit; } xml_data = virDomainGetXMLDesc(dom, 0); error_exit: if (NULL!= dom) virDomainFree(dom); if (NULL!= conn) virConnectClose(conn); return xml_data; } int main () { char *xml = NULL; xml = get_xml_info(1); if (!xml){ printf("Failed on first try\n"); return 0; } free(xml); xml = get_xml_info(1); if (!xml){ printf("Failed on second try\n"); return 0; } free(xml); return 1; }

On Tue, Jul 18, 2006 at 11:48:29AM -0400, Bryan D. Payne wrote:
I'm experiencing an odd problem in virDomainLookupByID when using 0.1.3 that does not exist when using 0.1.1. Perhaps this is a side effect of switching the backend connection? I'm curious is anyone else has seen this and/or if you have any suggestions for fixing it.
The attached code generates the problem that I'm seeing. Specifically, after upgrading to 0.1.3, calling virDomainLookupByID twice results in a failure on the second call. This behavior was not seen in 0.1.1. Any thoughts?
You dont mention whether you are running the test case as root or an unprivileged user ? Also what config options are in your /etc/xen/xend-config.sxp file ? As root your test case succeeds in getting the XML. As non-root, I see a failure on the first call - the test case is a little bit misleading though - virDomainLookupByID is working fine - the place I see failure is in the virDomainGetXMLDesc - which is because the setuid proxy doesn't not yet support fetching the XML. The only thing I can think ofis that you have HTTP enabled for XenD so that getting the XML is working, but then for some reason the proxy is shutting down prematurely causing a failure of virDomainLookupByID. If you could send your exact /etc/xen/xend-config.sxp file it would help me reproduce the problem here. Oh, what Xen version and distro are you using And is it 32 or 64 bit would be helpful
PS... This problem is seen in XenAccess. Thanks to Daniele Sgandurra for bringing it to my attention.
I'm curious - what is XenAccess you mention here ? Is this some application being developed with libvirt ? Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

You dont mention whether you are running the test case as root or an unprivileged user ? Also what config options are in your /etc/xen/xend-config.sxp file ?
I'm running as root. My xend-config is attached.
As root your test case succeeds in getting the XML. As non-root, I see a failure on the first call - the test case is a little bit misleading though - virDomainLookupByID is working fine - the place I see failure is in the virDomainGetXMLDesc - which is because the setuid proxy doesn't not yet support fetching the XML.
In my case, the failure is with virDomainLookupByID. For example, I get the following output: [root@guinness examples]# ./test (0) (null) ERROR: Failed to find Domain 1 Failed on second try [root@guinness examples]#
reproduce the problem here. Oh, what Xen version and distro are you using And is it 32 or 64 bit would be helpful
[root@guinness examples]# xm info host : guinness.beer.home release : 2.6.16-xen version : #1 SMP Tue Jun 20 22:00:41 EDT 2006 machine : i686 nr_cpus : 1 nr_nodes : 1 sockets_per_node : 1 cores_per_socket : 1 threads_per_core : 1 cpu_mhz : 2202 hw_caps : 078bfbff:e3d3fbff:00000000:00000010:00000000:00000001:00000001 total_memory : 2048 free_memory : 1 xen_major : 3 xen_minor : 0 xen_extra : .2-2 xen_caps : xen-3.0-x86_32 platform_params : virt_start=0xfc000000 xen_changeset : Thu Apr 13 15:18:37 2006 +0100 9617:5802713c159b cc_compiler : gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) cc_compile_by : root cc_compile_domain : beer.home cc_compile_date : Tue Jun 20 22:02:29 EDT 2006 [root@guinness examples]# I'm running xen 3.0.2-2, built from source. My machine is running FC5 (32-bit). When I tested the two libvirt versions, I build both directly from source using the standard (./configure ; make ; make install).
I'm curious - what is XenAccess you mention here ? Is this some application being developed with libvirt ?
Yes, XenAccess is a project that I'm working on to provide introspection for Xen. Currently, I use libvirt to obtain the kernel version of a running domain, but may use it for more info in the future. Details available here: http://xenaccess.sourceforge.net/ Thanks, bryan

On Tue, Jul 18, 2006 at 12:57:23PM -0400, Bryan D. Payne wrote:
You dont mention whether you are running the test case as root or an unprivileged user ? Also what config options are in your /etc/xen/xend-config.sxp file ?
I'm running as root. My xend-config is attached.
ok, it looks like you have got both the TCP & UNIX sockets for XenD turned off. Although libvirt uses the hypervisor for many operations there are several for which we have to use XenD. Our recommendation at this time is to enable unix sockets with the following config option: (xend-unix-server yes)
I'm curious - what is XenAccess you mention here ? Is this some application being developed with libvirt ?
Yes, XenAccess is a project that I'm working on to provide introspection for Xen. Currently, I use libvirt to obtain the kernel version of a running domain, but may use it for more info in the future. Details available here:
Thanks, that looks like an interesting project for me to take alook at. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Tue, Jul 18, 2006 at 01:34:10PM -0400, Bryan D. Payne wrote:
there are several for which we have to use XenD. Our recommendation at this time is to enable unix sockets with the following config option:
(xend-unix-server yes)
Good to know. This seems to have fixed the problem. Thanks!
Well there is still a few outstanding problems: - in case of failure of communications this should be reported better than that - the two successive calls should fail in the same way isn't it ? - maybe XML dump should be added too when using the proxy I'm not sure I will have time this week to address those issues, could you enter a bugzilla entry, so I have something remembering me to look at it when I have some time ? thanks ! Daniel -- Daniel Veillard | Red Hat http://redhat.com/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (3)
-
Bryan D. Payne
-
Daniel P. Berrange
-
Daniel Veillard