From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OsOgf-0008CG-Eo for mharc-grub-devel@gnu.org; Sun, 05 Sep 2010 19:31:49 -0400 Received: from [140.186.70.92] (port=57596 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsOgb-00089X-LJ for grub-devel@gnu.org; Sun, 05 Sep 2010 19:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsOga-0005vq-2X for grub-devel@gnu.org; Sun, 05 Sep 2010 19:31:45 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:64515) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsOgZ-0005vg-Mz for grub-devel@gnu.org; Sun, 05 Sep 2010 19:31:44 -0400 Received: by ewy28 with SMTP id 28so2192320ewy.0 for ; Sun, 05 Sep 2010 16:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=EKX7jUKYmWcZgCk54Fge6FPNNKBAl+1OuZyItzyQsv8=; b=HNXAzpjdi/UrPDA37PcrV0oITQBuOxCP+xzR0zv7QJh8s0lRhj3u+nCY9VwL3AZ4CR D3TfyFGz8r3ZkcctfQi+i78Az7rXvu2mWePqw72TILCNKiYOHwIMo3f2YEOmChy5mhfz 1m4/kXsk1v21BlQKfH3D1kvDscZSnIdiTo9/A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=E9Dd2fA4R2Xajz0+VEgtoZV2NBtaR9Mw38z8HpOXplT+ocaFDNSX1n56SkhBKVS4UG kBBsivSvWVHPZsHeH0pBfDJchCE86gjzyRb0ShRfARexlT/q9ZrCqRBUGfY3HEMGfIHE eR1SDfb0q/5gOrHQUsosjbzU2AqMK/IJn6PnY= Received: by 10.213.104.203 with SMTP id q11mr1564402ebo.12.1283729502928; Sun, 05 Sep 2010 16:31:42 -0700 (PDT) Received: from debian.bg45.phnet (124.117.63.81.cust.bluewin.ch [81.63.117.124]) by mx.google.com with ESMTPS id a48sm7058973eei.1.2010.09.05.16.31.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 05 Sep 2010 16:31:41 -0700 (PDT) Message-ID: <4C84284E.309@gmail.com> Date: Mon, 06 Sep 2010 01:31:26 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100805 Icedove/3.0.6 MIME-Version: 1.0 To: grub-devel@gnu.org References: <4C818D2D.5060907@gmail.com> <4C8422E4.2050002@omniflux.com> In-Reply-To: <4C8422E4.2050002@omniflux.com> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig7F0F1D5377836C53DC7265DD" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [RFT] PXE chainloader X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Sep 2010 23:31:47 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig7F0F1D5377836C53DC7265DD Content-Type: multipart/mixed; boundary="------------000608090009050903050107" This is a multi-part message in MIME format. --------------000608090009050903050107 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/06/2010 01:08 AM, Omni Flux wrote: > The output of two tests follow. It works, to an extent. Is PXE being > left in a state where the next bootloader can call it's initialization > routines again? > Attached patch may help. I noticed that last file may still remain opened= =2E > > Test 1: Boot grub PXE, chainload grub PXE, chainload grub PXE again. > Result: Chainloaded grub PXEs load in rescue mode. > > Pre-boot eXecution Environment (PXE) 2.43 > (C) Copyright 1999 Intel Corporation > (C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com > Corporation > All rights reserved > > > CLIENT MAC ADDR: XX XX XX XX XX XX GUID: > 00020003-0004-0005-0006-000700080009 > CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 > GATEWAY IP: 192.168.2.1 > Welcome to GRUB! > > GNU GRUB version 1.98 > > Minimal BASH-like line editing is supported. For the first word, TAB= > lists possible command completions. Anywhere else TAB lists possible= > device or file completions. > > > grub> pxechainloader (pxe)/boot/grub/grub2pxe > grub> boot > Welcome to GRUB! > > error: file not found. > Entering rescue mode... > grub rescue> insmod pxechain > grub rescue> pxechainloader (pxe)/boot/grub/grub2pxe > grub rescue> boot > Welcome to GRUB! > > error: file not found. > Entering rescue mode... > grub rescue> > > > > > > > > > > Test 2: Boot grub PXE, chainload pxelinux (Debian Lenny net installer) > Result: Chainloaded pxelinux fails to initialize UDP stack. > > Pre-boot eXecution Environment (PXE) 2.43 > (C) Copyright 1999 Intel Corporation > (C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com > Corporation > All rights reserved > > > CLIENT MAC ADDR: XX XX XX XX XX XX GUID: > 00020003-0004-0005-0006-000700080009 > CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 > GATEWAY IP: 192.168.2.1 > Welcome to GRUB! > > GNU GRUB version 1.98 > > Minimal BASH-like line editing is supported. For the first word, TAB= > lists possible command completions. Anywhere else TAB lists possible= > device or file completions. > > > grub> pxechainloader (pxe)/boot/debian/lenny/i386/pxelinux.0 > grub> boot > > PXELINUX 3.71 Debian-2008-09-06 Copyright (C) 1994-2008 H. Peter Anvin= > Found PXENV+ structure > PXE API version is 0201 > UNDI data segment at: 00096690 > UNDI data segment size: 4801 > UNDI code segment at: 0009AEA0 > UNDI code segment size: 3160 > PXE entry point found (we hope) at 9AEA:00FA > Getting cached packet 01 > Getting cached packet 02 > Getting cached packet 03 > My IP address seemes to be 45A84865 192.168.2.101 > ip=3D192.168.2.101:192.168.1.1:192.168.2.1:255.255.255.0 > Failed to initialize UDP stack > > Boot failed: press a key to retry, or wait for reset... > --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------000608090009050903050107 Content-Type: text/x-diff; name="pxechain.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pxechain.diff" =3D=3D=3D modified file 'grub-core/Makefile.core.def' --- grub-core/Makefile.core.def 2010-08-30 13:13:38 +0000 +++ grub-core/Makefile.core.def 2010-09-03 23:57:56 +0000 @@ -1064,6 +1064,12 @@ }; =20 module =3D { + name =3D pxechain; + i386_pc =3D loader/i386/pc/pxechainloader.c; + enable =3D i386_pc; +}; + +module =3D { name =3D multiboot2; cppflags =3D "-DGRUB_USE_MULTIBOOT2"; =20 =3D=3D=3D modified file 'grub-core/fs/i386/pc/pxe.c' --- grub-core/fs/i386/pc/pxe.c 2010-09-02 13:47:03 +0000 +++ grub-core/fs/i386/pc/pxe.c 2010-09-05 23:28:35 +0000 @@ -522,12 +522,17 @@ void grub_pxe_unload (void) { + struct grub_pxenv_tftp_close c; + if (grub_pxe_pxenv) { grub_fs_unregister (&grub_pxefs_fs); grub_disk_dev_unregister (&grub_pxe_dev); - - grub_pxe_pxenv =3D 0; + if (curr_file !=3D 0) + { + grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c, pxe_rm_entry); + curr_file =3D 0; + } } } =20 =3D=3D=3D added file 'grub-core/loader/i386/pc/pxechainloader.c' --- grub-core/loader/i386/pc/pxechainloader.c 1970-01-01 00:00:00 +0000 +++ grub-core/loader/i386/pc/pxechainloader.c 2010-09-05 23:29:09 +0000 @@ -0,0 +1,132 @@ +/* chainloader.c - boot another boot loader */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, In= c. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by= + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static grub_dl_t my_mod; +static struct grub_relocator *rel; +static grub_uint32_t edx =3D 0xffffffff; + +static grub_err_t +grub_pxechain_boot (void) +{ + struct grub_relocator16_state state =3D {=20 + .cs =3D 0, + .ip =3D 0x7c00, + .ds =3D 0, + .es =3D 0, + .fs =3D 0, + .gs =3D 0, + .ss =3D 0, + .sp =3D 0x7c00, + .edx =3D edx + }; + grub_video_set_mode ("text", 0, 0); + + grub_pxe_unload (); + + return grub_relocator16_boot (rel, state); +} + +static grub_err_t +grub_pxechain_unload (void) +{ + grub_relocator_unload (rel); + rel =3D NULL; + grub_dl_unref (my_mod); + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_cmd_pxechain (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + grub_file_t file =3D 0; + grub_err_t err; + void *image; + grub_size_t imagesize; + + if (argc =3D=3D 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); + + grub_dl_ref (my_mod); + + rel =3D grub_relocator_new (); + if (!rel) + goto fail; + + file =3D grub_file_open (argv[0]); + if (! file) + goto fail; + + + edx =3D grub_get_root_biosnumber (); + + imagesize =3D grub_file_size (file); + { + grub_relocator_chunk_t ch; + err =3D grub_relocator_alloc_chunk_addr (rel, &ch, 0x7c00, imagesize= ); + if (err) + goto fail; + image =3D get_virtual_current_address (ch); + } + + if (grub_file_read (file, image, imagesize) !=3D (grub_ssize_t) images= ize) + goto fail; +=20 + grub_loader_set (grub_pxechain_boot, grub_pxechain_unload, 1); + return GRUB_ERR_NONE; + + fail: + + if (file) + grub_file_close (file); + + grub_pxechain_unload (); + + return grub_errno; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT(pxechainloader) +{ + cmd =3D grub_register_command ("pxechainloader", grub_cmd_pxechain, + 0, N_("Chainload a PXE image.")); + my_mod =3D mod; +} + +GRUB_MOD_FINI(pxechainloader) +{ + grub_unregister_command (cmd); +} --------------000608090009050903050107-- --------------enig7F0F1D5377836C53DC7265DD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAkyEKE8ACgkQNak7dOguQgmV8gD/Zi4+xr+vRkXwYaSUCYKLY5s+ tMho0KGWYt6C+Z6Md1kA/1dsWZxI+WI+sBuFsXt1g1851EKZnTxt5+BiycgapUOl =vqTG -----END PGP SIGNATURE----- --------------enig7F0F1D5377836C53DC7265DD--