pygrub: Ignore GRUB2 if statements
PATCH 1/2 pygrub: Ignore GRUB2 if statements
SLES 12's default GRUB config has the following code before any entries:
if [ -n "$extra_cmdline" ]; then
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback' and reboot." { true; } }
fi
This prevents pygrub from booting using the default entry. Since I'm not aware of any distro GRUB config which puts useful entries within conditionals, ignore them.
--- tools/pygrub/src/GrubConf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/pygrub/src/GrubConf.py +7 -1
@@ -373,6 +373,7 @@ class Grub2ConfigFile(_GrubConfigFile): lines = buf.split("\n") in_function = False + in_if = False img = None title = "" menu_level=0
@@ -389,9 +390,14 @@ class Grub2ConfigFile(_GrubConfigFile): if l.startswith('function'): in_function = True continue - if in_function: + elif l.startswith('if'): + in_if = True + continue + if in_function or in_if: if l.startswith('}'): in_function = False + elif l.startswith('fi'): + in_if = False continue # new image
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 2/2 libfsimage: Add support for btrfs
Add support for booting from btrfs filesystems. All the code except fsys_btrfs.c is imported from btrfs-progs 4.5.1. btrfs-progs is licensed as GPLv2. The files have been imported with minimal modification. Further work could split and prune the support code to only what is required for reading.
The driver supports following subvolumes and symlinks, and reading files with compression (zlib and lzo). This driver is useful for booting SLES 12 in its default configuration, since it uses btrfs.
--- tools/libfsimage/Makefile | 2 +- tools/libfsimage/btrfs/Makefile | 36 + tools/libfsimage/btrfs/bitops.h | 224 ++ tools/libfsimage/btrfs/btrfs-list.h | 178 ++ tools/libfsimage/btrfs/commands.h | 134 + tools/libfsimage/btrfs/crc32c.c | 222 ++ tools/libfsimage/btrfs/crc32c.h | 33 + tools/libfsimage/btrfs/ctree.c | 2941 ++++++++++++++++++++ tools/libfsimage/btrfs/ctree.h | 2570 ++++++++++++++++++ tools/libfsimage/btrfs/dir-item.c | 351 +++ tools/libfsimage/btrfs/disk-io.c | 1779 +++++++++++++ tools/libfsimage/btrfs/disk-io.h | 168 ++ tools/libfsimage/btrfs/extent-cache.c | 341 +++ tools/libfsimage/btrfs/extent-cache.h | 121 + tools/libfsimage/btrfs/extent-tree.c | 4122 +++++++++++++++++++++++++++++ tools/libfsimage/btrfs/extent_io.c | 895 +++++++ tools/libfsimage/btrfs/extent_io.h | 159 ++ tools/libfsimage/btrfs/file-item.c | 487 ++++ tools/libfsimage/btrfs/free-space-cache.c | 879 ++++++ tools/libfsimage/btrfs/free-space-cache.h | 62 + tools/libfsimage/btrfs/fsys_btrfs.c | 862 ++++++ tools/libfsimage/btrfs/hash.h | 28 + tools/libfsimage/btrfs/inode-item.c | 460 ++++ tools/libfsimage/btrfs/inode.c | 536 ++++ tools/libfsimage/btrfs/internal.h | 42 + tools/libfsimage/btrfs/ioctl.h | 729 +++++ tools/libfsimage/btrfs/kerncompat.h | 354 +++ tools/libfsimage/btrfs/list.h | 486 ++++ tools/libfsimage/btrfs/print-tree.h | 27 + tools/libfsimage/btrfs/radix-tree.h | 97 + tools/libfsimage/btrfs/raid6.c | 101 + tools/libfsimage/btrfs/rbtree-utils.c | 82 + tools/libfsimage/btrfs/rbtree-utils.h | 53 + tools/libfsimage/btrfs/rbtree.c | 548 ++++ tools/libfsimage/btrfs/rbtree.h | 118 + tools/libfsimage/btrfs/rbtree_augmented.h | 249 ++ tools/libfsimage/btrfs/repair.c | 50 + tools/libfsimage/btrfs/repair.h | 34 + tools/libfsimage/btrfs/root-tree.c | 192 ++ tools/libfsimage/btrfs/transaction.h | 64 + tools/libfsimage/btrfs/utils.c | 3242 +++++++++++++++++++++++ tools/libfsimage/btrfs/utils.h | 342 +++ tools/libfsimage/btrfs/volumes.c | 2131 +++++++++++++++ tools/libfsimage/btrfs/volumes.h | 229 ++ 44 files changed, 26759 insertions(+), 1 deletion(-) create mode 100644 tools/libfsimage/btrfs/Makefile create mode 100644 tools/libfsimage/btrfs/bitops.h create mode 100644 tools/libfsimage/btrfs/btrfs-list.h create mode 100644 tools/libfsimage/btrfs/commands.h create mode 100644 tools/libfsimage/btrfs/crc32c.c create mode 100644 tools/libfsimage/btrfs/crc32c.h create mode 100644 tools/libfsimage/btrfs/ctree.c create mode 100644 tools/libfsimage/btrfs/ctree.h create mode 100644 tools/libfsimage/btrfs/dir-item.c create mode 100644 tools/libfsimage/btrfs/disk-io.c create mode 100644 tools/libfsimage/btrfs/disk-io.h create mode 100644 tools/libfsimage/btrfs/extent-cache.c create mode 100644 tools/libfsimage/btrfs/extent-cache.h create mode 100644 tools/libfsimage/btrfs/extent-tree.c create mode 100644 tools/libfsimage/btrfs/extent_io.c create mode 100644 tools/libfsimage/btrfs/extent_io.h create mode 100644 tools/libfsimage/btrfs/file-item.c create mode 100644 tools/libfsimage/btrfs/free-space-cache.c create mode 100644 tools/libfsimage/btrfs/free-space-cache.h create mode 100644 tools/libfsimage/btrfs/fsys_btrfs.c create mode 100644 tools/libfsimage/btrfs/hash.h create mode 100644 tools/libfsimage/btrfs/inode-item.c create mode 100644 tools/libfsimage/btrfs/inode.c create mode 100644 tools/libfsimage/btrfs/internal.h create mode 100644 tools/libfsimage/btrfs/ioctl.h create mode 100644 tools/libfsimage/btrfs/kerncompat.h create mode 100644 tools/libfsimage/btrfs/list.h create mode 100644 tools/libfsimage/btrfs/print-tree.h create mode 100644 tools/libfsimage/btrfs/radix-tree.h create mode 100644 tools/libfsimage/btrfs/raid6.c create mode 100644 tools/libfsimage/btrfs/rbtree-utils.c create mode 100644 tools/libfsimage/btrfs/rbtree-utils.h create mode 100644 tools/libfsimage/btrfs/rbtree.c create mode 100644 tools/libfsimage/btrfs/rbtree.h create mode 100644 tools/libfsimage/btrfs/rbtree_augmented.h create mode 100644 tools/libfsimage/btrfs/repair.c create mode 100644 tools/libfsimage/btrfs/repair.h create mode 100644 tools/libfsimage/btrfs/root-tree.c create mode 100644 tools/libfsimage/btrfs/transaction.h create mode 100644 tools/libfsimage/btrfs/utils.c create mode 100644 tools/libfsimage/btrfs/utils.h create mode 100644 tools/libfsimage/btrfs/volumes.c create mode 100644 tools/libfsimage/btrfs/volumes.h
tools/libfsimage/Makefile +1 -1
@@ -1,7 +1,7 @@ XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/Rules.mk -SUBDIRS-y = common ufs reiserfs iso9660 fat zfs +SUBDIRS-y = common ufs reiserfs iso9660 fat zfs btrfs SUBDIRS-$(CONFIG_X86) += xfs ifneq ($(EXTFS_LIBS), ) SUBDIRS-y += ext2fs-lib
tools/libfsimage/btrfs/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +XEN_ROOT = $(CURDIR)/../../.. + +CFLAGS += -DBTRFS_FLAT_INCLUDES=1 +LIB_SRCS-y = fsys_btrfs.c \ + crc32c.c \ + ctree.c \ + dir-item.c \ + disk-io.c \ + extent-cache.c \ + extent_io.c \ + extent-tree.c \ + file-item.c \ + free-space-cache.c \ + inode.c \ + inode-item.c \ + raid6.c \ + rbtree.c \ + rbtree-utils.c \ + repair.c \ + root-tree.c \ + utils.c \ + volumes.c + +FS = btrfs +FS_LIBDEPS = $(filter -llzo2,$(ZLIB)) -lz + +# Include configure output (config.h) +CFLAGS += -include $(XEN_ROOT)/tools/config.h + +.PHONY: all +all: fs-all + +.PHONY: install +install: fs-install + +include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/btrfs/bitops.h new file +224 -0
224 lines not on this page · raw message
tools/libfsimage/btrfs/btrfs-list.h new file +178 -0
178 lines not on this page · raw message
tools/libfsimage/btrfs/commands.h new file +134 -0
134 lines not on this page · raw message
tools/libfsimage/btrfs/crc32c.c new file +222 -0
222 lines not on this page · raw message
tools/libfsimage/btrfs/crc32c.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) 2007 Red Hat. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program 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 this program; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 021110-1307, USA. +*/ + +#ifndef __CRC32C__ +#define __CRC32C__ + +#if BTRFS_FLAT_INCLUDES +#include "kerncompat.h" +#else +#include <btrfs/kerncompat.h> +#endif /* BTRFS_FLAT_INCLUDES */ + +u32 crc32c_le (u32 seed,unsigned char const *data,size_t length); +void crc32c_optimization_init (void ); + +#define crc32c (seed, data, length) crc32c_le(seed, (unsigned char const *)data, length) +#define btrfs_crc32c crc32c +#endif
tools/libfsimage/btrfs/ctree.c new file +2941 -0
2,165 lines not on this page · raw message
tools/libfsimage/btrfs/ctree.h new file +2570 -0
2,570 lines not on this page · raw message
tools/libfsimage/btrfs/dir-item.c new file +351 -0
351 lines not on this page · raw message
tools/libfsimage/btrfs/disk-io.c new file +1779 -0
1,779 lines not on this page · raw message
tools/libfsimage/btrfs/disk-io.h new file +168 -0
168 lines not on this page · raw message
tools/libfsimage/btrfs/extent-cache.c new file +341 -0
341 lines not on this page · raw message
tools/libfsimage/btrfs/extent-cache.h new file +121 -0
121 lines not on this page · raw message
tools/libfsimage/btrfs/extent-tree.c new file +4122 -0
4,122 lines not on this page · raw message
tools/libfsimage/btrfs/extent_io.c new file +895 -0
895 lines not on this page · raw message
tools/libfsimage/btrfs/extent_io.h new file +159 -0
159 lines not on this page · raw message
tools/libfsimage/btrfs/file-item.c new file +487 -0
487 lines not on this page · raw message
tools/libfsimage/btrfs/free-space-cache.c new file +879 -0
879 lines not on this page · raw message
tools/libfsimage/btrfs/free-space-cache.h new file +62 -0
62 lines not on this page · raw message
tools/libfsimage/btrfs/fsys_btrfs.c new file +862 -0
862 lines not on this page · raw message
tools/libfsimage/btrfs/hash.h new file +28 -0
Lines of this file are not shown. View the raw message.
tools/libfsimage/btrfs/inode-item.c new file +460 -0
460 lines not on this page · raw message
tools/libfsimage/btrfs/inode.c new file +536 -0
536 lines not on this page · raw message
tools/libfsimage/btrfs/internal.h new file +42 -0
42 lines not on this page · raw message
tools/libfsimage/btrfs/ioctl.h new file +729 -0
729 lines not on this page · raw message
tools/libfsimage/btrfs/kerncompat.h new file +354 -0
354 lines not on this page · raw message
tools/libfsimage/btrfs/list.h new file +486 -0
486 lines not on this page · raw message
tools/libfsimage/btrfs/print-tree.h new file +27 -0
Lines of this file are not shown. View the raw message.
tools/libfsimage/btrfs/radix-tree.h new file +97 -0
97 lines not on this page · raw message
tools/libfsimage/btrfs/raid6.c new file +101 -0
101 lines not on this page · raw message
tools/libfsimage/btrfs/rbtree-utils.c new file +82 -0
82 lines not on this page · raw message
tools/libfsimage/btrfs/rbtree-utils.h new file +53 -0
53 lines not on this page · raw message
tools/libfsimage/btrfs/rbtree.c new file +548 -0
548 lines not on this page · raw message
tools/libfsimage/btrfs/rbtree.h new file +118 -0
118 lines not on this page · raw message
tools/libfsimage/btrfs/rbtree_augmented.h new file +249 -0
249 lines not on this page · raw message
tools/libfsimage/btrfs/repair.c new file +50 -0
50 lines not on this page · raw message
tools/libfsimage/btrfs/repair.h new file +34 -0
Lines of this file are not shown. View the raw message.
tools/libfsimage/btrfs/root-tree.c new file +192 -0
192 lines not on this page · raw message
tools/libfsimage/btrfs/transaction.h new file +64 -0
64 lines not on this page · raw message
tools/libfsimage/btrfs/utils.c new file +3242 -0
3,242 lines not on this page · raw message
tools/libfsimage/btrfs/utils.h new file +342 -0
342 lines not on this page · raw message
tools/libfsimage/btrfs/volumes.c new file +2131 -0
2,131 lines not on this page · raw message
tools/libfsimage/btrfs/volumes.h new file +229 -0
229 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Part of the diff is not shown here. View the raw message.
Re: [PATCH 2/2] libfsimage: Add support for btrfs
Ross Lagerwall writes ("[PATCH 2/2] libfsimage: Add support for btrfs"):
Quoted 9 lines
Add support for booting from btrfs filesystems. All the code except
fsys_btrfs.cis imported from btrfs-progs 4.5.1. btrfs-progs is licensed as GPLv2. The files have been imported with minimal modification. Further work could split and prune the support code to only what is required for reading.The driver supports following subvolumes and symlinks, and reading files with compression (zlib and lzo). This driver is useful for booting SLES 12 in its default configuration, since it uses btrfs.
I think this is fine in principle. But can you split the code import from the code you have written ? I guess I don't mean to ask you to _rearrange_ the code, but can you split it into separate commits ? I think that will make archeaology etc. much easier.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ross Lagerwall writes ("[PATCH 1/2] pygrub: Ignore GRUB2 if statements"):
Quoted 10 lines
SLES 12's default GRUB config has the following code before any entries:
if [ -n "$extra_cmdline" ]; thensubmenu "Bootable snapshot #$snapshot_num" { menuentry "If OK, run 'snapper rollback' and reboot." { true; }}
fiThis prevents pygrub from booting using the default entry. Since I'm not aware of any distro GRUB config which puts useful entries within conditionals, ignore them.
I think this has a risk of breaking things, doesn't it ? I mean, existing setups might contain `if's and the relevant parts would no longer be processed.
So I think this isn't a backport candidate. And really I would like an alternative, less risky fix, which would be a backport candidate. Can you think of an alternative approach ?
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel