From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YEtfW-0006wO-2v for mharc-grub-devel@gnu.org; Sat, 24 Jan 2015 00:54:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEtfT-0006rs-LO for grub-devel@gnu.org; Sat, 24 Jan 2015 00:54:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEtfQ-0004V8-BD for grub-devel@gnu.org; Sat, 24 Jan 2015 00:53:59 -0500 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]:51819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEtfP-0004V2-Un for grub-devel@gnu.org; Sat, 24 Jan 2015 00:53:56 -0500 Received: by mail-la0-f42.google.com with SMTP id ms9so936576lab.1 for ; Fri, 23 Jan 2015 21:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=aAZ77Lt1JH7gzl8oq6SZ9CMzMXmF7PLJgWnQolFcm/g=; b=EEhxPjo7tog4JcIFCQIFdK5Lc/46GhmVv88Ta/3OODUjNTS2rVrrNWPbGN7odFplzw uv/KB5tRrR3MHn1/D+n8U9QOPL9TGuKeVdEzrQqwpXEnR416XV+QzJc5AptoVpGAayMd CrAYADtdT4dkGJz6kLtWWs1dhRG/hAS1QW36eWu40TtEJULrBurxPZeFTHjgeCf7Epcn KOIm+RFPHJEr1KaXxTzDOcSVnXC8F7wpmIDJ8PeC/fckaR0mT2YF7pcwX6AsBsFAVZ5n gy2wvmKJpglquDY2kiBB05eXlwg0cMtPIqASW5YPKUWQV+ua3SqdW1tK9c/F+8ejfkcO vR2w== X-Received: by 10.112.118.144 with SMTP id km16mr8398348lbb.75.1422078834897; Fri, 23 Jan 2015 21:53:54 -0800 (PST) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id g5sm977646lag.11.2015.01.23.21.53.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 21:53:54 -0800 (PST) Date: Sat, 24 Jan 2015 08:53:52 +0300 From: Andrei Borzenkov To: Michael Chang Subject: Re: pvgrub2 and old grub menu.lst Message-ID: <20150124085352.6bec53a1@opensuse.site> In-Reply-To: <20140403065002.GA12346@linux-dsax.tai.apac.novell.com> References: <20140401074548.GB28903@linux-dsax.tai.apac.novell.com> <20140401200644.0fecf331@opensuse.site> <20140402084330.GA6303@linux-dsax.tai.apac.novell.com> <20140402201314.11f396b2@opensuse.site> <20140403065002.GA12346@linux-dsax.tai.apac.novell.com> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22a Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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: Sat, 24 Jan 2015 05:54:01 -0000 =D0=92 Thu, 3 Apr 2014 14:50:02 +0800 Michael Chang =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > On Wed, Apr 02, 2014 at 08:13:14PM +0400, Andrey Borzenkov wrote: > > =D0=92 Wed, 2 Apr 2014 14:29:50 +0400 > > Andrey Borzenkov =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > >=20 > > > On Wed, Apr 2, 2014 at 12:43 PM, Michael Chang wrot= e: > > > > On Tue, Apr 01, 2014 at 08:06:44PM +0400, Andrey Borzenkov wrote: > > > >> =D0=92 Tue, 1 Apr 2014 15:46:22 +0800 > > > >> Michael Chang =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > > >> > > > >> > While trying to boot xen pv guest with old grub config (menu.lst= ), > > > >> > the pvgrub2 loads it's menu successfully, but when you attemp to= boot > > > >> > the kernel it failed with the following message. > > > >> > > > > >> > error: couldn't load file /boot/vmlinuz-3.0.76-0.11-xen. > > > >> > error: you need to load the kernel first. > > > >> > > > > >> > Press any key to continue..." > > > >> > > > > >> > The kernel is there and boots fine with pygrub. > > > >> > > > > >> > After some investigation, it boils down to the menu.lst has expl= icitly > > > >> > set it's root device to (hd0,1) and therefore the root device is= not > > > >> > recognized by pvgrub2. > > > >> > > > > >> > title Xen -- SUSE Linux Enterprise Server 11 SP3 - 3.0.76-0.11 > > > >> > root (hd0,1) > > > >> > kernel /boot/vmlinuz-3.0.76-0.11-xen root=3D/dev/xvda2 resume= =3D/dev/xvda1 > > > >> > splash=3Dsilent showopts initrd /boot/initrd-3.0.76-0.11.xen > > > >> > > > > >> > I'd like to know whether old grub configuration is considered or= planned > > > >> > to work with pvgrub2 ? And is it a viable suggestion to have (hd= X,Y) a > > > >> > valid xen disk name because it's quite common in some existing c= onfigs ? > > > >> > > > > >> > > > >> I believe this technically should work; but this needs someone who > > > >> knows how Xen disks is mapped to hd number in legacy grub. > > > >> > > > >> It would be something like (completely untested) > > > > > > > > Thank you for the patch. I applied it and tried to test it. The > > > > virtdisks[i].handle never matched with num as it's id of the disk (= on > > > > my system it is 51712). > > > > > > >=20 > > > As I said, completely untested :) > > >=20 > > > > Please pardon my ignorant, can num be the index to the virtdisks ar= ray > > > > to get the mapped xen disk ? > > > > > > >=20 > > > pv-grub additionally sorts by handle: > > > http://xenbits.xen.org/gitweb/?p=3Dxen.git;a=3Dblob;f=3Dstubdom/grub/= mini-os.c;h=3D9d4bcc76d5f3e9907889948ee0dcea32e19c185b;hb=3DHEAD#l73 > > >=20 > > > So to actually map pv-grub hdX we need to do the same. > >=20 > > Could you test patch below (compile-tested)? >=20 > This patch works very well for me. It can boot into system using legacy > menu.lst. >=20 > I also setup two disks for testing, and set root=3DhdX,Y to list the > file in repective disk correct. Then swapping the disk order in xen > config and again the result is correct. >=20 > FWIW here my acknowledge for my positive test result. >=20 > Tested-By: Michael Chang . >=20 > Feel free to let me know anything I can help in this topic, and really > appreciate for your work and time on this. >=20 Finally pushed. > Thanks, > Michael >=20 > >=20 > > From: Andrey Borzenkov > > Subject: [PATCH] accept also hdX as alias to native Xen disk name > >=20 > > To assign correct disk numbers, sort disks by increasing order of handle > > value. This allows reusing legacy pv-grub menu.lst which is using hdX = names. > >=20 > > Suggested-By: Michael Chang > >=20 > > --- > > grub-core/disk/xen/xendisk.c | 45 +++++++++++++++++++++++++++++++++++-= -------- > > 1 file changed, 36 insertions(+), 9 deletions(-) > >=20 > > diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c > > index 2b11c2a..b18a923 100644 > > --- a/grub-core/disk/xen/xendisk.c > > +++ b/grub-core/disk/xen/xendisk.c > > @@ -40,6 +40,7 @@ struct virtdisk > > grub_xen_evtchn_t evtchn; > > void *dma_page; > > grub_xen_grant_t dma_grant; > > + struct virtdisk *compat_next; > > }; > > =20 > > #define xen_wmb() mb() > > @@ -47,6 +48,7 @@ struct virtdisk > > =20 > > static struct virtdisk *virtdisks; > > static grub_size_t vdiskcnt; > > +struct virtdisk *compat_head; > > =20 > > static int > > grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_d= ata, > > @@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t= hook, void *hook_data, > > static grub_err_t > > grub_virtdisk_open (const char *name, grub_disk_t disk) > > { > > - grub_size_t i; > > + int i; > > grub_uint32_t secsize; > > char fdir[200]; > > char *buf; > > + int num =3D -1; > > + struct virtdisk *vd; > > =20 > > - for (i =3D 0; i < vdiskcnt; i++) > > - if (grub_strcmp (name, virtdisks[i].fullname) =3D=3D 0) > > + /* For compatibility with pv-grub legacy menu.lst accept hdX as disk= name */ > > + if (name[0] =3D=3D 'h' && name[1] =3D=3D 'd' && name[2]) > > + { > > + num =3D grub_strtoul (name + 2, 0, 10); > > + if (grub_errno) > > + { > > + grub_errno =3D 0; > > + num =3D -1; > > + } > > + } > > + for (i =3D 0, vd =3D compat_head; vd; vd =3D vd->compat_next, i++) > > + if (i =3D=3D num || grub_strcmp (name, vd->fullname) =3D=3D 0) > > break; > > - if (i =3D=3D vdiskcnt) > > + if (!vd) > > return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk"); > > - disk->data =3D &virtdisks[i]; > > - disk->id =3D i; > > + disk->data =3D vd; > > + disk->id =3D vd - virtdisks; > > =20 > > - grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backe= nd_dir); > > + grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir); > > buf =3D grub_xenstore_get_file (fdir, NULL); > > if (!buf) > > return grub_errno; > > @@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t di= sk) > > if (grub_errno) > > return grub_errno; > > =20 > > - grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", > > - virtdisks[i].backend_dir); > > + grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_di= r); > > buf =3D grub_xenstore_get_file (fdir, NULL); > > if (!buf) > > return grub_errno; > > @@ -264,6 +277,7 @@ fill (const char *dir, void *data) > > grub_err_t err; > > void *buf; > > struct evtchn_alloc_unbound alloc_unbound; > > + struct virtdisk **prev =3D &compat_head, *vd =3D compat_head; > > =20 > > /* Shouldn't happen unles some hotplug happened. */ > > if (vdiskcnt >=3D *ctr) > > @@ -374,6 +388,19 @@ fill (const char *dir, void *data) > > =20 > > virtdisks[vdiskcnt].frontend_dir =3D grub_strdup (fdir); > > =20 > > + /* For compatibility with pv-grub maintain linked list sorted by han= dle > > + value in increasing order. This allows mapping of (hdX) disk names > > + from legacy menu.lst */ > > + while (vd) > > + { > > + if (vd->handle > virtdisks[vdiskcnt].handle) > > + break; > > + prev =3D &vd->compat_next; > > + vd =3D vd->compat_next; > > + } > > + virtdisks[vdiskcnt].compat_next =3D vd; > > + *prev =3D &virtdisks[vdiskcnt]; > > + > > vdiskcnt++; > > return 0; > > =20 > > --=20 > > tg: (4afd010..) e/xen/hdX-compat (depends on: master)