Skip to contentSkip to conversation

fixed xm incorrect error information

PATCH New Zhu Han 1 participant 1 message Jul 19, 2007

lore
Share & tools
lore

Zhu Han

author
#0 lore raw

PATCH 1/1 fixed xm incorrect error information

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:

tools/python/xen/xm/create.py +0 -0
diff -r 3ef0510e44d0 tools/python/xen/xm/create.py
@@ -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)
Signature · 2 lines
best regards,
hanzhu
tools/python/xen/xm/create.py +22 -18
diff -r 3ef0510e44d0 tools/python/xen/xm/create.py
@@ -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)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel