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

[Xen-changelog] Change the console handling, to remove the loop and timeout if a console fails



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID b67f9f21fd9c2a49bb11681638c7b7c70006002b
# Parent  4195392fba061cda1e6a710fe530edf4fbe521a0
Change the console handling, to remove the loop and timeout if a console fails
to respond first time.  For restored and unpaused domains there is no need for
the console to output data, so we cannot use this as a way to detect the
liveness of a console.  Instead, a command must always be sent to the console,
which means that this failure can only be detected once the constructor of the
Console class has returned successfully.  The __chewall loop still remains, in
order to detect runaway consoles and to clear out previous data from the
console before executing commands, but we no longer treat failure of that
method to read data as a failure of the console itself.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 4195392fba06 -r b67f9f21fd9c tools/xm-test/lib/XmTestLib/Console.py
--- a/tools/xm-test/lib/XmTestLib/Console.py    Sun Nov 27 01:02:36 2005
+++ b/tools/xm-test/lib/XmTestLib/Console.py    Sun Nov 27 01:06:20 2005
@@ -66,37 +66,25 @@
         self.historySaveCmds  = historySaveCmds
         self.debugMe          = False
         self.limit            = None
-        self.delay            = 2
 
         consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
 
-        start = time.time()
-
-        while (time.time() - start) < self.TIMEOUT:
-            if verbose:
-                print "Console executing: %s" % str(consoleCmd)
-
-            pid, fd = pty.fork()
-
-            if pid == 0:
-                os.execvp("/usr/sbin/xm", consoleCmd[1:])
-
-            self.consolePid = pid
-            self.consoleFd  = fd
-
-            tty.setraw(self.consoleFd, termios.TCSANOW)
-            
-            bytes = self.__chewall(self.consoleFd)
-
-            if bytes > 0:
-                return
-
-            if verbose:
-                print "Console didn't attach, waiting %i sec..." % self.delay
-            time.sleep(self.delay)
-
-        raise ConsoleError("Console didn't respond after %i secs" % 
self.TIMEOUT)
-    
+        if verbose:
+            print "Console executing: %s" % str(consoleCmd)
+
+        pid, fd = pty.fork()
+
+        if pid == 0:
+            os.execvp("/usr/sbin/xm", consoleCmd[1:])
+
+        self.consolePid = pid
+        self.consoleFd  = fd
+
+        tty.setraw(self.consoleFd, termios.TCSANOW)
+
+        self.__chewall(self.consoleFd)
+
+
     def __addToHistory(self, line):
         self.historyBuffer.append(line)
         self.historyLines += 1
@@ -145,8 +133,8 @@
                     if self.debugMe:
                         sys.stdout.write(foo)
                     bytes += 1
-                except:
-                    timeout += 1
+                except Exception, exn:
+                    raise ConsoleError(str(exn))
 
             else:
                 timeout += 1
@@ -174,7 +162,7 @@
 
         os.write(self.consoleFd, "%s\n" % command)
 
-        while 1==1:
+        while True:
             i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT)
 
             if self.consoleFd in i:
@@ -183,9 +171,10 @@
                     if self.debugMe:
                         sys.stdout.write(str)
                     bytes += 1
-                except:
-                    raise ConsoleError("Failed to read from console (fd=%i)"
-                                       % self.consoleFd)
+                except Exception, exn:
+                    raise ConsoleError(
+                        "Failed to read from console (fd=%i): %s" %
+                        (self.consoleFd, exn))
             else:
                 raise ConsoleError("Timed out waiting for console")
 
diff -r 4195392fba06 -r b67f9f21fd9c 
tools/xm-test/tests/restore/01_restore_basic_pos.py
--- a/tools/xm-test/tests/restore/01_restore_basic_pos.py       Sun Nov 27 
01:02:36 2005
+++ b/tools/xm-test/tests/restore/01_restore_basic_pos.py       Sun Nov 27 
01:06:20 2005
@@ -63,6 +63,9 @@
 # Make sure it's alive
 try:
     newConsole = XmConsole(domain.getName())
+    run = newConsole.runCmd("ls")
+    if run["return"] != 0:
+        FAIL("Unable to read from restored domain")
 except ConsoleError, e:
     FAIL("Restored domain is dead (%s)" % str(e))
 
diff -r 4195392fba06 -r b67f9f21fd9c 
tools/xm-test/tests/unpause/01_unpause_basic_pos.py
--- a/tools/xm-test/tests/unpause/01_unpause_basic_pos.py       Sun Nov 27 
01:02:36 2005
+++ b/tools/xm-test/tests/unpause/01_unpause_basic_pos.py       Sun Nov 27 
01:06:20 2005
@@ -70,9 +70,6 @@
 # Are we still alive after all that?
 try:
     console = XmConsole(domain.getName(), historySaveCmds=True)
-except ConsoleError, e:
-    pass
-try:
     run = console.runCmd("ls")
 except ConsoleError, e:
     FAIL(str(e))

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


 


Rackspace

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