[Libvir] [PATCH] xend 404 errors return VIR_ERR_NO_DOMAIN
Daniel Veillard
veillard at redhat.com
Wed Jul 4 13:00:09 UTC 2007
On Wed, Jul 04, 2007 at 12:07:45PM +0100, Richard W.M. Jones wrote:
> (1) Check for 404 errors from xend and turn them into VIR_ERR_NO_DOMAIN
> (currently they are VIR_ERR_POST_FAILED).
>
> You'll typically see this when you have a handle to a domain, but the
> underlying domain is shutdown, as in this example:
>
> $ python
> Python 2.4.3 (#1, Dec 11 2006, 11:39:03)
> [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import libvirt
> >>> conn = libvirt.open ("xen+tls:///")
> >>> dom = conn.lookupByName ("fc6_6")
> >>> dom.suspend ()
> 0
> >>> dom.resume ()
> 0
> #### here, I shut down the domain using 'xm'
> >>> dom.suspend ()
> libvir: Xen Daemon error : Domain not found: No such domain fc6_6
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/home/rjones/local/lib/python2.4/site-packages/libvirt.py",
> line 359, in suspend
> if ret == -1: raise libvirtError ('virDomainSuspend() failed',
> dom=self)
> libvirt.libvirtError: virDomainSuspend() failed Domain not found: No
> such domain fc6_6
Hum, I would guess xend_post can be used to call xend on calls not related
to domains (for example all calls coming from xend_node_op() though there
is only a few).
At that point content should carry some kind of error message,
I guess if you want to really try to refine the error number you would
have to look in the string retuned back. Immediately labelling it as a
domain not found error sounds a bit wrong to me. The POST operation could
have failed too for some other reason. Unfortunately except poking into
content for the returned string I don't see a way to disambiguate there.
> (2) There was a case where xend was returning an error, but we didn't
> translate that into an error return code (-1). I'm sure this is an
> oversight, and the patch fixes it.
Hum, this wasn't really an oversight, I didn't want to loose the
HTTP error code that early, I agree it's a bit confusing as the function
is said to returns the HTTP return code or -1 in case or error, if
you loose the return code then http2unix can't do its job.
Some cleanup is in order but I would not be too radical there.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
More information about the libvir-list
mailing list