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

[Libvir] [PATCH] xend 404 errors return VIR_ERR_NO_DOMAIN



(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

(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.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
diff -uprN --exclude=CVS --exclude=.git --exclude='*.pem' --exclude=demoCA --exclude=.gitignore --exclude='*.orig' --exclude='*.bak' libvirt-network-lookup/src/xend_internal.c libvirt-no-domain/src/xend_internal.c
--- libvirt-network-lookup/src/xend_internal.c	2007-07-03 16:54:30.000000000 +0100
+++ libvirt-no-domain/src/xend_internal.c	2007-07-04 11:59:12.000000000 +0100
@@ -512,8 +512,13 @@ xend_post(virConnectPtr xend, const char
     ret = xend_req(xend, s, content, n_content);
     close(s);
 
-    if ((ret < 0) || (ret >= 300)) {
+    if (ret == 404) {
+        /* Domain has gone away - eg. someone else shut it down. */
+        virXendError (xend, VIR_ERR_NO_DOMAIN, content);
+        ret = -1;
+    } else if ((ret < 0) || (ret >= 300)) {
         virXendError(xend, VIR_ERR_POST_FAILED, content);
+        ret = -1;
     } else if ((ret == 202) && (strstr(content, "failed") != NULL)) {
         virXendError(xend, VIR_ERR_POST_FAILED, content);
         ret = -1;

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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