From: Christoph Egger Subject: [PATCH][TOOLS] pygrub: cleanup and support for NetBSD Date: Wed, 26 Mar 2008 15:16:42 +0100 Message-ID: <200803261516.42496.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Krl6HvAMQC8YleD" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_Krl6HvAMQC8YleD Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Keir, Attached patch gets rid of the global attr variable and adds support for=20 NetBSD. Signed-off-by: Christoph Egger =2D-=20 AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Gesch=E4ftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplement=E4r: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Gesch=E4ftsf=FChrer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy --Boundary-00=_Krl6HvAMQC8YleD Content-Type: text/x-diff; charset="us-ascii"; name="tools_pygrub.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tools_pygrub.diff" diff -r 966c04d42e94 tools/pygrub/src/pygrub --- a/tools/pygrub/src/pygrub Wed Mar 26 09:12:57 2008 +0000 +++ b/tools/pygrub/src/pygrub Wed Mar 26 16:33:01 2008 +0100 @@ -240,10 +240,10 @@ class Grub: if y > self.start_image + maxy: break if y == self.selected_image: - attr = curses.A_REVERSE - else: - attr = 0 - self.entry_win.addstr(y + 1 - self.start_image, 2, i.title.ljust(70), attr) + self.entry_win.attron(curses.A_REVERSE) + self.entry_win.addstr(y + 1 - self.start_image, 2, i.title.ljust(70)) + if y == self.selected_image: + self.entry_win.attroff(curses.A_REVERSE) self.entry_win.refresh() def edit_entry(self, origimg): @@ -269,16 +269,17 @@ class Grub: self.entry_win.box() for idx in range(1, len(img.lines)): # current line should be highlighted - attr = 0 if idx == curline: - attr = curses.A_REVERSE + self.entry_win.attron(curses.A_REVERSE) # trim the line l = img.lines[idx].ljust(70) if len(l) > 70: l = l[:69] + ">" - self.entry_win.addstr(idx, 2, l, attr) + self.entry_win.addstr(idx, 2, l) + if idx == curline: + self.entry_win.attroff(curses.A_REVERSE) self.entry_win.refresh() c = self.screen.getch() diff -r 966c04d42e94 tools/python/xen/xend/XendBootloader.py --- a/tools/python/xen/xend/XendBootloader.py Wed Mar 26 09:12:57 2008 +0000 +++ b/tools/python/xen/xend/XendBootloader.py Wed Mar 26 16:33:01 2008 +0100 @@ -12,7 +12,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import os, select, errno, stat, signal +import os, select, errno, stat, signal, tty import random import shlex from xen.xend import sxp @@ -43,6 +43,9 @@ def bootloader(blexec, disk, dom, quiet log.error(msg) raise VmError(msg) + if os.uname()[0] == "NetBSD" and disk.startswith('/dev/'): + disk = disk.replace("/dev/", "/dev/r") + mkdir.parents("/var/run/xend/boot/", stat.S_IRWXU) while True: @@ -63,12 +66,9 @@ def bootloader(blexec, disk, dom, quiet # where we copy characters between the two master fds, as well as # listening on the bootloader's fifo for the results. - # Termios runes for very raw access to the pty master fds. - attr = [ 0, 0, termios.CS8 | termios.CREAD | termios.CLOCAL, - 0, 0, 0, [0] * 32 ] - (m1, s1) = pty.openpty() termios.tcsetattr(m1, termios.TCSANOW, attr) + tty.setraw(m1); fcntl.fcntl(m1, fcntl.F_SETFL, os.O_NDELAY); os.close(s1) slavename = ptsname.ptsname(m1) @@ -109,7 +109,7 @@ def bootloader(blexec, disk, dom, quiet # record that this domain is bootloading dom.bootloader_pid = child - termios.tcsetattr(m2, termios.TCSANOW, attr) + tty.setraw(m2); fcntl.fcntl(m2, fcntl.F_SETFL, os.O_NDELAY); while True: try: --Boundary-00=_Krl6HvAMQC8YleD Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_Krl6HvAMQC8YleD--