summaryrefslogtreecommitdiff
path: root/tools/pygrub/src
Commit message (Collapse)AuthorAgeFilesLines
* tools: Delete trailing whitespace in python scriptsAndrew Cooper2023-03-174-42/+42
| | | | | | | | No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
* tools/pygrub: Failing to set value to 0 in Grub2ConfigFileMichael Young2019-08-141-1/+1
| | | | | | | | | | | In Grub2ConfigFile the code to handle ${saved_entry} and ${next_entry} sets arg = "0" but this now does nothing following c/s d1b93ea2615bd "tools/pygrub: Make pygrub understand default entry in string format" which replaced arg.strip() with arg_strip in the following line. This patch restores the previous behaviour. Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub: encode / decode string in Python 3Wei Liu2019-04-021-2/+8
| | | | | | | | | String is unicode in 3 but bytes in 2. We need to call encode / decode function when using Python 3. Reported-by: M A Young <m.a.young@durham.ac.uk> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub/grub: always use integer for default entryWei Liu2019-04-021-1/+5
| | | | | | | | | | | | | The original code set the default to either a string or an integer (0) and relies on a Python 2 specific behaviour to work (integer is allowed to be compared to string in Python 2 but not 3). Always use integer. The caller (pygrub) already has code to handle that. Reported-by: M A Young <m.a.young@durham.ac.uk> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub: fix message in grub parserWei Liu2019-04-021-1/+1
| | | | | | | The code suggests 0 is allowed. Zero is not a positive number. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub/fsimage: make it work with python 3Wei Liu2019-03-121-54/+69
| | | | | | | | | | | | | | | | | | | With the help of two porting guides and cpython source code: 1. Use PyBytes to replace PyString counterparts. 2. Use PyVarObject_HEAD_INIT. 3. Remove usage of Py_FindMethod. 4. Use new module initialisation routine. For #3, Py_FindMethod was removed, yet an alternative wasn't documented. The code is the result of reverse-engineering cpython commit 6116d4a1d1 https://docs.python.org/3/howto/cporting.html http://python3porting.com/cextensions.html Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub: make python scripts work with 2.6 and upWei Liu2019-03-124-70/+78
| | | | | | | | | | | | | | | | Run 2to3 and pick the sensible suggestions. Import print_function and absolute_import so 2.6 can work. There has never been a curses.wrapper module according to 2.x and 3.x doc, only a function, so "import curses.wrapper" is not correct. It happened to work because 2.x implemented a (undocumented) module. We only need to import curses to make curses.wrapper available to pygrub. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub: change tabs into spacesWei Liu2019-03-121-2/+2
| | | | | | | | | Not sure why Python 2 never complained, but Python 3 does. Change tabs to spaces. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* pygrub/fsimage: drop unused structWei Liu2019-03-121-7/+0
| | | | | Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* tools/pygrub: Add `xen' to fsimage python module nameIan Jackson2018-10-152-7/+7
| | | | | | | | This module should be called `libxenfsimage' for the same reasons that the C library should. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
* tools/libfsimage: Add `xen' to .h names and principal .so nameIan Jackson2018-10-151-1/+1
| | | | | | | | | | | `fsimage' is rather general. And we do not expect this library to be very useful out of tree because of its unstable ABI. So add the word `xen'. This will avoid naming conflicts with anyone else's fsimage library. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
* pygrub: Properly quote results, when returning them to the caller:Ian Jackson2016-11-221-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | * When the caller wants sexpr output, use `repr()' This is what Xend expects. The returned S-expressions are now escaped and quoted by Python, generally using '...'. Previously kernel and ramdisk were unquoted and args was quoted with "..." but without proper escaping. This change may break toolstacks which do not properly dequote the returned S-expressions. * When the caller wants "simple" output, crash if the delimiter is contained in the returned value. With --output-format=simple it does not seem like this could ever happen, because the bootloader config parsers all take line-based input from the various bootloader config files. With --output-format=simple0, this can happen if the bootloader config file contains nul bytes. This is CVE-2016-9379 and CVE-2016-9380 / XSA-198. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Tested-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* tools: pygrub: if partition table is empty, try treating as a whole diskIan Campbell2015-11-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pygrub (in identify_disk_image()) detects a DOS style partition table via the presence of the 0xaa55 signature at the end of the first sector of the disk. However this signature is also present in whole-disk configurations when there is an MBR on the disk. Many filesystems (e.g. ext[234]) include leading padding in their on disk format specifically to enable this. So if we think we have a DOS partition table but do not find any actual partition table entries we may as well try looking at it as a whole disk image. Worst case is we probe and find there isn't anything there. This was reported by Sjors Gielen in Debian bug #745419. The fix was inspired by a patch by Adi Kriegisch in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745419#27 Tested by genext2fs'ing my /boot into a new raw image (works) and then: dd if=/usr/lib/grub/i386-pc/g2ldr.mbr of=img conv=notrunc bs=512 count=1 to add an MBR (with 0xaa55 signature) to it, which after this patch also works. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: 745419-forwarded@bugs.debian.org
* Replace FSF street address with canonical URLIan Campbell2015-07-293-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As recommended in http://www.gnu.org/licenses/gpl-howto.en.html. This is the result of: $ git grep -El Mass\|Temple\|Franklin | xargs ./fsf.pl Where fsf.pl is: #!/usr/bin/perl -w -pi.bak -0777 my $repl = 'If not, see <http://www.gnu.org/licenses/>.'; my $br = qr/(?:\s*\n\s*(?:[\*\#]|\/\/|\.\\" )?\s*|\s+)/; my $inwt = qr/[Ii]f${br}not,${br}write${br}(?:to${br})?the${br}Free${br}Software${br}Foundation,(?:${br}Inc\.,)?/; my $mass = qr/675${br}Mass${br}Ave,?${br}Cambridge,?${br}MA${br}02139,?${br}USA,?\.?/; my $franklin = qr/51${br}Franklin${br}St(?:reet)?(?:,${br}| - )Fifth${br}Floor,?${br}Boston,?${br}MA,?${br}02110-1301,?${br}USA,?\.?/; my $temple = qr/59${br}Temple${br}Place(?:,${br}| - )Suite${br}330,?${br}Boston,?${br}MA,?${br}021110?-1307,?${br}USA,?\.?/; s|$inwt$br$mass|$repl|m; s|$inwt$br$franklin|$repl|m; s|$inwt$br$temple|$repl|m; The only remaining mentions of these addresses are in COPYING files which I haven't touched. Some of the changed files are imports from elsewhere, however filtering them out is tricky, I think it is tolerable to have these files be modified here and then perhaps reverted on the next sync, since it's only 1-2 lines and obvious what is going on. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: Fix regression from c/s d1b93ea, attempt 2Boris Ostrovsky2014-12-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | c/s d1b93ea causes substantial functional regressions in pygrub's ability to parse bootloader configuration files. c/s d1b93ea itself changed an an interface which previously used exclusively integers, to using strings in the case of a grub configuration with explicit default set, along with changing the code calling the interface to require a string. The default value for "default" remained as an integer. As a result, any Extlinux or Lilo configuration (which drives this interface exclusively with integers), or Grub configuration which doesn't explicitly declare a default will die with an AttributeError when attempting to call "self.cf.default.isdigit()" where "default" is an integer. Sadly, this AttributeError gets swallowed by the blanket ignore in the loop which searches partitions for valid bootloader configurations, causing the issue to be reported as "Unable to find partition containing kernel" We should explicitly check type of "default" in image_index() and process it appropriately. Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* tools/pygrub: Fix TOCTOU race introduced by c/s 63dcc68Andrew Cooper2014-11-041-3/+9
| | | | | | | | | | | | | In addition, use os.makedirs() which will also create intermediate directories if they don't exist. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> CC: Ian Campbell <Ian.Campbell@citrix.com> CC: Ian Jackson <Ian.Jackson@eu.citrix.com> CC: Wei Liu <wei.liu2@citrix.com> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> CC: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: fix non-interactive parsing of grub1 config filesSimon Rowe2014-11-041-9/+14
| | | | | | | | | | | | | Changes to handle non-numeric default attributes for grub2 caused run_grub() to attempt to index into the images list using a string. Pull out the code that handles submenus into a new function and use that to ensure sel is numeric. Reported-by: David Scott <dave.scott@citrix.com> Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-and-tested-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: fix read sizes on FreeBSDRoger Pau Monne2014-09-291-4/+13
| | | | | | | | | | | | | | FreeBSD only allows reading multiples of sector size from raw disk devices (character devices). This fix should only alter the behaviour of pygrub on FreeBSD, the other supported OSes will continue using the same size. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Cc: Ian Campbell <ian.campbell@citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools/pygrub: store kernels in /var/run/xen/pygrubOlaf Hering2014-09-231-1/+7
| | | | | | | | | | | | Move location of temporary bootfiles from /var/run/xend/boot to /var/run/xen/pygrub. Create the subdirectory if does not exist. The <dir> argument --output-directory must be an existing directory. The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot. Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* tools/pygrub: Make pygrub understand default entry in string formatBoris Ostrovsky2014-07-032-6/+25
| | | | | | | | | | | | | | | | Currently pygrub can only correctly parse grub2's default attribute when it is specified as a number. If it is set to ${saved_entry} or ${next_entry} then the first image (i.e. entry number 0) is selected. If any other value is specified (typically this would be the string in menuentry) pygrub will crash. This patch will allow pygrub to interpret default attribute if it is specified as a string (note that in case of submenus only the leaf string will be considered). Also issue a warning if default is set to ${saved_entry} or ${next_entry}. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* tools/pygrub: Fix extlinux when /boot is a separate partition from /Andrew Cooper2014-06-181-1/+3
| | | | | | | | | | Grub and Grub2 already cope with this. Reported-by: Joseph Hom <jhom@softlayer.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> CC: Ian Campbell <Ian.Campbell@citrix.com> CC: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* tools/pygrub: Fix error handling if no valid partitions are foundAndrew Cooper2014-05-121-2/+2
| | | | | | | | | | | | | | | If no partitions at all are found, pygrub never creates the name 'fs', resulting in a NameError indicating the lack of fs, rather than a RuntimeError explaining that no partitions were found. Set fs to None right at the start, and use the pythonic idiom "if fs is None:" to protect against otherwise valid values for fs which compare equal to 0/False. Reported-by: Sven Köhler <sven.koehler@gmail.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> CC: Ian Campbell <Ian.Campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentryJoby Poriyath2014-03-121-1/+3
| | | | | | | | | | | | | | | menuentry in grub2/grub.cfg uses linux16 and initrd16 commands instead of linux and initrd. Due to this RHEL 7 (beta) guest failed to boot after the installation. In addition to this, RHEL 7 menu entries have two different single-quote delimited strings on the same line, and the greedy grouping for menuentry parsing gets both strings, and the options inbetween. Signed-off-by: Joby Poriyath <joby.poriyath@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Cc: george.dunlap@citrix.com
* pygrub: remote ia64 from pygrubOlaf Hering2014-03-121-24/+11
| | | | | | Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: Support (/dev/xvda) style disk specificationsIan Campbell2013-10-141-1/+5
| | | | | | | | | | | You get these if you install Debian Wheezy as HVM and then try to convert to PV. This is Debian bug #603391. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Tested-by: Tril <tril@metapipe.net> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: add Debian extlinux.conf pathIan Campbell2013-08-271-0/+1
| | | | | | | | | This is Debian bug #697407. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697407 Signed-off-by: Ian Campbell <ijc@hellion.org.uk> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: allow user to specify an explicit offset to fsKjetil Torgrim Homme2013-07-171-4/+13
| | | | | | | This new option overrides partition table parsing Signed-off-by: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com> Reviewed-by: Matt Wilson <msw@amazon.com>
* pygrub/GrubConf: fix boot problem for fedora 19 grub.cfg (2nd attempt)Marcel J.E. Mol2013-06-271-0/+2
| | | | | | | | | | | | | | | Booting a fedora 19 domU failed because a it could not properly parse the grub.cfg file. This was cased by set default="${next_entry}" This statement actually is within an 'if' statement, so maybe it would be better to skip code within if/fi blocks... But this patch seems to work fine. Signed-off-by: Marcel Mol <marcel@mesa.nl> Acked-by: Ian Campbell <ian.campbell@citix.com> Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
* Fix pygrub handling non-default entryMiroslav Rezanina2013-01-171-1/+1
| | | | | | | | | If we pass 0 as pygrub --entry argument (i.e. we want to boot first item), default value is used instead. This is dueto wrong check for range of allowed values of index - 0 is index of first item. Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> Acked-by: Matt Wilson <msw@amazon.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: Fix command line argument error handlingMatthew Daley2012-11-123-4/+4
| | | | | | | | | | | | | pygrub's individual config file parsers do not correctly check the amount of command line arguments given to them. In addition, the LILO config parser would report an incorrect message. Use len() to correctly check the amount of arguments, and fix the LILO error message. Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: Add option to list grub entriesCharles Arnold2012-10-261-4/+20
| | | | | | | | | | | | | | | | The argument to "--entry" allows 2 syntaxes, either directly the entry number in menu.lst, or the whole string behind the "title" key word. This poses the following issue: From Dom0 there is no way to guess the number and, or the complete title string because this string contains the kernel version, which will change with a kernel update. This patch adds [-l|--list-entries] as an argument to pygrub. Signed-off-by: Charles Arnold <carnold@suse.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: correct typo in --args assignmentOlaf Hering2012-10-091-3/+3
| | | | | | | | | | | | | If pygrub was called with --args="some thing", then this string should be append to the kernel command line. But the last changeset 25941:795c493fe561 contained a typo, it assigns 'args' instead of 'arg'. Rename the local variable which holds the string from the domain config file to avoid further confusion. Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: always append --argsOlaf Hering2012-09-251-2/+4
| | | | | | | | | | | | | | | | | If a bootloader entry in menu.lst has no additional kernel command line options listed and the domU.cfg has 'bootargs="--args=something"' the additional arguments from the config file are not passed to the kernel. The reason for that incorrect behaviour is that run_grub appends arg only if the parsed config file has arguments listed. Fix this by appending args from image section and the config file separatly. To avoid adding to a NoneType initialize grubcfg['args'] to an empty string. This does not change behaviour but simplifies the code which appends the string. Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: don't leave fds openRoger Pau Monne2012-07-231-0/+3
| | | | | | | | | | | On NetBSD a block device can only be opened once, so make sure pygrub closes it every time, if this is not done libfsimage is not able to open the disk later. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: cope better with big files in the guest.M A Young2012-07-041-17/+44
| | | | | | | | | | | | | | | Only read the first megabyte of a configuration file (grub etc.) and read the kernel and ramdisk files from the guest in one megabyte pieces so pygrub doesn't use a lot of memory if the files are large. With --not-really option check that the chosen kernel and ramdisk files exist. If there are problems writing the copy of the kernel or ramdisk, delete the copied files and exit in case they have filled the filesystem. Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Matt Wilson <msw@amazon.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: extlinux parsing correctnessRoger Pau Monne2012-02-071-1/+1
| | | | | | | | | | | | The "in" operator should be used instead of the find method, since we are only interested in knowing whether the line contains "initrd=", but we don't care about it's position. Also fixes an error that happens when initrd= it's at the start of the line, since find returns 0 and is evaluated as False. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: fix extlinux parsingRoger Pau Monne2012-01-031-1/+10
| | | | | | | | | | | | | | | | | | pygrub was unable to parse extlinux config files correctly, exactly the ones like: LABEL grsec KERNEL vmlinuz-3.0.10-grsec APPEND initrd=initramfs-3.0.10-grsec root=UUID=cfd4a7b4-8c40-4025-b877-8205f1c622ee modules=sd-mod,usb-storage,ext4 xen quiet This patch fixes it, adding a new case when parsing the "append" line, that searches for the initrd image. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Campbell <ian.campbell.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* pygrub: Fix "a" entry editing in grub2Miroslav Rezanina2011-12-131-1/+1
| | | | | | | | | | | | When user wants to change entry in grub2 menu in pygrub, there's no response in case of appending command line arguments ('a' key). Append malfunction is caused by change of keyword used for kernel record. Grub uses 'kernel' for line with linux kernel but grub2 uses 'linux' instead. This patch adds checking for both grub 1 and 2 keywords. Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: Allow scrolling of the list of entriesMiroslav Rezanina2011-12-131-4/+19
| | | | | | | | | | | | | When user wants to change entry in grub2 menu in pygrub, there may be crash of pygrub in case of editing item ('e' key). Crash on editing is caused longer entry list in case of grub2. As entry window is 10 lines high, it can hold only 8 entries (2 lines for border). Adding line outside of windows high causes crash. Patch add handling for longer lists and scrolling through them. Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: Add HybridISO support for PyGrub2Philipp Hahn2011-11-021-7/+19
| | | | | | | | | | | | | | | | grub-mkrescue internally uses xorriso, which generates a so-called "Hybrid ISO": The ISO images also contains a DOS partition table, which allows the identical ISO file to be stored on an USB stick for booting from it. This breaks PyGrub, since it (wrongly) detects only the DOS partition table and uses the first partition instead of the complete ISO file. Add a check to detect HybridISO files and use offset 0 in addition to partition table parsing. Signed-off-by: Philipp Hahn <hahn@univention.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pyrgrub: cope with configurations with set default="${saved_entry}" lineMichael Young2011-10-251-0/+2
| | | | | | | | | | Fedora 16 grub2 configuration file can have lines like set default="${saved_entry}" and a string containing an integer is expected Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: cope with configurations with submenusMichael Young2011-10-251-2/+11
| | | | | | | | | | | | | | | | | The grub2 configuration file in Fedora 16 can have one or more menuentrys in a submenu, with configuration of the form submenu "Xen 4.1" { menuentry ... { ... } } (this example occurs when the xen hypervisor is installed on the guest) Ignore the submenu line and the corresponding } Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: Allow GPT partition referencesMichael Young2011-10-251-0/+2
| | | | | | | | The grub2 configuration file in Fedora 16 can have GPT partition references like (hd0,gpt2) so remove the "gpt" string where necessary Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: look in /boot/grub2 (for eg Fedora 16)Michael Young2011-10-251-1/+2
| | | | | | | | Fedora 16 puts grub configuration files in /boot/grub2/grub.cfg so pygrub should look there as well Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* pygrub: check all GPT partitionsMichael Young2011-10-251-4/+13
| | | | | | | | | | | | | On Fedora 16 the first GPT partition is a boot partition for grub2 with the grub2 configuration in the second partition. Check all GPT partitions for grub configuration, not just the first. [ Also remove now-inaccurate comment. -iwj ] Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Tested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: add debug flagGuido Gunther2011-10-111-2/+10
| | | | | | | | | | Debugging config file errors is tedious so help a bit by not silently dropping parsing exceptions when --debug is given. Also intialize the logging API at debug level in this case. Signed-off-by: Guido Gunther <agx@sigxcpu.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: prefer Grub2 to Grub1Ian Campbell2011-07-151-5/+5
| | | | | | | | If a VM image has grub2 installed it is likely the one we need to be using. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools/pygrub: fix solaris kernel snifftools/pygrub: fix solaris kernel sniff2011-07-141-2/+5
| | | | | | | | | | | | Solaris 11 build 163+ removes '/platform/i86xpv/kernel/unix' and only the 64-bit PV kernel file '/platform/i86xpv/kernel/amd64/unix' exists. This patch fixes the detection. Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com> Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com> Signed-off-by: Frank Che <frank.che@oracle.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* pygrub: support grub2 "(hdX,msdosY)" partition syntaxIan Campbell2010-10-131-0/+2
| | | | | | | | This appeared in Debian Squeeze at some point. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* pygrub: look in every partition for something to bootIan Jackson2010-07-151-35/+62
| | | | | | | | | pygrub: look in every partition for something to boot, in case the OS installer (SLES 10 sp1 in particular) forgets to mark the boot partition as active. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> Acked-by: David Markey <admin@dmarkey.com>