Hello community, here is the log from the commit of package libguestfs for openSUSE:Factory checked in at 2013-08-07 20:45:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libguestfs (Old) and /work/SRC/openSUSE:Factory/.libguestfs.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libguestfs" Changes: -------- New Changes file: --- /dev/null 2013-07-23 23:44:04.804033756 +0200 +++ /work/SRC/openSUSE:Factory/.libguestfs.new/libguestfs.changes 2013-08-07 20:45:13.000000000 +0200 @@ -0,0 +1,898 @@ +------------------------------------------------------------------- +Mon Aug 5 17:48:01 CEST 2013 - oher...@suse.de + +- Package /lib/udev or /usr/lib/udev in guestfsd subpackage + +------------------------------------------------------------------- +Tue Jul 30 20:57:39 CEST 2013 - oher...@suse.de + +- Update to version 1.20.10 + * sysprep: On RHEL, firstboot script should be called S99... not 99. + * fish: For -N option, add drive with explicit format = "raw". + * daemon: Implement set-label for XFS and fix it for btrfs (RHBZ#986875). + * mkfs: Use -b size=<size> for xfs (RHBZ#981715). + * cmd: Allow callers to override file-closing behaviour after fork. + * daemon: hivex: Check that hivex_commit is passed an absolute path (RHBZ#981683). + * daemon: Verify ext2/3/4 filesystem name before passing to mke2fs (RHBZ#978302). + * virt-resize: Add notes about Windows and disk consistency (RHBZ#975753). + * virt-resize: Take into account large start offset of the first partition when calculating overhead (RHBZ#974904). + * launch: direct: Calculate appliance root correctly when iface drives are added (RHBZ#975797). + +------------------------------------------------------------------- +Sun Jun 16 08:36:08 CEST 2013 - oher...@suse.de + +- Update to version 1.20.9 + * txz-out: Fix this API to produce xz files again (RHBZ#972775). + * inspect: Fix bogus warning for partitions without /boot.ini + * inspect: Partial support for non-standard windows system root + * events: Avoid event handler limit if program allocates and deallocates handlers. + * proto: Fix for rare FileIn hangs. (RHBZ#969845) + * inspection: Don't segfault if /etc/SuSE-release is an empty file. + * fuse: Allow specifying the fstype of a mount + * is_lv: Does not need to depend on lvm2. + * add --with-supermin-extra-options configure option + * Remove use of gnulib progname module. + * inspection: Fix double-free when certain guest files are empty. (CVE-2013-2124) + * daemon: Properly quote arguments for tar-out, base64-out commands (RHBZ#957772). + * inspection: Don't fail if libosinfo database is not found (RHBZ#948324). + * daemon/copy: Ensure errno is preserved along error + * Better error messages for FUSE and other things not supported. + +------------------------------------------------------------------- +Mon Apr 8 20:55:11 CEST 2013 - oher...@suse.de + +- force paths to supermin/supermin-helper even if package is not available at buildtime + +------------------------------------------------------------------- +Tue Apr 2 14:43:33 CEST 2013 - oher...@suse.de + +- Update to version 1.20.5 + * daemon: file: Remove extraneous space after output of 'file' command (RHBZ#928995). + * lib: Add missing cases in switch statements. + * appliance: Make sure cachedir has mode 0755 (RHBZ#921292). + * appliance: Use ignore_value() macro instead of casting return to (void). + * launch: Print attach-method, tmpdir, umask, euid when launching. + * utils: Fix error messages for external commands that fail (RHBZ#921040). + +------------------------------------------------------------------- +Tue Apr 2 14:39:01 CEST 2013 - oher...@suse.de + +- make sure /etc/lvm/lvm.conf exists (bnc#812931) + +------------------------------------------------------------------- +Fri Mar 22 19:55:41 CET 2013 - oher...@suse.de + +- Update to version 1.20.4 + * launch: appliance: Add custom parameters last. + * filearch: Don't print errno if cpio command fails, print command status instead. + * proto: send_to_daemon is not an exported function. + +------------------------------------------------------------------- +Mon Mar 18 18:46:34 UTC 2013 - dmuel...@suse.com + +- use proper build conditionals so that it can be influenced + outside spec file (via e.g. prjconf) + +------------------------------------------------------------------- +Wed Mar 6 20:27:13 CET 2013 - oher...@suse.de + +- Update to version 1.20.3 + * trace: Put trace buffer on the stack instead of in the handle. + * FAQ: Add question about running fsck on live filesystems + * lib: Check calls to xmlXPathEvalExpression for nodesetval == NULL. + * recipes: Add example converting from one format/filesystem to another + * daemon: protocol: Fix memory leak when receiving FileIn file (RHBZ#914934). + * protocol: Don't segfault if appliance crashes during FileIn upload (RHBZ#914931). + * libutils: Add guestfs___count_strings utility function to common library + * lib: Create libutils convenience library. + * docs: Rewrite security section (thanks Dan Berrange) + * lib: Fix memory leak when the 'lpj' setting is read from dmesg. + +------------------------------------------------------------------- +Mon Feb 25 21:51:17 CET 2013 - oher...@suse.de + +- Update to version 1.20.2 + * proto: Fix stack overflow when there are many progress events (RHBZ#909624). + * rescue: Count the mountable filesystems when displaying the 'suggest' message. + * lib: Define CLEANUP_CMD_CLOSE macro and use it throughout the library. + * lib: Allow guestfs_free_* functions to be safely called with a NULL pointer. + * btrfs: Fix btrfs_subvolume_list on F18 (RHBZ#903620). + * daemon: Check parameter of base64-out and tar-out before running external command (RHBZ#908322). + * daemon: download: Add extra check that download file is not a directory (RHBZ#908321). + * daemon: Add more information to certain calls to perror. + * daemon: Call wipefs before mkfs to work around pathological behaviour in btrfs. + * lib: Add CLEANUP_* macros which automatically free things when leaving scope. + * header: Deprecate LIBGUESTFS_HAVE_* in favour of GUESTFS_HAVE_*. + * fuse: Use guestfs_rename to implement rename(2) syscall (RHBZ#895910). + * New API: rename: Rename file within the same filesystem (RHBZ#895910). + * fuse: If guestfs_last_errno returns 0, don't return no error to FUSE layer. + * daemon: Change ln, ln-f (hard-link) APIs to use link(2) instead of external ln (RHBZ#895905). + * Fix checksums-out command (RHBZ#895904). + * launch: appliance: Fix parsing of QEMU_OPTIONS. + * launch: appliance: Small refactoring of virtio-scsi detection code. + +------------------------------------------------------------------- +Mon Feb 25 20:11:27 CET 2013 - oher...@suse.de + +- enable ruby bindings only in 12.2 or later, ruby is too fragile + +------------------------------------------------------------------- +Sun Feb 24 18:11:07 CET 2013 - oher...@suse.de + +- BuildRequire: perl-macros only in sles11 builds to fix build in 11.4 + +------------------------------------------------------------------- +Fri Jan 18 14:28:46 CET 2013 - oher...@suse.de + +- more fixes for copying entire /etc/lvm directory (bnc#795503) + +------------------------------------------------------------------- +Wed Jan 16 16:40:46 CET 2013 - oher...@suse.de + +- disable strip and /usr/lib/rpm/find-debuginfo.sh for non-opt builds + it destroys bytecode binaries + +------------------------------------------------------------------- +Thu Jan 3 14:01:47 CET 2013 - oher...@suse.de + +- handle more architectures than just x86 when looking for guest kernel + +------------------------------------------------------------------- +Wed Jan 2 16:19:30 CET 2013 - oher...@suse.de + +- Update to version 1.20.1 + * inspection: Set fs->device field on swap devices. + * Pass noapic on i686 kernel command line. + * daemon: Use pvcreate --force option (RHBZ#887971). + * daemon: Fold stdout on stderr when running e2fsck. + * other minor changes + +------------------------------------------------------------------- +Wed Jan 2 16:00:13 CET 2013 - oher...@suse.de + +- copy entire /etc/lvm directory in guestfsd (bnc#795503) + +------------------------------------------------------------------- +Mon Dec 17 23:48:22 CET 2012 - oher...@suse.de + +- correct initrd filename on i586 (bnc#794819) + +------------------------------------------------------------------- +Thu Dec 13 17:09:48 CET 2012 - oher...@suse.de + +- Update to stable branch, version 1.20.0 + +------------------------------------------------------------------- +Tue Dec 11 17:54:19 CET 2012 - oher...@suse.de + +- add Conflicts: (libguestfs0|guestfs-data) with old versions to + guestfs-tools to make sure all parts match the same API + +------------------------------------------------------------------- +Thu Nov 29 20:25:33 CET 2012 - oher...@suse.de + +- update BuildRequire ext4-writeable-kmp-default handling + enable it unconditional in sles11 builds, but not in the + Virtualization repo because its a private package. + +------------------------------------------------------------------- +Thu Nov 29 20:15:11 CET 2012 - oher...@suse.de + +- make perl-bindings (perl-Sys-Guestfs) optional, disabled for sles11 + +------------------------------------------------------------------- +Sun Nov 25 18:17:02 CET 2012 - oher...@suse.de + +- include Pod-Simple-3.23.tar.gz to get perl(Pod::Simple::XHTML) + at build time (bnc#789653) +- Update to version 1.19.64 (fate#312159) + +------------------------------------------------------------------- +Mon Nov 19 18:26:16 CET 2012 - oher...@suse.de + +- readd autoreconf -fi if automake is newer than 1.10 + it fixes ruby build failures due to RPATH ending up in libraries + in 11.4 and 12.1 + +------------------------------------------------------------------- ++++ 701 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:Factory/.libguestfs.new/libguestfs.changes New: ---- 1000-force-virtio_blk-in-old-guest-kernel.patch Pod-Simple-3.23.tar.xz libguestfs-1.20.10.tar.xz libguestfs.changes libguestfs.mkinitrd.1110.patch libguestfs.mkinitrd.1210.patch libguestfs.mkinitrd.1220.patch libguestfs.mkinitrd.boot.sh libguestfs.mkinitrd.setup.sh libguestfs.spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libguestfs.spec ++++++ ++++ 753 lines (skipped) ++++++ 1000-force-virtio_blk-in-old-guest-kernel.patch ++++++ >From f010abe024b47057f814e369b7b647e52d001019 Mon Sep 17 00:00:00 2001 From: Olaf Hering <o...@aepfle.de> Date: Mon, 3 Sep 2012 19:50:44 +0200 Subject: [PATCH] force virtio_blk in old guest kernel Signed-off-by: Olaf Hering <o...@aepfle.de> --- df/output.c | 13 +++++++++---- fish/options.c | 8 +++++++- src/guestfs-internal.h | 2 ++ src/handle.c | 16 ++++++++++++++++ src/inspect-fs-unix.c | 4 ++-- src/launch-appliance.c | 3 +++ src/launch-libvirt.c | 7 +++++++ test-tool/test-tool.c | 16 +++++++++++++--- 8 files changed, 59 insertions(+), 10 deletions(-) diff --git a/df/output.c b/df/output.c index 5729dd4..fb33ca1 100644 --- a/df/output.c +++ b/df/output.c @@ -42,6 +42,7 @@ #include "virt-df.h" static void write_csv_field (const char *field); +static int use_virtio_blk; void print_title (void) @@ -82,7 +83,7 @@ print_title (void) } } -static char *adjust_device_offset (const char *device, int offset); +static char *adjust_device_offset (guestfs_h *g, const char *device, int offset); void print_stat (const char *name, const char *uuid_param, @@ -110,7 +111,7 @@ print_stat (const char *name, const char *uuid_param, exit (EXIT_FAILURE); if (offset >= 0) { char *p = dev; - dev = adjust_device_offset (p, offset); + dev = adjust_device_offset (g, p, offset); free (p); } @@ -237,8 +238,9 @@ write_csv_field (const char *field) static char *drive_name (int index, char *ret); static char * -adjust_device_offset (const char *device, int offset) +adjust_device_offset (guestfs_h *g, const char *device, int offset) { + ; int index; int part_num; char *whole_device; @@ -282,7 +284,10 @@ adjust_device_offset (const char *device, int offset) exit (EXIT_FAILURE); } - strcpy (ret, "/dev/sd"); +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif + strcpy (ret, use_virtio_blk ? "/dev/vd" : "/dev/sd"); drive_name (index, &ret[7]); len = strlen (ret); if (part_num > 0) diff --git a/fish/options.c b/fish/options.c index 384ef43..74703ca 100644 --- a/fish/options.c +++ b/fish/options.c @@ -27,6 +27,8 @@ #include "options.h" +static int use_virtio_blk; + char add_drives (struct drv *drv, char next_drive) { @@ -40,13 +42,17 @@ add_drives (struct drv *drv, char next_drive) exit (EXIT_FAILURE); } +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif + if (drv) { next_drive = add_drives (drv->next, next_drive); free (drv->device); drv->device = NULL; - if (asprintf (&drv->device, "/dev/sd%c", next_drive) == -1) { + if (asprintf (&drv->device, "/dev/%s%c", use_virtio_blk ? "vd" : "sd", next_drive) == -1) { perror ("asprintf"); exit (EXIT_FAILURE); } diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 49341e2..1303a7e 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -318,6 +318,8 @@ struct guestfs_h virDomainPtr dom; /* libvirt domain */ } virt; #endif + + int use_virtio_blk; }; /* Per-filesystem data stored for inspect_os. */ diff --git a/src/handle.c b/src/handle.c index cb00a2e..b0d75c1 100644 --- a/src/handle.c +++ b/src/handle.c @@ -215,6 +215,22 @@ parse_environment (guestfs_h *g, return -1; } +/* + * Currently virtio_scsi is forced if qemu in the host supports this + * feature. This test does however not take the capabilities of the started + * guest into account. As a result no disks will be found if the guest + * kernel is older than 3.4. + */ +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + static const char env_string[] = "GUESTFS_QEMU_NO_VIRTIO_BLK"; + str = getenv(env_string); + g->use_virtio_blk = str == NULL; + if (str) + debug (g, "SuSE: %s in environment, preserving virtio-scsi setting.", env_string); + else + debug (g, "SuSE: %s not in environment, preventing virtio-scsi usage in old guest kernel.", env_string); +#endif + return 0; } diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index 40f797d..45d50ee 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -1370,7 +1370,7 @@ resolve_fstab_device_diskbyid (guestfs_h *g, const char *part, return 0; /* Make the partition name and check it exists. */ - device = safe_asprintf (g, "/dev/sda%s", part); + device = safe_asprintf (g, "/dev/%sa%s", g->use_virtio_blk ? "vd" : "sd", part); if (!is_partition (g, device)) { free (device); return 0; @@ -1447,7 +1447,7 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map) if (disk_i != -1 && disk_i <= 26 && slice_i > 0 && slice_i <= 1 /* > 4 .. see comment above */ && part_i >= 0 && part_i < 26) { - device = safe_asprintf (g, "/dev/sd%c%d", disk_i + 'a', part_i + 5); + device = safe_asprintf (g, "/dev/%s%c%d", g->use_virtio_blk ? "vd" : "sd", disk_i + 'a', part_i + 5); } } else if ((part = match1 (g, spec, re_diskbyid)) != NULL) { diff --git a/src/launch-appliance.c b/src/launch-appliance.c index a86a8cc..1067d17 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -935,6 +935,9 @@ qemu_supports_virtio_scsi (guestfs_h *g) } } + if (g->use_virtio_blk) + g->app.virtio_scsi = 2; + return g->app.virtio_scsi == 1; } diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index 6ad19de..b8efc4f 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -177,6 +177,13 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri) return -1; } +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + if (g->use_virtio_blk) { + error (g, "Using libvirt is not possible with this binary package due to forced virtio-blk usage."); + return -1; + } +#endif + guestfs___launch_send_progress (g, 0); TRACE0 (launch_libvirt_start); diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index d71caed..58cc885 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -95,6 +95,16 @@ main (int argc, char *argv[]) guestfs_h *g; char *qemu = NULL; int qemu_use_wrapper; + char *disk_name, *partition_name; + int use_virtio_blk = 0; + +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif + if (asprintf(&disk_name, "/dev/%s", use_virtio_blk ? "vda" : "sda") < 0) + exit (EXIT_FAILURE); + if (asprintf(&partition_name, "%s1", disk_name) < 0) + exit (EXIT_FAILURE); for (;;) { c = getopt_long (argc, argv, options, long_options, &option_index); @@ -281,19 +291,19 @@ main (int argc, char *argv[]) fflush (stdout); /* Create the filesystem and mount everything. */ - if (guestfs_part_disk (g, "/dev/sda", "mbr") == -1) { + if (guestfs_part_disk (g, disk_name, "mbr") == -1) { fprintf (stderr, _("libguestfs-test-tool: failed to run part-disk\n")); exit (EXIT_FAILURE); } - if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1) { + if (guestfs_mkfs (g, "ext2", partition_name) == -1) { fprintf (stderr, _("libguestfs-test-tool: failed to mkfs.ext2\n")); exit (EXIT_FAILURE); } - if (guestfs_mount (g, "/dev/sda1", "/") == -1) { + if (guestfs_mount (g, partition_name, "/") == -1) { fprintf (stderr, _("libguestfs-test-tool: failed to mount /dev/sda1 on /\n")); exit (EXIT_FAILURE); ++++++ libguestfs.mkinitrd.1110.patch ++++++ --- mkinitrd/scripts/setup-prepare.sh | 94 +++++++++++++++++++++++++++++++------- mkinitrd/scripts/setup-progs.sh | 4 - 2 files changed, 79 insertions(+), 19 deletions(-) Index: 1110/mkinitrd/scripts/setup-prepare.sh =================================================================== --- 1110.orig/mkinitrd/scripts/setup-prepare.sh +++ 1110/mkinitrd/scripts/setup-prepare.sh @@ -13,43 +13,103 @@ #%param_v: "Verbose mode." #%param_L: "Disable logging." #%param_h: "This help screen." # ###### Additional options ## ## Script inclusion may be overriden by ## 1) creating a monster-initrd ## 2) including the wanted module in the configuration option ADDITIONAL_FEATURES in /etc/sysconfig/initrd ## 3) definition using the -f command line switch ## # Install a binary file +# cp_bin file target_filename +# cp_bin file target_directory +# cp_bin file file target_directory +# file is either a regular file or a symlink. symlinks and all paths they point to will be copied +# the "root" of target is $tmp_mnt, which is required to copy symlinks properly cp_bin() { - cp -a "$@" \ - || exit_code=1 - - # Remember the binaries installed. We need the list for checking - # for dynamic libraries. - while [ $# -gt 1 ]; do - initrd_bins[${#initrd_bins[@]}]=$1 - shift - done - # file may print '^setuid ELF ...' - # suid mount will fail if mkinitrd was called as user - if [ -L "$1" ]; then - : do nothing with symlinks - elif [ -d "$1" -o -f "$1" ]; then - find "$1" -type f -print0 | xargs -0 chmod 0755 - fi + local -a files + local target + local target_dirname + local file + + # need at least two parameters, source and destination + if test $# -lt 2 + then + return 0 + fi + # store source filenames + until test $# -eq 1 + do + files=( ${files[@]} $1 ) + shift + done + # store target, either file or directory + target=$1 + # if more than two parameters, last entry must be a directory + if test ${#files[@]} -gt 1 + then + if ! test -d ${target} + then + return 0 + fi + target_dirname=${target} + else + # simplify symlink resolving for sinlge filename + target_dirname=${target%/*} + fi + + for file in ${files[@]} + do + local src dst + src=${file} + dst=${target} + # copy requested soure file as is to requested destination + cp -a -v --remove-destination ${src} ${dst} + # copy symlinks recursivly + while [ 1 ] + do + local tmp_src + if test -L ${src} + then + tmp_src=$(readlink ${src}) + if test "${tmp_src:0:1}" = "/" + then + src=${tmp_src} + else + # relative symlink + src=${src%/*}/${tmp_src} + fi + cp -a -v --remove-destination --parents ${src} $tmp_mnt + # if link target exists, proceed to next symlink target + if test -e "${src}" + then + continue + fi + fi + # exit loop in case of dead symlink or if target of symlink was reached + break + done + # if source file exists, add it to list of binaries + if test -e "${src}" + then + # file may print '^setuid ELF ...' + # suid mount will fail if mkinitrd was called as user + chmod -v 0755 $tmp_mnt/${src} + initrd_bins[${#initrd_bins[@]}]=${src} + fi + done } # check if we should use script or feature $1 use_script() { local condition feature script file # always use when creating monster initrd [ "$create_monster_initrd" ] && return 0 # Normalize to feature name feature="${1##*/}" feature="${feature#*-}" feature="${feature%.sh}" @@ -146,27 +206,27 @@ fi for feature in $ADDITIONAL_FEATURES ; do feature_exists "$feature" || echo "[WARNING] Feature \"$feature\" not found. A typo?" done # create an empty initrd if ! mkdir $tmp_mnt ; then error 1 "could not create temporary directory" fi # fill the initrd cp $INITRD_PATH/bin/linuxrc $linuxrc mkdir "$tmp_mnt/boot" -mkdir -p $tmp_mnt/{sbin,bin,etc,dev,proc,sys,root,config} +mkdir -p $tmp_mnt/{sbin,bin,etc,dev,proc,sys,root,config,usr/bin,usr/sbin} mkdir -p -m 4777 $tmp_mnt/tmp # Create a dummy /etc/mtab for mount/umount echo -n > $tmp_mnt/etc/mtab # Add modprobe, modprobe.conf*, and a version of /bin/true: modprobe.conf # might use it. cp -r $root_dir/etc/modprobe.conf $root_dir/etc/modprobe.conf.local \ $root_dir/etc/modprobe.d $tmp_mnt/etc cat > $tmp_mnt/bin/true <<-EOF #! /bin/sh : Index: 1110/mkinitrd/scripts/setup-progs.sh =================================================================== --- 1110.orig/mkinitrd/scripts/setup-progs.sh +++ 1110/mkinitrd/scripts/setup-progs.sh @@ -28,29 +28,29 @@ for script in $INITRD_PATH/boot/*.sh; do echo "[ \"\$debug\" ] && echo running $file source boot/$file [ \"\$modules\" ] && load_modules" >> run_all.sh [ "$condition" ] && echo "fi" >> run_all.sh # and all programs it needs for files in $(cat $script | grep '%programs: ' | sed 's/^#%programs: \(.*\)$/\1/'); do for file in $(eval echo $files); do if [ "${file:0:17}" = "/lib/mkinitrd/bin" ]; then SOURCE=$file DEST="./bin/" elif [ "${file:0:1}" = "/" ]; then # absolute path files have to stay alive SOURCE=$file [ ! -e $file -a -e /usr$file ] && SOURCE="/usr$file" - DEST=".$file" + DEST=".$SOURCE" else SOURCE=$(which "$file") - DEST="./bin/" + DEST=".$SOURCE" fi cp_bin "$SOURCE" "$DEST" done done fi done echo -ne "Features: " echo $features [ -e "bin/sh" ] || ln -s /bin/bash bin/sh ++++++ libguestfs.mkinitrd.1210.patch ++++++ --- mkinitrd/scripts/setup-prepare.sh | 90 +++++++++++++++++++++++++++++++------- mkinitrd/scripts/setup-progs.sh | 17 +------ 2 files changed, 78 insertions(+), 29 deletions(-) Index: 1210/mkinitrd/scripts/setup-prepare.sh =================================================================== --- 1210.orig/mkinitrd/scripts/setup-prepare.sh +++ 1210/mkinitrd/scripts/setup-prepare.sh @@ -13,43 +13,103 @@ #%param_R: "Print release (version)." #%param_L: "Disable logging." #%param_h: "This help screen." # ###### Additional options ## ## Script inclusion may be overriden by ## 1) creating a monster-initrd ## 2) including the wanted module in the configuration option ADDITIONAL_FEATURES in /etc/sysconfig/initrd ## 3) definition using the -f command line switch ## # Install a binary file +# cp_bin file target_filename +# cp_bin file target_directory +# cp_bin file file target_directory +# file is either a regular file or a symlink. symlinks and all paths they point to will be copied +# the "root" of target is $tmp_mnt, which is required to copy symlinks properly cp_bin() { - cp -a "$@" \ - || exit_code=1 + local -a files + local target + local target_dirname + local file - # Remember the binaries installed. We need the list for checking - # for dynamic libraries. - while [ $# -gt 1 ]; do - initrd_bins[${#initrd_bins[@]}]=$1 - shift - done - # file may print '^setuid ELF ...' - # suid mount will fail if mkinitrd was called as user - if [ -L "$1" ]; then - : do nothing with symlinks - elif [ -d "$1" -o -f "$1" ]; then - find "$1" -type f -print0 | xargs -0 chmod 0755 - fi + # need at least two parameters, source and destination + if test $# -lt 2 + then + return 0 + fi + # store source filenames + until test $# -eq 1 + do + files=( ${files[@]} $1 ) + shift + done + # store target, either file or directory + target=$1 + # if more than two parameters, last entry must be a directory + if test ${#files[@]} -gt 1 + then + if ! test -d ${target} + then + return 0 + fi + target_dirname=${target} + else + # simplify symlink resolving for sinlge filename + target_dirname=${target%/*} + fi + + for file in ${files[@]} + do + local src dst + src=${file} + dst=${target} + # copy requested soure file as is to requested destination + cp -a -v --remove-destination ${src} ${dst} + # copy symlinks recursivly + while [ 1 ] + do + local tmp_src + if test -L ${src} + then + tmp_src=$(readlink ${src}) + if test "${tmp_src:0:1}" = "/" + then + src=${tmp_src} + else + # relative symlink + src=${src%/*}/${tmp_src} + fi + cp -a -v --remove-destination --parents ${src} $tmp_mnt + # if link target exists, proceed to next symlink target + if test -e "${src}" + then + continue + fi + fi + # exit loop in case of dead symlink or if target of symlink was reached + break + done + # if source file exists, add it to list of binaries + if test -e "${src}" + then + # file may print '^setuid ELF ...' + # suid mount will fail if mkinitrd was called as user + chmod -v 0755 $tmp_mnt/${src} + initrd_bins[${#initrd_bins[@]}]=${src} + fi + done } # check if we should use script or feature $1 use_script() { local condition feature script file # always use when creating monster initrd [ "$create_monster_initrd" ] && return 0 # Normalize to feature name feature="${1##*/}" feature="${feature#*-}" feature="${feature%.sh}" Index: 1210/mkinitrd/scripts/setup-progs.sh =================================================================== --- 1210.orig/mkinitrd/scripts/setup-progs.sh +++ 1210/mkinitrd/scripts/setup-progs.sh @@ -24,48 +24,37 @@ for script in $INITRD_PATH/boot/*.sh; do condition="$(sed -rn 's/^#[[:blank:]]*%if:[[:blank:]]*(.*)$/if [ \1 ]; then/p' < "$script")" echo "$condition" >> run_all.sh # -- remember dependent modules sed -rn 's/^#[[:blank:]]*%modules:[[:blank:]]*(.*)$/modules="\1"/p' < $script >> run_all.sh echo "[ \"\$debug\" ] && echo running $file source boot/$file [ \"\$modules\" ] && load_modules" >> run_all.sh [ "$condition" ] && echo "fi" >> run_all.sh # and all programs it needs for files in $(sed -rn 's/^#[[:blank:]]*%programs:[[:blank:]]*(.*)$/\1/p' < "$script"); do for file in $(eval echo $files); do if [ "${file:0:17}" = "/lib/mkinitrd/bin" ]; then SOURCE=$file - DEST="./bin/" + DEST="${tmp_mnt}/bin/" elif [ "${file:0:1}" = "/" ]; then # absolute path files have to stay alive SOURCE=$file [ ! -e $file -a -e /usr$file ] && SOURCE="/usr$file" - DEST=".$file" + DEST="${tmp_mnt}$SOURCE" else case "$(type -t "$file")" in builtin) continue esac SOURCE=$(type -p "$file") - DEST="./bin/" + DEST="${tmp_mnt}$SOURCE" fi cp_bin "$SOURCE" "$DEST" - - # if we're given a symlink, always copy the linked file too - if [ -L "$SOURCE" ]; then - LINK=$(readlink -e "$SOURCE") - if [ -e "$LINK" ]; then - mkdir -p .$(dirname "$LINK") - cp_bin "$LINK" ."$LINK" - else - echo 2>&1 "WARNING: $LINK is a dangling symlink" - fi - fi done done fi done echo -ne "Features: " echo $features [ -e "bin/sh" ] || ln -s /bin/bash bin/sh ++++++ libguestfs.mkinitrd.1220.patch ++++++ --- mkinitrd/scripts/setup-prepare.sh | 126 ++++++++++++++++++++++---------------- mkinitrd/scripts/setup-progs.sh | 17 ----- 2 files changed, 79 insertions(+), 64 deletions(-) Index: 1220/mkinitrd/scripts/setup-prepare.sh =================================================================== --- 1220.orig/mkinitrd/scripts/setup-prepare.sh +++ 1220/mkinitrd/scripts/setup-prepare.sh @@ -13,77 +13,103 @@ #%param_R: "Print release (version)." #%param_L: "Disable logging." #%param_h: "This help screen." # ###### Additional options ## ## Script inclusion may be overriden by ## 1) creating a monster-initrd ## 2) including the wanted module in the configuration option ADDITIONAL_FEATURES in /etc/sysconfig/initrd ## 3) definition using the -f command line switch ## # Install a binary file -cp_link() { - # Copy the target of the given link $1 to the destination $2 - # spaces and special characters in file names will break things - if [ -h "$1" ]; then - lnkTarget=$(readlink $1) - if [ -e $lnkTarget ];then - cp -a $lnkTarget $2/$lnkTarget - else - # This link points to something in the same directory - lnkSrc="$1" - # Get the base bath of the link origin - lnkSrcBase=${lnkSrc%/*} - cp -a $lnkSrcBase/$lnkTarget $2/$lnkSrcBase/$lnkTarget - fi - return 1 - fi - return 0 -} - +# cp_bin file target_filename +# cp_bin file target_directory +# cp_bin file file target_directory +# file is either a regular file or a symlink. symlinks and all paths they point to will be copied +# the "root" of target is $tmp_mnt, which is required to copy symlinks properly cp_bin() { - cp -a "$@" \ - || exit_code=1 - - if [ -h "$1" ]; then - lnkTarget=$1 - # Determine the base bath of the target - targetPath="$2" - targetBase=${targetPath%$1*} - while [ 1 ]; do - cp_link $lnkTarget $targetBase - lnkCopied=$? - if [ $lnkCopied = 0 ]; then - if [ -e $lnkTarget ]; then - initrd_bins[${#initrd_bins[@]}]=$lnkTarget - fi - break - fi - done - else - # Remember the binaries installed. We need the list for checking - # for dynamic libraries. - while [ $# -gt 1 ]; do - initrd_bins[${#initrd_bins[@]}]=$1 - shift - done - # file may print '^setuid ELF ...' - # suid mount will fail if mkinitrd was called as user - if [ -d "$1" -o -f "$1" ]; then - find "$1" -type f -print0 | xargs -0 chmod 0755 - fi - fi + local -a files + local target + local target_dirname + local file + + # need at least two parameters, source and destination + if test $# -lt 2 + then + return 0 + fi + # store source filenames + until test $# -eq 1 + do + files=( ${files[@]} $1 ) + shift + done + # store target, either file or directory + target=$1 + # if more than two parameters, last entry must be a directory + if test ${#files[@]} -gt 1 + then + if ! test -d ${target} + then + return 0 + fi + target_dirname=${target} + else + # simplify symlink resolving for sinlge filename + target_dirname=${target%/*} + fi + + for file in ${files[@]} + do + local src dst + src=${file} + dst=${target} + # copy requested soure file as is to requested destination + cp -a -v --remove-destination ${src} ${dst} + # copy symlinks recursivly + while [ 1 ] + do + local tmp_src + if test -L ${src} + then + tmp_src=$(readlink ${src}) + if test "${tmp_src:0:1}" = "/" + then + src=${tmp_src} + else + # relative symlink + src=${src%/*}/${tmp_src} + fi + cp -a -v --remove-destination --parents ${src} $tmp_mnt + # if link target exists, proceed to next symlink target + if test -e "${src}" + then + continue + fi + fi + # exit loop in case of dead symlink or if target of symlink was reached + break + done + # if source file exists, add it to list of binaries + if test -e "${src}" + then + # file may print '^setuid ELF ...' + # suid mount will fail if mkinitrd was called as user + chmod -v 0755 $tmp_mnt/${src} + initrd_bins[${#initrd_bins[@]}]=${src} + fi + done } # check if we should use script or feature $1 use_script() { local condition feature script file # always use when creating monster initrd [ "$create_monster_initrd" ] && return 0 # Normalize to feature name feature="${1##*/}" feature="${feature#*-}" feature="${feature%.sh}" Index: 1220/mkinitrd/scripts/setup-progs.sh =================================================================== --- 1220.orig/mkinitrd/scripts/setup-progs.sh +++ 1220/mkinitrd/scripts/setup-progs.sh @@ -24,48 +24,37 @@ for script in $INITRD_PATH/boot/*.sh; do condition="$(sed -rn 's/^#[[:blank:]]*%if:[[:blank:]]*(.*)$/if [ \1 ]; then/p' < "$script")" echo "$condition" >> run_all.sh # -- remember dependent modules sed -rn 's/^#[[:blank:]]*%modules:[[:blank:]]*(.*)$/modules="\1"/p' < $script >> run_all.sh echo "[ \"\$debug\" ] && echo running $file source boot/$file [ \"\$modules\" ] && load_modules" >> run_all.sh [ "$condition" ] && echo "fi" >> run_all.sh # and all programs it needs for files in $(sed -rn 's/^#[[:blank:]]*%programs:[[:blank:]]*(.*)$/\1/p' < "$script"); do for file in $(eval echo $files); do if [ "${file:0:17}" = "/lib/mkinitrd/bin" ]; then SOURCE=$file - DEST="./bin/" + DEST="${tmp_mnt}/bin/" elif [ "${file:0:1}" = "/" ]; then # absolute path files have to stay alive SOURCE=$file [ ! -e $file -a -e /usr$file ] && SOURCE="/usr$file" - DEST=".$file" + DEST="${tmp_mnt}$SOURCE" else case "$(type -t "$file")" in builtin) continue esac SOURCE=$(type -p "$file") - DEST="./bin/" + DEST="${tmp_mnt}$SOURCE" fi cp_bin "$SOURCE" "$DEST" - - # if we're given a symlink, always copy the linked file too - if [ -L "$SOURCE" ]; then - LINK=$(readlink -e "$SOURCE") - if [ -e "$LINK" ]; then - mkdir -p .$(dirname "$LINK") - cp_bin "$LINK" ."$LINK" - else - echo 2>&1 "WARNING: $LINK is a dangling symlink" - fi - fi done done fi done echo -ne "Features: " echo $features [ -e "bin/sh" ] || ln -s /bin/bash bin/sh ++++++ libguestfs.mkinitrd.boot.sh ++++++ #!/bin/bash #%stage: block # #%modules: dm-mod # #%udevmodules: virtio_blk #%udevmodules: virtio_console #%udevmodules: virtio_net #%udevmodules: virtio_pci #%udevmodules: virtio_scsi #%udevmodules: sg #%udevmodules: sd_mod #%udevmodules: sr_mod #%udevmodules: #%udevmodules: loop #%udevmodules: #%udevmodules: 9p #%udevmodules: btrfs #%udevmodules: cramfs #%udevmodules: ext2 #%udevmodules: ext3 #%udevmodules: ext4 #%udevmodules: fat #%udevmodules: fuse #%udevmodules: hfs #%udevmodules: hfsplus #%udevmodules: jfs #%udevmodules: minix #%udevmodules: nfs #%udevmodules: quota #%udevmodules: reiserfs #%udevmodules: squashfs #%udevmodules: squashfs3 #%udevmodules: udf #%udevmodules: ufs #%udevmodules: xfs #%udevmodules: #%udevmodules: nls_ascii #%udevmodules: nls_cp1250 #%udevmodules: nls_cp1251 #%udevmodules: nls_cp1255 #%udevmodules: nls_cp437 #%udevmodules: nls_cp737 #%udevmodules: nls_cp775 #%udevmodules: nls_cp850 #%udevmodules: nls_cp852 #%udevmodules: nls_cp855 #%udevmodules: nls_cp857 #%udevmodules: nls_cp860 #%udevmodules: nls_cp861 #%udevmodules: nls_cp862 #%udevmodules: nls_cp863 #%udevmodules: nls_cp864 #%udevmodules: nls_cp865 #%udevmodules: nls_cp866 #%udevmodules: nls_cp869 #%udevmodules: nls_cp874 #%udevmodules: nls_cp932 #%udevmodules: nls_cp936 #%udevmodules: nls_cp949 #%udevmodules: nls_cp950 #%udevmodules: nls_euc-jp #%udevmodules: nls_iso8859-1 #%udevmodules: nls_iso8859-13 #%udevmodules: nls_iso8859-14 #%udevmodules: nls_iso8859-15 #%udevmodules: nls_iso8859-2 #%udevmodules: nls_iso8859-3 #%udevmodules: nls_iso8859-4 #%udevmodules: nls_iso8859-5 #%udevmodules: nls_iso8859-6 #%udevmodules: nls_iso8859-7 #%udevmodules: nls_iso8859-9 #%udevmodules: nls_koi8-r #%udevmodules: nls_koi8-ru #%udevmodules: nls_koi8ru #%udevmodules: nls_utf8 # #%programs: mdadm #%programs: modprobe #%programs: lvm #%programs: grep #%programs: ls #%programs: head #%programs: cat #%programs: ip #%programs: date #%programs: valgrind #%programs: find #%programs: xargs #%programs: setctsid # mount-rootfs-and-do-chroot.sh #%programs: mkdir #%programs: stat #%programs: mount #%programs: chroot #%programs: umount # # Generated at build time: #@GUESTFS_EXT_CMDS@ # missing_commands="@GUESTFS_MISSING_CMDS@" # Make the modules available now # run_all.sh will load them after this script is sourced load_modules # from libguestfs-1.19.34/appliance/init: # Scan for MDs. mdadm -As --auto=yes --run # Scan for LVM. mkdir -p /etc/lvm echo -n >> /etc/lvm/lvm.conf lvm vgscan --ignorelockingfailure lvm vgchange -ay --ignorelockingfailure # Improve virtio-blk performance (RHBZ#509383). for f in /sys/block/vd*/queue/rotational; do if test -f $f ; then echo 1 > $f; fi ; done # These are useful when debugging. if grep -sq guestfs_verbose=1 /proc/cmdline; then ls -lR /dev head -n 1234 \ /proc/mounts \ /proc/modules \ /proc/cpuinfo \ /proc/uptime \ /proc/version \ /proc/partitions lvm pvs lvm vgs lvm lvs # ip a # ip r date echo "These commands might be called by guestfsd, but they were not available at buildtime:" echo "missing commands: $missing_commands" echo fi if ! grep -sq guestfs_rescue=1 /proc/cmdline; then # Run the daemon under valgrind if ./configure --enable-valgrind-daemon vg_channel=/dev/virtio-ports/org.libguestfs.valgrind if [ -w $vg_channel ]; then if [ -r /etc/guestfsd.suppressions ]; then suppressions="--suppressions=/etc/guestfsd.suppressions" fi exec 3>$vg_channel vg="valgrind --leak-check=full --log-fd=3 --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes $suppressions" echo "enabling valgrind: $vg" fi # The host will kill qemu abruptly if guestfsd shuts down normally $vg guestfsd # Otherwise we try to clean up gracefully. For example, this ensures that a # core dump generated by the guest daemon will be written to disk. else # Use appliance in rescue mode, also used by the virt-rescue command. eval $(grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline) PS1='><rescue> ' console_kname=ttyS0 if test -f /proc/consoles then console_major_minor="`sed 's@^.* @@;p;Q' < /proc/consoles `" console_dev="`find /sys/ -name dev -type f -print0 | xargs -0 --no-run-if-empty grep -m 1 -l ${console_major_minor}`" console_kname=${console_dev%/dev} console_kname=${console_kname##*/} fi export TERM PS1 echo echo "------------------------------------------------------------" echo echo "Welcome to virt-rescue, the libguestfs rescue shell." echo echo "Note: The contents of / are the rescue appliance." echo "You have to mount the guest's partitions under /sysroot" echo "before you can examine them. A helper script for that exists:" echo "mount-rootfs-and-do-chroot.sh /dev/sda2" echo setctsid "/dev/${console_kname}" bash -i echo echo "virt-rescue: Syncing the disk now before exiting ..." echo fi echo "Leaving." echo s > /proc/sysrq-trigger echo b > /proc/sysrq-trigger exit 0 ++++++ libguestfs.mkinitrd.setup.sh ++++++ #!/bin/bash #%stage: block # # copy daemon manually because it is located in RPM_BUILD_ROOT mkdir -vp $tmp_mnt/usr/sbin cp_bin $(type -p guestfsd) $tmp_mnt/usr/sbin # many guestfish commands need a mount point # in guestfsd the mount point defaults to /sysroot mkdir -vp $tmp_mnt/sysroot # guestfsd tries to bind mount this directory mkdir -vp $tmp_mnt/selinux for f in /etc/magic /usr/share/misc/magic* do if test -e $f then cp -av --parents $f $tmp_mnt/ fi done for d in /usr/share/*augeas* do if test -e $d then cp -av --parents $d $tmp_mnt/ fi done for t in \ screen \ vt100 \ vt102 \ linux do ti="`echo /usr/share/terminfo/*/${t}`" for f in $ti do if test -f "${f}" then cp -av --parents $f $tmp_mnt fi done done # Bug 674684 - mount-rootfs-and-do-chroot.sh cat > $tmp_mnt/bin/mount-rootfs-and-do-chroot.sh <<'__EOF__' #!/bin/bash # Usage: $0 /dev/sda5 rootfs=$1 mnt=/sysroot mounts= if test -b "${rootfs}" then mkdir -v -p "${mnt}" if mount -v "${rootfs}" "${mnt}" then for i in dev proc sys selinux do if test -d /${i} && test -d "${mnt}/${i}" && test "`stat -c %D /`" != "`stat -c %D ${i}`" then mount -v --bind /${i} "${mnt}/${i}" fi done chroot "${mnt}" su - while read b m rest do case "${m}" in ${mnt}*) mounts="${m} ${mounts}" ;; esac done <<-EOF ` cat < /proc/mounts ` EOF for i in ${mounts} do umount -v "${i}" done fi fi __EOF__ -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org