fedoostrap or deboostrap requirement
by Piavlo
Hi,
While trying to ./configure libguestfs on gentoo fails since it requires
feboostrap or deboostrap
Can this be made optional and not as necessary requirement, since there
are still many useful uses for libguestfs
besides bootstrapping, which can be used on distros like gentoo.
Thanks
Alex
15 years, 1 month
[PATCH] Use grub entries to find Linux kernels
by Matthew Booth
This change adds grub parsing to Lib.pm. It adds the following structure to $os:
{boot}
->{configs}
->[0]
->{title} = "Fedora (2.6.29.6-213.fc11.i686.PAE)"
->{kernel} = \kernel
->{cmdline} = "ro root=/dev/mapper/vg_mbooth-lv_root rhgb"
->{initrd} = \initrd
->{default} = 0
The kernel and initrd entries are just references to their top level entries
under kernels and initrd_modules respectively.
It also changes the way Linux kernels and initrd are discovered. Instead of
searching /lib/modules and /boot for files with matching names, kernels and
initrds are scanned as they are discovered in grub.conf.
---
perl/lib/Sys/Guestfs/Lib.pm | 278 +++++++++++++++++++++++++++++--------------
1 files changed, 189 insertions(+), 89 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index bbc583f..20e29ff 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1343,7 +1343,6 @@ sub inspect_in_detail
_check_for_kernels ($g, $os);
if ($os->{os} eq "linux") {
_find_modprobe_aliases ($g, $os);
- _check_for_initrd ($g, $os);
}
}
@@ -1392,48 +1391,170 @@ sub _check_for_applications
sub _check_for_kernels
{
- local $_;
- my $g = shift;
- my $os = shift;
+ my ($g, $os) = @_;
- my @kernels;
+ if ($os->{os} eq "linux") {
+ # Iterate over entries in grub.conf, populating $os->{boot}
+ # For every kernel we find, inspect it and add to $os->{kernels}
+
+ my @boot_configs;
+
+ # We want
+ # $os->{boot}
+ # ->{configs}
+ # ->[0]
+ # ->{title} = "Fedora (2.6.29.6-213.fc11.i686.PAE)"
+ # ->{kernel} = \kernel
+ # ->{cmdline} = "ro root=/dev/mapper/vg_mbooth-lv_root rhgb"
+ # ->{initrd} = \initrd
+ # ->{default} = \config
+ # Initialise augeas
+ $g->aug_init("/", 16);
+
+ my @configs = ();
+ # Get all configurations from grub
+ foreach my $bootable
+ ($g->aug_match("/files/etc/grub.conf/title"))
+ {
+ my %config = ();
+ $config{title} = $g->aug_get($bootable);
+
+ my $grub_kernel;
+ eval {
+ $grub_kernel = $g->aug_get("$bootable/kernel");
+ };
+ if($@) {
+ warn __x("Grub entry {title} has no kernel",
+ title => $config{title});
+ }
- my $osn = $os->{os};
- if ($osn eq "linux") {
- # Installed kernels will have a corresponding /lib/modules/<version>
- # directory, which is the easiest way to find out what kernels
- # are installed, and what modules are available.
- foreach ($g->ls ("/lib/modules")) {
- if ($g->is_dir ("/lib/modules/$_")) {
- my %kernel;
- $kernel{version} = $_;
-
- # List modules.
- my @modules;
- my $any_module;
- my $prefix = "/lib/modules/$_";
- foreach ($g->find ($prefix)) {
- if (m,/([^/]+)\.ko$, || m,([^/]+)\.o$,) {
- $any_module = "$prefix$_" unless defined $any_module;
- push @modules, $1;
- }
- }
+ # Check we've got a kernel entry
+ if(defined($grub_kernel)) {
+ # Parse a kernel path and optional kernel command line
+ if($grub_kernel =~ /^\s*(\S+)(?:\s+(.*))?$/) {
+ my $kernel_path = $1;
+ $config{cmdline} = $2 if defined($2);
+
+ my $kernel = _inspect_linux_kernel($g, $os, "/boot$1");
+
+ # Check the kernel was recognised
+ if(defined($kernel)) {
+ $config{kernel} = $kernel;
+
+ # Look for an initrd entry
+ my $initrd;
+ eval {
+ $initrd = $g->aug_get("$bootable/initrd");
+ };
+
+ unless($@) {
+ $config{initrd} =
+ _inspect_initrd($g, $os, "/boot$initrd",
+ $kernel->{version});
+ } else {
+ warn __x("Grub entry {title} does not specify an ".
+ "initrd", title => $config{title});
+ }
+ }
+ }
+ else {
+ warn __x("Unexpected grub kernel line: {grub_kernel}",
+ grub_kernel => $grub_kernel);
+ next;
+ }
+ }
- $kernel{modules} = \@modules;
+ push(@configs, \%config);
+ }
- # Determine kernel architecture by looking at the arch
- # of any kernel module.
- $kernel{arch} = file_architecture ($g, $any_module);
- push @kernels, \%kernel;
- }
- }
+ # Create the top level boot entry
+ my %boot;
+ $boot{configs} = \@configs;
- } elsif ($osn eq "windows") {
+ # Add the default configuration
+ eval {
+ $boot{default} = $g->aug_get("/files/etc/grub.conf/default");
+ };
+ if($@) {
+ warn __"No grub default specified";
+ }
+
+ $os->{boot} = \%boot;
+ }
+
+ elsif ($os->{os} eq "windows") {
# XXX
}
+}
+
+sub _inspect_linux_kernel
+{
+ my ($g, $os, $path) = @_;
+
+ my %kernel = ();
+
+ $kernel{path} = $path;
+
+ # Try to get the kernel version by running file against it
+ my $version;
+ my $filedesc = $g->file($path);
+ if($filedesc =~ /^$path: Linux kernel .*\bversion\s+(\S+)\b/) {
+ $version = $1;
+ }
+
+ # Sometimes file can't work out the kernel version, for example because it's
+ # a Xen PV kernel. In this case try to guess the version from the filename
+ else {
+ if($path =~ m{/boot/vmlinuz-(.*)}) {
+ $version = $1;
+
+ # Check /lib/modules/$version exists
+ if(!$g->is_dir("/lib/modules/$version")) {
+ warn __x("Didn't find modules directory {modules} for kernel ".
+ "{path}", modules => "/lib/modules/$version",
+ path => $path);
+
+ # Give up
+ return undef;
+ }
+ } else {
+ warn __x("Couldn't guess kernel version number from path for ".
+ "kernel {path}", path => $path);
+
+ # Give up
+ return undef;
+ }
+ }
+
+ $kernel{version} = $version;
+
+ # List modules.
+ my @modules;
+ my $any_module;
+ my $prefix = "/lib/modules/$version";
+ foreach my $module ($g->find ($prefix)) {
+ if ($module =~ m{/([^/]+)\.(?:ko|o)$}) {
+ $any_module = "$prefix$module" unless defined $any_module;
+ push @modules, $1;
+ }
+ }
+
+ $kernel{modules} = \@modules;
+
+ # Determine kernel architecture by looking at the arch
+ # of any kernel module.
+ $kernel{arch} = file_architecture ($g, $any_module);
+
+ # Put this kernel on the top level kernel list
+ my $kernels = $os->{kernels};
+ if(!defined($kernels)) {
+ $kernels = [];
+ $os->{kernels} = $kernels;
+ }
+ push(@$kernels, \%kernel);
- $os->{kernels} = \@kernels;
+ return \%kernel;
}
# Find all modprobe aliases. Specifically, this looks in the following
@@ -1450,28 +1571,14 @@ sub _find_modprobe_aliases
my $os = shift;
# Initialise augeas
- my $success = 0;
- $success = $g->aug_init("/", 16);
-
- # Register /etc/modules.conf and /etc/conf.modules to the Modprobe lens
- my @results;
- @results = $g->aug_match("/augeas/load/Modprobe/incl");
-
- # Calculate the next index of /augeas/load/Modprobe/incl
- my $i = 1;
- foreach ( @results ) {
- next unless m{/augeas/load/Modprobe/incl\[(\d*)]};
- $i = $1 + 1 if ($1 == $i);
- }
+ $g->aug_init("/", 16);
- $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]",
- "/etc/modules.conf");
- $i++;
- $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]",
- "/etc/conf.modules");
+ # Register additional paths to the Modprobe lens
+ $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/modules.conf");
+ $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/conf.modules");
# Make augeas reload
- $success = $g->aug_load();
+ $g->aug_load();
my %modprobe_aliases;
@@ -1479,9 +1586,7 @@ sub _find_modprobe_aliases
/files/etc/modules.conf/alias
/files/etc/modprobe.conf/alias
/files/etc/modprobe.d/*/alias) {
- @results = $g->aug_match($pattern);
-
- for my $path ( @results ) {
+ for my $path ( $g->aug_match($pattern) ) {
$path =~ m{^/files(.*)/alias(?:\[\d*\])?$}
or die __x("{path} doesn't match augeas pattern",
path => $path);
@@ -1505,45 +1610,40 @@ sub _find_modprobe_aliases
$os->{modprobe_aliases} = \%modprobe_aliases;
}
-# Get a listing of device drivers in any initrd corresponding to a
-# kernel. This is an indication of what can possibly be booted.
-
-sub _check_for_initrd
+# Get a listing of device drivers from an initrd
+sub _inspect_initrd
{
- local $_;
- my $g = shift;
- my $os = shift;
+ my ($g, $os, $path, $version) = @_;
+
+ my @modules;
+
+ # Disregard old-style compressed ext2 files and only work with real
+ # compressed cpio files, since cpio takes ages to (fail to) process anything
+ # else.
+ if ($g->file ($path) =~ /cpio/) {
+ eval {
+ @modules = $g->initrd_list ($path);
+ };
+ unless ($@) {
+ @modules = grep { m{([^/]+)\.(?:ko|o)$} } @modules;
+ } else {
+ warn __x("{filename}: could not read initrd format",
+ filename => "$path");
+ }
+ }
- my %initrd_modules;
-
- foreach my $initrd ($g->ls ("/boot")) {
- if ($initrd =~ m/^initrd-(.*)\.img$/ && $g->is_file ("/boot/$initrd")) {
- my $version = $1;
- my @modules;
-
- # Disregard old-style compressed ext2 files and only
- # work with real compressed cpio files, since cpio
- # takes ages to (fail to) process anything else.
- if ($g->file ("/boot/$initrd") =~ /cpio/) {
- eval {
- @modules = $g->initrd_list ("/boot/$initrd");
- };
- unless ($@) {
- @modules = grep { m,([^/]+)\.ko$, || m,([^/]+)\.o$, }
- @modules;
- $initrd_modules{$version} = \@modules
- } else {
- warn __x("{filename}: could not read initrd format",
- filename => "/boot/$initrd");
- }
- }
- }
+ # Add to the top level initrd_modules entry
+ my $initrd_modules = $os->{initrd_modules};
+ if(!defined($initrd_modules)) {
+ $initrd_modules = {};
+ $os->{initrd_modules} = $initrd_modules;
}
+
+ $initrd_modules->{$version} = \@modules;
- $os->{initrd_modules} = \%initrd_modules;
+ return \@modules;
}
-
1;
=head1 COPYRIGHT
--
1.6.2.5
15 years, 1 month
[PATCH] Update incorrect comment in Lib.pm
by Matthew Booth
Related: change the name of the function the comment describes to be more
accurate.
---
perl/lib/Sys/Guestfs/Lib.pm | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index be17a30..bbc583f 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1342,7 +1342,7 @@ sub inspect_in_detail
_check_for_applications ($g, $os);
_check_for_kernels ($g, $os);
if ($os->{os} eq "linux") {
- _check_for_modprobe_aliases ($g, $os);
+ _find_modprobe_aliases ($g, $os);
_check_for_initrd ($g, $os);
}
}
@@ -1436,16 +1436,14 @@ sub _check_for_kernels
$os->{kernels} = \@kernels;
}
-# Check /etc/modprobe.conf to see if there are any specified
-# drivers associated with network (ethX) or hard drives. Normally
-# one might find something like:
-#
-# alias eth0 xennet
-# alias scsi_hostadapter xenblk
-#
-# XXX This doesn't look beyond /etc/modprobe.conf, eg. in /etc/modprobe.d/
+# Find all modprobe aliases. Specifically, this looks in the following
+# locations:
+# * /etc/conf.modules
+# * /etc/modules.conf
+# * /etc/modprobe.conf
+# * /etc/modprobe.d/*
-sub _check_for_modprobe_aliases
+sub _find_modprobe_aliases
{
local $_;
my $g = shift;
--
1.6.2.5
15 years, 1 month
[PATCH] Fix broken qemu <= 0.10 which randomly adds a CD-ROM device to the appliance
by Richard W.M. Jones
qemu <= 0.10 randomly adds a CD-ROM device to the appliance because of
this bit of code:
http://git.savannah.gnu.org/cgit/qemu.git/tree/vl.c?h=stable-0.10#n5495
Thankfully this code has been removed from upstream qemu.
Anyway I'm not quite sure why we never saw this before - it seems like
this code didn't exist in the versions of qemu that were in Fedora, or
somehow this code only runs some of the time. But anyway, this breaks
the tests in Fedora 11 and RHEL 5.3 right now.
The attached code attempts to work around this stupidity by adding
checks in list_devices and list_partitions to see if the device is
openable, and ignoring any which aren't. These fake, empty CD drives
fail this extra check with error "No medium found", so they get
ignored.
[I'm still running all the tests with this patch, so not quite sure if
it's correct.]
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
15 years, 1 month
Re: error when compiling libguestfs on Ubuntu 9.04
by LANNUZEL Anthony IT&L@bs
> Install debian-archive-keyring:
>
> http://packages.debian.org/sid/debian-archive-keyring
>
> Debirf wants to pass it to debootstrap for verification. The other
> possibility is to try to build an Ubuntu based appliance instead of a
> Debian based one with:
>
> /configure --with-repo=karmic --with-mirror=<your_ubuntu_mirror>
Hi,
I just got the same issue, and tried your advices.
After installing debian-archive-keyring, I ran the following command:
./configure --with-repo=jaunty
--with-mirror=http://fr.archive.ubuntu.com/ubuntu
but when I run "make" I get the following error:
Loading profile 'debian'...
debirf: clearing old debirf root...
debirf: creating debirf root...
failed to open configuration file `/root/.dpkg.cfg' for reading:
Permission denied
So I run "make" as root, even if it is not recommended. Now I get the
following error:
debirf: creating debirf root...
I: Retrieving Release
I: Retrieving Release.gpg
I: Checking Release signature
E: Release signed by unknown key (key id 40976EAF437D05B5)
I ran the following commands but I still get the same error:
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 40976EAF437D05B5
gpg --export 437D05B5 >> ~/.gnupg/trustedkeys.gpg
sudo apt-key add ~/.gnupg/pubring.gpg
sudo apt-get update -o Acquire::http::No-Cache=True
Any hints ?
Regards
Anthony
15 years, 1 month
[PATCH] build: fix test for --nocompress option
by Jim Meyering
The test for febootstrap-to-initramfs' --nocompress option
was always failing for me on F11. Here's why:
$ bash ~/w/co/libguestfs:210-comment-fix
$ t=`febootstrap-to-initramfs 2>&1`
[Exit 1]
$ if ! echo $t|grep -sq -- --nocompress; then echo not found; fi
not found
Notice: without quotes, the [--nocompress] term expands to "k",
because I happen to have a temporary file named "k":
$ echo $t
Usage: febootstrap-to-initramfs [--files=filelist] k DIR Please read
febootstrap-to-initramfs(8) man page for more information.
$ echo "$t"
Usage: febootstrap-to-initramfs [--files=filelist] [--nocompress] DIR
Please read febootstrap-to-initramfs(8) man page for more information.
a simpler example gives a clue:
$ touch a b c
$ echo [--z]
a b c
$ echo [--a]
a
$ echo [--b]
a b
it's interpreting [--nocompress] as a range: "-" through "n", plus
the other characters, ocmpres. "k" falls in the --n range.
Anyhow, here's the fix:
>From 84855642ed41828d01d55123cfab8d8dede759c1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 29 Jul 2009 16:33:02 -0400
Subject: [PATCH] build: fix test for --nocompress option
* configure.ac: Fix underquoting bug that would cause the test
for febootstrap-to-initramfs' --nocompress option always to fail
with certain-letter-named files in the top directory.
---
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 0ae20be..6bdf7d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -264,7 +264,7 @@ version of febootstrap.
AC_MSG_CHECKING([for --nocompress support in $FEBOOTSTRAP_TO_INITRAMFS])
out=`$FEBOOTSTRAP_TO_INITRAMFS 2>&1 ||:`
echo "febootstrap_to_initramfs test command output: $out" >&AS_MESSAGE_LOG_FD
- if ! echo $out | grep -sq -- "--nocompress" ; then
+ if ! echo "$out" | grep -sq -e --nocompress ; then
AC_MSG_RESULT([no])
AC_MSG_FAILURE(
[febootstrap-to-initramfs does not support the --nocompress option.
--
1.6.3.3
15 years, 1 month
[PATCH] build: avoid locale-specific changes in generated, VC'd file
by Jim Meyering
When I build with LC_ALL=C in my environment,
the all-local rule generates po/POTFILES.in that
is sorted differently from the on that is checked in:
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ca01b3d..154915a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -63,12 +63,11 @@ fish/tilde.c
fish/time.c
inspector/virt-inspector.pl
java/com_redhat_et_libguestfs_GuestFS.c
-ocaml/guestfs_c_actions.c
ocaml/guestfs_c.c
+ocaml/guestfs_c_actions.c
perl/bindtests.pl
-perl/Guestfs.c
-perl/lib/Sys/Guestfs/Lib.pm
perl/lib/Sys/Guestfs.pm
+perl/lib/Sys/Guestfs/Lib.pm
python/guestfs-py.c
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.c
If we generate that file so that sort always uses the C locale, then,
this type of difference will not arise. Here's the patch to fix the
rule as well as to reflect the change in the generated file:
>From 609e1d1840da25614a7c9e8954e5356050c9f2ad Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 29 Jul 2009 08:13:35 -0400
Subject: [PATCH] build: avoid locale-specific changes in generated, VC'd file
* Makefile.am (all-local): Use LC_ALL=C to sort in C locale.
* po/POTFILES.in: Regenerate.
---
Makefile.am | 2 +-
po/POTFILES.in | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index f118291..3cba8bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -165,7 +165,7 @@ all-local:
grep -v 'examples/' | \
grep -v '/guestfs_protocol.c' | \
grep -v '/rc_protocol.c' | \
- sort | \
+ LC_ALL=C sort | \
sed 's,^\./,,' > po/POTFILES.in
# Pkgconfig.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ca01b3d..154915a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -63,12 +63,11 @@ fish/tilde.c
fish/time.c
inspector/virt-inspector.pl
java/com_redhat_et_libguestfs_GuestFS.c
-ocaml/guestfs_c_actions.c
ocaml/guestfs_c.c
+ocaml/guestfs_c_actions.c
perl/bindtests.pl
-perl/Guestfs.c
-perl/lib/Sys/Guestfs/Lib.pm
perl/lib/Sys/Guestfs.pm
+perl/lib/Sys/Guestfs/Lib.pm
python/guestfs-py.c
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.c
--
1.6.3.3
15 years, 1 month