<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When i start xen guest from console all is OK
but</FONT></DIV>
<DIV><FONT face=Arial size=2>i have this error if i try to start from
SSH:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[root@fedora bin]# /usr/sbin/xm create -c
virtual7<BR>Using config file "/etc/xen/virtual7".</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Traceback (most recent call last):<BR> File
"/usr/bin/pygrub", line 258, in ?<BR>
curses.wrapper(run_main)<BR> File "/usr/lib/python2.4/curses/wrapper.py",
line 44, in wrapper<BR> return func(stdscr, *args,
**kwds)<BR> File "/usr/bin/pygrub", line 214, in
run_main<BR> sel = main(cf)<BR> File "/usr/bin/pygrub",
line 162, in main<BR> (stdscr, win) = draw_window()<BR>
File "/usr/bin/pygrub", line 33, in draw_window<BR>
curses.use_default_colors()<BR>_curses.error: use_default_colors() returned
ERR<BR>Error: Boot loader didn't return any data!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Any Ideas ?</FONT></DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This is my envirorment:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>OS: Fedora core 5</FONT></DIV>
<DIV><FONT face=Arial size=2>XEN version:</FONT></DIV>
<DIV><FONT face=Arial size=2>Name :
xen
Relocations: (not relocatable)<BR>Version :
3.0.2
Vendor: Red Hat, Inc.<BR>Release :
0.FC5.1
Build Date: gio 04 mag 2006 17:27:42 CEST<BR>Install Date: ven 12 mag 2006
18:45:01 CEST Build Host:
hs20-bc1-5.build.redhat.com<BR>Group :
Development/Libraries Source
RPM: xen-3.0.2-0.FC5.1.src.rpm<BR>Size
:
3903916
License: GPL<BR>Signature : DSA/SHA1, gio 04 mag 2006 19:03:45 CEST,
Key ID da84cbd430c9ecf8<BR>Packager : Red Hat, Inc. <<A
href="http://bugzilla.redhat.com/bugzilla">http://bugzilla.redhat.com/bugzilla</A>><BR>URL
: <A
href="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html">http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Kernel version:</FONT></DIV>
<DIV><FONT face=Arial size=2>kernel-xen0-2.6.16-1.2096_FC5.i686.rpm</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Kernel guest version: 2.6.15-1.2054_FC5xenU
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>---------------------------------------------------------------------------------</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>[root@fedora bin]# cat
/usr/bin/pygrub<BR>#!/usr/bin/python<BR>#<BR># pygrub - simple python-based
bootloader for Xen<BR>#<BR># Copyright 2005 Red Hat, Inc.<BR># Jeremy Katz
<<A href="mailto:katzj@redhat.com">katzj@redhat.com</A>><BR>#<BR># This
software may be freely redistributed under the terms of the GNU<BR># general
public license.<BR>#<BR># You should have received a copy of the GNU General
Public License<BR># along with this program; if not, write to the Free
Software<BR># Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
USA.<BR>#</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import os, sys, string, struct, tempfile<BR>import
logging</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import curses, _curses, curses.wrapper<BR>import
getopt</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>sys.path = [ '/usr/lib/python' ] +
sys.path</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import grub.GrubConf<BR>import
grub.fsys</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>PYGRUB_VER = 0.3</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR>def draw_window():<BR> stdscr =
curses.initscr()<BR> if hasattr(curses,
'use_default_colors'):<BR>
curses.use_default_colors()<BR>
try:<BR>
curses.curs_set(0)<BR> except
_curses.error:<BR> pass</DIV>
<DIV> </DIV>
<DIV> stdscr.addstr(1, 4, "pyGRUB version %s"
%(PYGRUB_VER,))</DIV>
<DIV> </DIV>
<DIV> win = curses.newwin(10, 74, 2, 1)<BR>
win.box()<BR> win.refresh()</DIV>
<DIV> </DIV>
<DIV> stdscr.addstr(12, 5, "Use the U and D keys to select
which entry is highlighted.")<BR> stdscr.addstr(13, 5, "Press
enter to boot the selected OS. 'e' to edit the")<BR>
stdscr.addstr(14, 5, "commands before booting, 'a' to modify the kernel
arguments ")<BR> stdscr.addstr(15, 5, "before booting, or 'c'
for a command line.")<BR> stdscr.addch(12, 13,
curses.ACS_UARROW)<BR> stdscr.addch(12, 19,
curses.ACS_DARROW)<BR> (y, x) =
stdscr.getmaxyx()<BR> stdscr.move(y - 1, x - 1)</DIV>
<DIV> </DIV>
<DIV> stdscr.refresh()<BR> return (stdscr,
win)</DIV>
<DIV> </DIV>
<DIV>def fill_entries(win, cfg, selected):<BR> y = 0</DIV>
<DIV> </DIV>
<DIV> for i in
cfg.images:<BR> if (0, y) >
win.getmaxyx():<BR>
break<BR> if y ==
selected:<BR>
attr = curses.A_REVERSE<BR>
else:<BR> attr
= 0<BR> win.addstr(y + 1, 2,
i.title.ljust(70), attr)<BR> y +=
1<BR> win.refresh()</DIV>
<DIV> </DIV>
<DIV>def select(win, line):<BR>
win.attron(curses.A_REVERSE)<BR> win.redrawln(line + 1,
1)<BR> win.refresh()</DIV>
<DIV> </DIV>
<DIV>def is_disk_image(file):<BR> fd = os.open(file,
os.O_RDONLY)<BR> buf = os.read(fd, 512)<BR>
os.close(fd)</DIV>
<DIV> </DIV>
<DIV> if len(buf) >= 512 and struct.unpack("H", buf[0x1fe:
0x200]) == (0xaa55,):<BR> return
True<BR> return False</DIV>
<DIV> </DIV>
<DIV>SECTOR_SIZE=512<BR>def get_active_offset(file):<BR>
"""Find the offset for the start of the first active partition in
the<BR> disk image file."""<BR> fd =
os.open(file, os.O_RDONLY)<BR> buf = os.read(fd,
512)<BR> for poff in (446, 462, 478, 494): # partition
offsets<BR> # active partition has
0x80 as the first byte<BR> if
struct.unpack("<c", buf[poff:poff+1]) ==
('\x80',):<BR>
return struct.unpack("<L", buf[poff+8:poff+12])[0] *
SECTOR_SIZE<BR> return -1</DIV>
<DIV> </DIV>
<DIV>def get_config(fn, isconfig = False):<BR> if not
os.access(fn, os.R_OK):<BR> raise
RuntimeError, "Unable to access %s" %(fn,)</DIV>
<DIV> </DIV>
<DIV> cf = grub.GrubConf.GrubConfigFile()</DIV>
<DIV> </DIV>
<DIV> if
isconfig:<BR> # set the config file
and parse it<BR> cf.filename =
fn<BR>
cf.parse()<BR> return cf</DIV>
<DIV> </DIV>
<DIV> offset = 0<BR> if
is_disk_image(fn):<BR> offset =
get_active_offset(fn)<BR> if offset ==
-1:<BR> raise
RuntimeError, "Unable to find active partition on disk"</DIV>
<DIV> </DIV>
<DIV> # open the image and read the grub
config<BR> fs = None<BR> for fstype in
grub.fsys.fstypes.values():<BR> if
fstype.sniff_magic(fn,
offset):<BR>
fs = fstype.open_fs(fn,
offset)<BR>
break</DIV>
<DIV> </DIV>
<DIV> if fs is not
None:<BR> grubfile =
None<BR> for f in
("/boot/grub/menu.lst",
"/boot/grub/grub.conf",<BR>
"/grub/menu.lst",
"/grub/grub.conf"):<BR>
if
fs.file_exist(f):<BR>
grubfile =
f<BR>
break<BR> if grubfile is
None:<BR>
raise RuntimeError, "we couldn't find /boot/grub{menu.lst,grub.conf} " +
\<BR>
"in the image provided. halt!"<BR> f =
fs.open_file(grubfile)<BR> buf =
f.read()<BR>
f.close()<BR>
fs.close()<BR> # then parse the grub
config<BR>
cf.parse(buf)<BR>
else:<BR> raise RuntimeError, "Unable
to read filesystem" <BR> <BR> return
cf</DIV>
<DIV> </DIV>
<DIV>def get_entry_idx(cf, entry):<BR> # first, see if the
given entry is numeric<BR>
try:<BR> idx =
string.atoi(entry)<BR> return
idx<BR> except
ValueError:<BR> pass</DIV>
<DIV> </DIV>
<DIV> # it's not, now check the labels for a
match<BR> for i in
range(len(cf.images)):<BR> if entry ==
cf.images[i].title:<BR>
return i</DIV>
<DIV> </DIV>
<DIV> return None</DIV>
<DIV> </DIV>
<DIV>def main(cf = None):<BR> mytime = 0<BR>
timeout = int(cf.timeout)</DIV>
<DIV> </DIV>
<DIV> (stdscr, win) = draw_window()<BR>
stdscr.timeout(1000)<BR> selected =
cf.default<BR> <BR> while (timeout == -1 or
mytime < int(timeout)):<BR> if
timeout != -1 and mytime != -1:
<BR>
stdscr.addstr(20, 5, "Will boot selected entry in %2d
seconds"<BR>
%(int(timeout) - mytime))<BR>
else:<BR>
stdscr.addstr(20, 5, " " *
80)<BR>
<BR> fill_entries(win, cf,
selected)<BR> c =
stdscr.getch()<BR> if mytime !=
-1:<BR> mytime
+= 1<BR># if c ==
ord('q'):<BR>#
selected =
-1<BR>#
break<BR> if c ==
ord('c'):<BR>
# FIXME: needs to go to command line
mode<BR>
continue<BR> elif c ==
ord('a'):<BR>
# FIXME: needs to go to append
mode<BR>
continue<BR> elif c ==
ord('e'):<BR>
# FIXME: needs to go to edit
mode<BR>
continue<BR> elif c in
(curses.KEY_ENTER, ord('\n'),
ord('\r')):<BR>
break<BR> elif c ==
curses.KEY_UP:<BR>
mytime =
-1<BR>
selected -= 1<BR> elif c ==
curses.KEY_DOWN:<BR>
mytime =
-1<BR>
selected += 1<BR>
else:<BR>
pass</DIV>
<DIV> </DIV>
<DIV> # bound at the top and
bottom<BR> if selected <
0:<BR>
selected = 0<BR> elif selected >=
len(cf.images):<BR>
selected = len(cf.images) - 1</DIV>
<DIV> </DIV>
<DIV> if selected >=
0:<BR> return selected</DIV>
<DIV> </DIV>
<DIV>if __name__ == "__main__":<BR> sel =
None<BR> <BR> def run_main(scr,
*args):<BR> global
sel<BR> sel = main(cf)</DIV>
<DIV> </DIV>
<DIV> def
usage():<BR> print >>
sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--entry=] <image>"
%(sys.argv[0],)</DIV>
<DIV> </DIV>
<DIV> try:<BR> opts,
args = getopt.gnu_getopt(sys.argv[1:],
'qh::',<BR>
["quiet", "help", "output=",
"entry=",<BR>
"isconfig"])<BR> except
getopt.GetoptError:<BR>
usage()<BR> sys.exit(1)</DIV>
<DIV> </DIV>
<DIV> if len(args) <
1:<BR>
usage()<BR>
sys.exit(1)<BR> file =
args[0]<BR> <BR>
output = None<BR> entry = None<BR>
interactive = True<BR> isconfig = False<BR>
for o, a in opts:<BR> if o in ("-q",
"--quiet"):<BR>
interactive = False<BR> elif o in
("-h",
"--help"):<BR>
usage()<BR>
sys.exit()<BR> elif o in
("--output",):<BR>
output = a<BR> elif o in
("--entry",):<BR>
entry = a<BR>
# specifying the entry to boot implies
non-interactive<BR>
interactive = False<BR> elif o in
("--isconfig",):<BR>
isconfig = True</DIV>
<DIV> </DIV>
<DIV> if output is None or output ==
"-":<BR> fd =
sys.stdout.fileno()<BR>
else:<BR> fd = os.open(output,
os.O_WRONLY)</DIV>
<DIV> </DIV>
<DIV> cf = get_config(file, isconfig)<BR> if
interactive:<BR>
curses.wrapper(run_main)<BR>
else:<BR> sel = cf.default</DIV>
<DIV> </DIV>
<DIV> # set the entry to boot as
requested<BR> if entry is not
None:<BR> idx = get_entry_idx(cf,
entry)<BR> if idx is not None and idx
> 0 and idx <
len(cf.images):<BR>
sel = idx</DIV>
<DIV> </DIV>
<DIV> img = cf.images[sel]<BR> print "Going
to boot %s" %(img.title)<BR> print " kernel: %s"
%(img.kernel[1],)<BR> if
img.initrd:<BR> print " initrd:
%s" %(img.initrd[1],)</DIV>
<DIV> </DIV>
<DIV> offset = 0<BR> if
is_disk_image(file):<BR> offset =
get_active_offset(file)<BR> if offset
== -1:<BR>
raise RuntimeError, "Unable to find active partition on disk"</DIV>
<DIV> </DIV>
<DIV> # read the kernel and initrd onto the
hostfs<BR> fs = None<BR> for fstype in
grub.fsys.fstypes.values():<BR> if
fstype.sniff_magic(file,
offset):<BR>
fs = fstype.open_fs(file,
offset)<BR>
break</DIV>
<DIV> </DIV>
<DIV> if fs is
None:<BR> raise RuntimeError, "Unable
to open filesystem"</DIV>
<DIV> </DIV>
<DIV> kernel =
fs.open_file(img.kernel[1],).read()<BR> (tfd, fn) =
tempfile.mkstemp(prefix="vmlinuz.", dir="/var/lib/xen")<BR>
os.write(tfd, kernel)<BR> os.close(tfd)<BR>
sxp = "linux (kernel %s)" %(fn,)</DIV>
<DIV> </DIV>
<DIV> if
img.initrd:<BR> initrd =
fs.open_file(img.initrd[1],).read()<BR>
(tfd, fn) = tempfile.mkstemp(prefix="initrd.",
dir="/var/lib/xen")<BR> os.write(tfd,
initrd)<BR>
os.close(tfd)<BR> sxp += "(ramdisk
%s)" %(fn,)<BR>
else:<BR> initrd =
None<BR> sxp += "(args '%s')" %(img.args,)</DIV>
<DIV> </DIV>
<DIV> sys.stdout.flush()<BR> os.write(fd,
sxp)</DIV>
<DIV>---------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>