Port-xen archive

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

Re: NetBSD/Xen Howto



Manuel Bouyer <bouyer%antioche.eu.org@localhost> writes:

> On Tue, Mar 07, 2006 at 10:54:16PM +0100, Rainer Brinkmöller wrote:
>> 
>> >shutdown -p will cause the domain to shutdown and destroy once shutdown
>> >is complete.
>> >
>> At my environment not that way, that it brings me back to dom0.
>> It just stay at this message without the dom0 prompt.
>> So i have to use Ctrl + ]
>
> Any character will cause the console to exit. xm just fail to detect
> the other end of the socket has been closed until it tries to send
> something.

This is actually a bug in xentools that I found the other day; the
process that's reading goes into a loop on EOF instead of stopping.

I have an untidy patch that fixes this, and also introduces a new
feature where setting TERM=xencons_noescape in the environment
disables the ^] escape sequence, for use inside something like
conserver.  I'm attaching it in its current form so that, if I wind up
without time to clean it up, someone else can if they feel like it.

-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
--- xen/util/console_client.py  2005-08-03 19:57:58.000000000 -0400
+++ xen/util/console_client.py  2006-02-09 23:14:54.000000000 -0500
@@ -17,12 +17,22 @@
 OSPEED = 5
 CC     = 6
 
+doescape = True
+try:
+    if os.environ["TERM"] == "xencons_noescape":
+        doescape = False
+except:
+    pass
+
+kid_pid = False
+
 def __child_death(signum, frame):
-    global stop
+    global stop, kid_pid
     stop = True
+    kid_pid = False
 
 def __recv_from_sock(sock):
-    global stop
+    global stop, kid_pid
     stop = False
     while not stop:
         try:
@@ -31,14 +41,20 @@
             if error[0] != errno.EINTR:
                 raise
         else:
-            try:
-                os.write(1, data)
-            except os.error, error:
-                if error[0] != errno.EINTR:
-                    raise
+            if not data:
+                stop = True
+            else:
+                try:
+                    os.write(1, data)
+                except os.error, error:
+                    if error[0] != errno.EINTR:
+                        raise
+    if kid_pid:
+       os.kill(kid_pid, signal.SIGHUP)
     os.wait()
 
 def __send_to_sock(sock):
+    global doescape
     while 1:
         try:
             data = os.read(0,1024)
@@ -46,7 +62,7 @@
             if error[0] != errno.EINTR:
                 raise
         else:
-            if ord(data[0]) == ord(']')-64:
+            if doescape and ord(data[0]) == ord(']')-64:
                 break
             try:
                 sock.send(data)
@@ -58,6 +74,7 @@
     sys.exit(0)
 
 def connect(host,port):
+    global kid_pid
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
     sock.connect((host,port))
 
@@ -71,16 +88,18 @@
     nattrs[CC][VMIN] = 1
     nattrs[CC][VTIME] = 0
 
-    if os.fork():
+    kid_pid = os.fork()
+    if kid_pid:
         signal.signal(signal.SIGCHLD, __child_death)
-        print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********"
+        if doescape: print "************ REMOTE CONSOLE: CTRL-] TO QUIT 
********"
         tcsetattr(0, TCSAFLUSH, nattrs)
         try:
             __recv_from_sock(sock)
         finally:
             tcsetattr(0, TCSAFLUSH, oattrs)
-            print
-            print "************ REMOTE CONSOLE EXITED *****************"
+            if doescape:
+                print
+                print "************ REMOTE CONSOLE EXITED *****************"
     else:
         signal.signal(signal.SIGPIPE, signal.SIG_IGN)
         __send_to_sock(sock)


Home | Main Index | Thread Index | Old Index