All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen bootloader
@ 2005-04-27  9:21 aq
  2005-04-27  9:24 ` aq
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: aq @ 2005-04-27  9:21 UTC (permalink / raw)
  To: Jeremy Katz; +Cc: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

hello Jeremy,

Here is a patch to fix few problems in Xen bootloader you sent to the
list yesterday.

list of changes:
- make a dummy tools/pygrub/src/__init__.py
- extend filesystem abstraction by adding file_exist() method. this
method is used to check for existent of a file given its name. now
ext2fs implements this method.
- pygrub opens and parses /boot/grub/menu.lst or /boot/grub/grub.conf,
in that order.
- add /usr/lib/python to system path (see pygrub). without this
change, pygrub cannot find grub python package.
- remove few blank lines

$ diffstat xen-grub.patch
 __init__.py            |    1
 fsys/__init__.py       |    5 +++-
 fsys/ext2/ext2module.c |   51 ++++++++++++++++++++++++++++++++++++++++---------
 pygrub                 |   12 +++++++++--
 4 files changed, 57 insertions(+), 12 deletions(-)

Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>

I wonder why the patch you sent to list is in CR/LF format? arent you
programming on Windows, are you ;-). could you please remove them next
time ?

regards,
aq

[-- Attachment #2: xen-grub.patch --]
[-- Type: application/octet-stream, Size: 4848 bytes --]

diff -Nurp unstable.27.3.org/tools/pygrub/src/fsys/ext2/ext2module.c unstable.27.3/tools/pygrub/src/fsys/ext2/ext2module.c
--- unstable.27.3.org/tools/pygrub/src/fsys/ext2/ext2module.c	2005-04-27 16:27:33.000000000 +0900
+++ unstable.27.3/tools/pygrub/src/fsys/ext2/ext2module.c	2005-04-27 18:01:26.077028000 +0900
@@ -174,6 +174,25 @@ ext2_file_open (Ext2Fs *fs, char * name,
     return (PyObject *) file;
 }
 
+static PyObject *
+ext2_file_exist (Ext2Fs *fs, char * name)
+{
+    int err;
+    ext2_ino_t ino;
+    Ext2File * file;
+
+    file = (Ext2File *) PyObject_NEW(Ext2File, &Ext2FileType);
+    file->file = NULL;
+
+    err = ext2fs_namei_follow(fs->fs, EXT2_ROOT_INO, EXT2_ROOT_INO, name, &ino);
+    if (err) {
+        Py_INCREF(Py_False);
+        return Py_False;
+    }
+    Py_INCREF(Py_True);
+    return Py_True;
+}
+
 /* ext2fs object */
 
 static PyObject *
@@ -231,6 +250,18 @@ ext2_fs_open_file (Ext2Fs *fs, PyObject 
     return ext2_file_open(fs, name, flags);
 }
 
+static PyObject *
+ext2_fs_file_exist (Ext2Fs *fs, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "name", NULL };
+    char * name;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &name))
+                                     return NULL;
+
+    return ext2_file_exist(fs, name);
+}
+
 static void
 ext2_fs_dealloc (Ext2Fs * fs)
 {
@@ -249,6 +280,9 @@ static struct PyMethodDef Ext2FsMethods[
         { "open_file",
           (PyCFunction) ext2_fs_open_file,
           METH_VARARGS|METH_KEYWORDS, NULL },
+        { "file_exist",
+          (PyCFunction) ext2_fs_file_exist,
+          METH_VARARGS|METH_KEYWORDS, NULL },
 	{ NULL, NULL, 0, NULL }	
 };
 
@@ -312,21 +346,20 @@ ext2_fs_new(PyObject *o, PyObject *args,
     return (PyObject *)pfs;
 }
 
-
 static struct PyMethodDef Ext2ModuleMethods[] = {
     { "Ext2Fs", (PyCFunction) ext2_fs_new, METH_VARARGS|METH_KEYWORDS, NULL },
     { NULL, NULL, 0, NULL }
 };
 
-
 void init_pyext2(void) {
-    PyObject *m, *d;
+    PyObject *m;
 
     m = Py_InitModule("_pyext2", Ext2ModuleMethods);
-    d = PyModule_GetDict(m);
-
-    /*    o = PyObject_NEW(PyObject, yExt2FsConstructorType);
-    PyDict_SetItemString(d, "PyExt2Fs", o);
-    Py_DECREF(o);*/
-                      
+    /*
+     * PyObject *d;
+     * d = PyModule_GetDict(m);
+     * o = PyObject_NEW(PyObject, yExt2FsConstructorType);
+     * PyDict_SetItemString(d, "PyExt2Fs", o);
+     * Py_DECREF(o);
+     */
 }
diff -Nurp unstable.27.3.org/tools/pygrub/src/fsys/__init__.py unstable.27.3/tools/pygrub/src/fsys/__init__.py
--- unstable.27.3.org/tools/pygrub/src/fsys/__init__.py	2005-04-27 16:27:33.000000000 +0900
+++ unstable.27.3/tools/pygrub/src/fsys/__init__.py	2005-04-27 15:20:37.000000000 +0900
@@ -49,7 +49,10 @@ class FileSystem(object):
         should look similar to a native file object."""
         raise RuntimeError, "open_file not implemented"
     
-
+    def file_exist(self, file):
+        """Check to see if the give file is existed.
+        Return true if file existed, return false otherwise."""
+        raise RuntimeError, "file_exist not implemented"
 
 mydir = sys.modules['grub.fsys'].__path__[0]
 for f in os.listdir(mydir):
diff -Nurp unstable.27.3.org/tools/pygrub/src/__init__.py unstable.27.3/tools/pygrub/src/__init__.py
--- unstable.27.3.org/tools/pygrub/src/__init__.py	1970-01-01 09:00:00.000000000 +0900
+++ unstable.27.3/tools/pygrub/src/__init__.py	2005-04-27 14:46:50.000000000 +0900
@@ -0,0 +1 @@
+ 
diff -Nurp unstable.27.3.org/tools/pygrub/src/pygrub unstable.27.3/tools/pygrub/src/pygrub
--- unstable.27.3.org/tools/pygrub/src/pygrub	2005-04-27 17:53:05.000000000 +0900
+++ unstable.27.3/tools/pygrub/src/pygrub	2005-04-27 17:57:44.000000000 +0900
@@ -19,6 +19,8 @@ import logging
 import curses, _curses, curses.wrapper
 import getopt
 
+sys.path = [ '/usr/lib/python' ] + sys.path
+
 import grub.GrubConf
 import grub.fsys
 
@@ -78,7 +80,6 @@ def is_disk_image(file):
     if len(buf) >= 512 and struct.unpack("H", buf[0x1fe: 0x200]) == (0xaaff):
         return True
     return False
-    
 
 def get_config(fn):
     if not os.access(fn, os.R_OK):
@@ -97,7 +98,14 @@ def get_config(fn):
             break
 
     if fs is not None:
-        f = fs.open_file("/boot/grub/grub.conf")
+        if fs.file_exist("/boot/grub/menu.lst"):
+            grubfile = "/boot/grub/menu.lst"
+        elif fs.file_exist("/boot/grub/grub.conf"):
+            grubfile = "/boot/grub/grub.conf"
+        else:
+            raise RuntimeError, "we couldn't find /boot/grub{menu.lst,grub.conf} " + \
+                                "in the image provided. halt!"
+        f = fs.open_file(grubfile)
         buf = f.read()
         f.close()
         fs.close()

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-27  9:21 [PATCH] xen bootloader aq
@ 2005-04-27  9:24 ` aq
  2005-04-28 13:51 ` Mike Wray
  2005-04-29  3:10 ` Jeremy Katz
  2 siblings, 0 replies; 10+ messages in thread
From: aq @ 2005-04-27  9:24 UTC (permalink / raw)
  To: Jeremy Katz; +Cc: xen-devel@lists.xensource.com

sorry, I forgot to note that the patch I have just sent to list should
be applied on top of the last patch of Jeremy.

regards,
aq

On 4/27/05, aq <aquynh@gmail.com> wrote:
> hello Jeremy,
> 
> Here is a patch to fix few problems in Xen bootloader you sent to the
> list yesterday.
> 
> list of changes:
> - make a dummy tools/pygrub/src/__init__.py
> - extend filesystem abstraction by adding file_exist() method. this
> method is used to check for existent of a file given its name. now
> ext2fs implements this method.
> - pygrub opens and parses /boot/grub/menu.lst or /boot/grub/grub.conf,
> in that order.
> - add /usr/lib/python to system path (see pygrub). without this
> change, pygrub cannot find grub python package.
> - remove few blank lines
> 
> $ diffstat xen-grub.patch
>  __init__.py            |    1
>  fsys/__init__.py       |    5 +++-
>  fsys/ext2/ext2module.c |   51 ++++++++++++++++++++++++++++++++++++++++---------
>  pygrub                 |   12 +++++++++--
>  4 files changed, 57 insertions(+), 12 deletions(-)
> 
> Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
> 
> I wonder why the patch you sent to list is in CR/LF format? arent you
> programming on Windows, are you ;-). could you please remove them next
> time ?
> 
> regards,
> aq
> 
> 
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-27  9:21 [PATCH] xen bootloader aq
  2005-04-27  9:24 ` aq
@ 2005-04-28 13:51 ` Mike Wray
  2005-04-28 14:26   ` aq
  2005-04-29  3:10 ` Jeremy Katz
  2 siblings, 1 reply; 10+ messages in thread
From: Mike Wray @ 2005-04-28 13:51 UTC (permalink / raw)
  To: aq, xen-devel@lists.xensource.com

aq wrote:
> hello Jeremy,
> 
> Here is a patch to fix few problems in Xen bootloader you sent to the
> list yesterday.

The patch had ^M line endings which stopped it applying until I removed them.
Please make sure patches don't have that other operating system's line endings.

Thanks,

Mike

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-28 13:51 ` Mike Wray
@ 2005-04-28 14:26   ` aq
  0 siblings, 0 replies; 10+ messages in thread
From: aq @ 2005-04-28 14:26 UTC (permalink / raw)
  To: Mike Wray; +Cc: xen-devel@lists.xensource.com

On 4/28/05, Mike Wray <mike.wray@hp.com> wrote:
> aq wrote:
> > hello Jeremy,
> >
> > Here is a patch to fix few problems in Xen bootloader you sent to the
> > list yesterday.
> 
> The patch had ^M line endings which stopped it applying until I removed them.
> Please make sure patches don't have that other operating system's line endings.

Then dont forget to blame Jeremy for this problem. Those ^M are
introduced in his first patch. I just inherited his code ;-)

Seriously, I will recheck the patch next time. 

Thanks,
aq

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-27  9:21 [PATCH] xen bootloader aq
  2005-04-27  9:24 ` aq
  2005-04-28 13:51 ` Mike Wray
@ 2005-04-29  3:10 ` Jeremy Katz
  2005-04-29  3:25   ` aq
  2005-04-29  7:59   ` Mike Wray
  2 siblings, 2 replies; 10+ messages in thread
From: Jeremy Katz @ 2005-04-29  3:10 UTC (permalink / raw)
  To: aq; +Cc: Mike Wray, xen-devel@lists.xensource.com

On Wed, 2005-04-27 at 18:21 +0900, aq wrote:
> Here is a patch to fix few problems in Xen bootloader you sent to the
> list yesterday.

Thanks.  Sorry for the delay in responding, I've been underwater with
stuff for FC4 test3.

> list of changes:
> - make a dummy tools/pygrub/src/__init__.py

I still don't know why this didn't work, but thanks.

> - extend filesystem abstraction by adding file_exist() method. this
> method is used to check for existent of a file given its name. now
> ext2fs implements this method.

Great, thanks.  My only comment about the ext2fs code for this is that
you might as well inline the contents of ext2_file_exist in
ext2fs_file_exist... you don't gain anything by having that for reuse
that I can see.

> - pygrub opens and parses /boot/grub/menu.lst or /boot/grub/grub.conf,
> in that order.
> - add /usr/lib/python to system path (see pygrub). without this
> change, pygrub cannot find grub python package.

Per the other changes I submitted a week or so ago, you want to append
this to the path, not prepend it.  

> - remove few blank lines

Fair enough.

> $ diffstat xen-grub.patch
>  __init__.py            |    1
>  fsys/__init__.py       |    5 +++-
>  fsys/ext2/ext2module.c |   51 ++++++++++++++++++++++++++++++++++++++++---------
>  pygrub                 |   12 +++++++++--
>  4 files changed, 57 insertions(+), 12 deletions(-)
> 
> Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>

I'll apply this to my local tree.  Mike -- based on your later mail,
should I gather that you've applied things to your tree and are in the
process of pushing to -unstable?  Or should I go about trying to do
something more sane to maintain this on the side for a while?

> I wonder why the patch you sent to list is in CR/LF format? arent you
> programming on Windows, are you ;-). could you please remove them next
> time ?

Hrmm, I have no clue either.  The previous patch appears to not be in
DOS format but the second one is.  And they should have been exported
identically from my local bk repository.  I'll double-check next time
before sending.

Jeremy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-29  3:10 ` Jeremy Katz
@ 2005-04-29  3:25   ` aq
  2005-04-29  7:59   ` Mike Wray
  1 sibling, 0 replies; 10+ messages in thread
From: aq @ 2005-04-29  3:25 UTC (permalink / raw)
  To: Jeremy Katz; +Cc: Mike Wray, xen-devel@lists.xensource.com

On 4/29/05, Jeremy Katz <katzj@redhat.com> wrote:
> On Wed, 2005-04-27 at 18:21 +0900, aq wrote:
> > Here is a patch to fix few problems in Xen bootloader you sent to the
> > list yesterday.
> 
> Thanks.  Sorry for the delay in responding, I've been underwater with
> stuff for FC4 test3.
> 
> > list of changes:
> > - make a dummy tools/pygrub/src/__init__.py
> 
> I still don't know why this didn't work, but thanks.
> 
> > - extend filesystem abstraction by adding file_exist() method. this
> > method is used to check for existent of a file given its name. now
> > ext2fs implements this method.
> 
> Great, thanks.  My only comment about the ext2fs code for this is that
> you might as well inline the contents of ext2_file_exist in
> ext2fs_file_exist... you don't gain anything by having that for reuse
> that I can see.

I agree.

By the way, I am working on xfs/jfs/reiserfs module for this code.
Hopefully I will finish soon.

regards,
aq

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-29  3:10 ` Jeremy Katz
  2005-04-29  3:25   ` aq
@ 2005-04-29  7:59   ` Mike Wray
  2005-04-29 15:30     ` Jeremy Katz
  2005-05-01  1:01     ` aq
  1 sibling, 2 replies; 10+ messages in thread
From: Mike Wray @ 2005-04-29  7:59 UTC (permalink / raw)
  To: Jeremy Katz; +Cc: xen-devel@lists.xensource.com

Jeremy Katz wrote:
> On Wed, 2005-04-27 at 18:21 +0900, aq wrote:
> 
>>Here is a patch to fix few problems in Xen bootloader you sent to the
>>list yesterday.
> 
> Thanks.  Sorry for the delay in responding, I've been underwater with
> stuff for FC4 test3.
> 
>>list of changes:
>>- make a dummy tools/pygrub/src/__init__.py
> 
> I still don't know why this didn't work, but thanks.
>
>>- extend filesystem abstraction by adding file_exist() method. this
>>method is used to check for existent of a file given its name. now
>>ext2fs implements this method.
>  
> Great, thanks.  My only comment about the ext2fs code for this is that
> you might as well inline the contents of ext2_file_exist in
> ext2fs_file_exist... you don't gain anything by having that for reuse
> that I can see.
> 
>>- pygrub opens and parses /boot/grub/menu.lst or /boot/grub/grub.conf,
>>in that order.
>>- add /usr/lib/python to system path (see pygrub). without this
>>change, pygrub cannot find grub python package.
> 
> Per the other changes I submitted a week or so ago, you want to append
> this to the path, not prepend it.  
> 
> 
>>- remove few blank lines
> 
> 
> Fair enough.
>
>>$ diffstat xen-grub.patch
>> __init__.py            |    1
>> fsys/__init__.py       |    5 +++-
>> fsys/ext2/ext2module.c |   51 ++++++++++++++++++++++++++++++++++++++++---------
>> pygrub                 |   12 +++++++++--
>> 4 files changed, 57 insertions(+), 12 deletions(-)
>>
>>Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
> 
> 
> I'll apply this to my local tree.  Mike -- based on your later mail,
> should I gather that you've applied things to your tree and are in the
> process of pushing to -unstable?  Or should I go about trying to do
> something more sane to maintain this on the side for a while?

Yes, I've applied the patch and it should be making its way out
to unstable, possibly today.

BTW, I had to install e2fsprogs-devel before it would compile, so
I added a note that you need that in a README.

>>I wonder why the patch you sent to list is in CR/LF format? arent you
>>programming on Windows, are you ;-). could you please remove them next
>>time ?
> 
> 
> Hrmm, I have no clue either.  The previous patch appears to not be in
> DOS format but the second one is.  And they should have been exported
> identically from my local bk repository.  I'll double-check next time
> before sending.

Mike

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-29  7:59   ` Mike Wray
@ 2005-04-29 15:30     ` Jeremy Katz
  2005-05-01  1:01     ` aq
  1 sibling, 0 replies; 10+ messages in thread
From: Jeremy Katz @ 2005-04-29 15:30 UTC (permalink / raw)
  To: Mike Wray; +Cc: xen-devel@lists.xensource.com

On Fri, 2005-04-29 at 08:59 +0100, Mike Wray wrote:
> Yes, I've applied the patch and it should be making its way out
> to unstable, possibly today.

Cool, thanks.

> BTW, I had to install e2fsprogs-devel before it would compile, so
> I added a note that you need that in a README.

When other fsystems come along, we'll probably end up wanting to check
for availability of the libraries and only build support for the
filesystems that we can.  Unfortunately, I'm going to have to look
harder at distutils to see if there is a clean way to do that :)

Jeremy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-04-29  7:59   ` Mike Wray
  2005-04-29 15:30     ` Jeremy Katz
@ 2005-05-01  1:01     ` aq
  2005-05-03 13:48       ` Mike Wray
  1 sibling, 1 reply; 10+ messages in thread
From: aq @ 2005-05-01  1:01 UTC (permalink / raw)
  To: Mike Wray; +Cc: Jeremy Katz, xen-devel@lists.xensource.com

On 4/29/05, Mike Wray <mike.wray@hp.com> wrote:
> Jeremy Katz wrote:
> > On Wed, 2005-04-27 at 18:21 +0900, aq wrote:
> >
> >>Here is a patch to fix few problems in Xen bootloader you sent to the
> >>list yesterday.
> >
> > Thanks.  Sorry for the delay in responding, I've been underwater with
> > stuff for FC4 test3.
> >
> >>list of changes:
> >>- make a dummy tools/pygrub/src/__init__.py
> >
> > I still don't know why this didn't work, but thanks.
> >
> >>- extend filesystem abstraction by adding file_exist() method. this
> >>method is used to check for existent of a file given its name. now
> >>ext2fs implements this method.
> >
> > Great, thanks.  My only comment about the ext2fs code for this is that
> > you might as well inline the contents of ext2_file_exist in
> > ext2fs_file_exist... you don't gain anything by having that for reuse
> > that I can see.
> >
> >>- pygrub opens and parses /boot/grub/menu.lst or /boot/grub/grub.conf,
> >>in that order.
> >>- add /usr/lib/python to system path (see pygrub). without this
> >>change, pygrub cannot find grub python package.
> >
> > Per the other changes I submitted a week or so ago, you want to append
> > this to the path, not prepend it.
> >
> >
> >>- remove few blank lines
> >
> >
> > Fair enough.
> >
> >>$ diffstat xen-grub.patch
> >> __init__.py            |    1
> >> fsys/__init__.py       |    5 +++-
> >> fsys/ext2/ext2module.c |   51 ++++++++++++++++++++++++++++++++++++++++---------
> >> pygrub                 |   12 +++++++++--
> >> 4 files changed, 57 insertions(+), 12 deletions(-)
> >>
> >>Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
> >
> >
> > I'll apply this to my local tree.  Mike -- based on your later mail,
> > should I gather that you've applied things to your tree and are in the
> > process of pushing to -unstable?  Or should I go about trying to do
> > something more sane to maintain this on the side for a while?
> 
> Yes, I've applied the patch and it should be making its way out
> to unstable, possibly today.

Mike, will you push those code to -unstable soon? I am looking forward
to it. ( I am having few improvements, but not sure what to patch
against)

thank you,
aq

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] xen bootloader
  2005-05-01  1:01     ` aq
@ 2005-05-03 13:48       ` Mike Wray
  0 siblings, 0 replies; 10+ messages in thread
From: Mike Wray @ 2005-05-03 13:48 UTC (permalink / raw)
  To: aq; +Cc: Jeremy Katz, xen-devel@lists.xensource.com

aq wrote:
>...
> Mike, will you push those code to -unstable soon? I am looking forward
> to it. ( I am having few improvements, but not sure what to patch
> against)
> 

I've applied the patch and some of your fixes locally.
It's in the pipeline for unstable, I can't push directly myself.

Mike

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-05-03 13:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-27  9:21 [PATCH] xen bootloader aq
2005-04-27  9:24 ` aq
2005-04-28 13:51 ` Mike Wray
2005-04-28 14:26   ` aq
2005-04-29  3:10 ` Jeremy Katz
2005-04-29  3:25   ` aq
2005-04-29  7:59   ` Mike Wray
2005-04-29 15:30     ` Jeremy Katz
2005-05-01  1:01     ` aq
2005-05-03 13:48       ` Mike Wray

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.