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

[Xen-devel] [PATCH]fixed xm incorrect error information


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: "Zhu Han" <schumi.han@xxxxxxxxx>
  • Date: Thu, 19 Jul 2007 16:10:45 +0800
  • Delivery-date: Thu, 19 Jul 2007 01:08:36 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=DkgOGg+Ba3rqeqhKr41pGx6Jj8x78qk6yLup0xvUfaSXlLPZjkkO+zvYLIx3Gg89rbVy5lAPpmXM6JgEvoSbSBg/pjO5yvWp7MJW2TwBXqB2sSbz0sfIs9kgPxjfsJ7/VdWxBSVVEhUb3qLi6T6oNvayTdQ/q0tXBjOl1/qWtVc=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Hi, all

I don't understand why do_console in xm/create.py will try to start
the console inside a loop. If the domain crashed before execConsole,
get_domid could throw out an exception and then os.waitpid will throw
out OSError and complain about no such child process. Obviously, this
is an incorrect error information. The attached patch fixs it:

signed-off-by: Zhu Han<schumi.han@xxxxxxxxx>

diff -r 3ef0510e44d0 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue May 08 10:21:23 2007 +0100
+++ b/tools/python/xen/xm/create.py     Thu Jul 19 15:56:45 2007 +0800
@@ -1311,24 +1311,28 @@ def do_console(domain_name):
def do_console(domain_name):
    cpid = os.fork()
    if cpid != 0:
-        for i in range(10):
-            # Catch failure of the create process
-            time.sleep(1)
-            (p, rv) = os.waitpid(cpid, os.WNOHANG)
-            if os.WIFEXITED(rv):
-                if os.WEXITSTATUS(rv) != 0:
-                    sys.exit(os.WEXITSTATUS(rv))
-            try:
-                # Acquire the console of the created dom
-                if serverType == SERVER_XEN_API:
-                    domid = server.xenapi.VM.get_domid(
-                               get_single_vm(domain_name))
-                else:
-                    dom = server.xend.domain(domain_name)
-                    domid = int(sxp.child_value(dom, 'domid', '-1'))
-                console.execConsole(domid)
-            except:
-                pass
+        # Catch failure of the create process
+        time.sleep(1)
+        (p, rv) = os.waitpid(cpid, os.WNOHANG)
+        if os.WIFEXITED(rv):
+            if os.WEXITSTATUS(rv) != 0:
+                sys.exit(os.WEXITSTATUS(rv))
+        try:
+            # Acquire the console of the created dom
+            if serverType == SERVER_XEN_API:
+                domid = server.xenapi.VM.get_domid(
+                           get_single_vm(domain_name))
+            else:
+                dom = server.xend.domain(domain_name)
+                domid = int(sxp.child_value(dom, 'domid', '-1'))
+        except:
+            print("can't get domain id. domain crashed?\n")
+            sys.exit(0)
+
+        try:
+            console.execConsole(domid)
+        except:
+            pass
        print("Could not start console\n");
        sys.exit(0)


--
best regards,
hanzhu

Attachment: xm_create.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.