From 99c908705839c1d778e15dc69c46d36b6738f1a4377f14a1dfb1d40f23dc7a3d Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 09:46:40 +0000 Subject: [PATCH 1/8] - Update to version 1.24.5 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=257 --- libguestfs.changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguestfs.changes b/libguestfs.changes index 133d0fb..2b6da98 100644 --- a/libguestfs.changes +++ b/libguestfs.changes @@ -1,7 +1,7 @@ ------------------------------------------------------------------- Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de -- Update to version 1.24.4 +- Update to version 1.24.5 * launch: Allow backend = "appliance" for backwards compatibility (RHBZ#1055452). * daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option. * init: Display clocksource (only when debugging is enabled). From 898c43d60f56d8f06eeefacea493820fac9cbc313385777be128e7f613f536bd Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 10:15:09 +0000 Subject: [PATCH 2/8] - add libguestfs-test subpackage, /usr/share/guestfs (fate#316275) libguestfs.test.simple.run-libugestfs-test-tool.sh libguestfs.test.simple.create-opensuse-guest.sh OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=258 --- libguestfs.changes | 7 + libguestfs.spec | 22 ++ ...estfs.test.simple.create-opensuse-guest.sh | 229 ++++++++++++++++++ ...fs.test.simple.run-libugestfs-test-tool.sh | 26 ++ 4 files changed, 284 insertions(+) create mode 100644 libguestfs.test.simple.create-opensuse-guest.sh create mode 100644 libguestfs.test.simple.run-libugestfs-test-tool.sh diff --git a/libguestfs.changes b/libguestfs.changes index 2b6da98..2277cc3 100644 --- a/libguestfs.changes +++ b/libguestfs.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 22 10:13:00 UTC 2014 - ohering@suse.com + +- add libguestfs-test subpackage, /usr/share/guestfs (fate#316275) + libguestfs.test.simple.run-libugestfs-test-tool.sh + libguestfs.test.simple.create-opensuse-guest.sh + ------------------------------------------------------------------- Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de diff --git a/libguestfs.spec b/libguestfs.spec index b58e3a3..ca140ae 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -160,6 +160,10 @@ Source11: libguestfs.mkinitrd.setup.sh Source1220: libguestfs.mkinitrd.1220.patch Source1210: libguestfs.mkinitrd.1210.patch Source1110: libguestfs.mkinitrd.1110.patch +# +Source10001: libguestfs.test.simple.run-libugestfs-test-tool.sh +Source10002: libguestfs.test.simple.create-opensuse-guest.sh +# Requires: guestfs-tools %description @@ -327,6 +331,14 @@ BuildRequires: rubygem-rake Allows Ruby scripts to directly use libguestfs. %endif +%package test +Summary: Testcases for libguestfs +License: GPL-2.0 +Group: System/Filesystems + +%description test +This package contains testcases to verify libguestfs functionality. + %package -n guestfs-data # kernel-default needs that %if %{?sles_version}0 > 0 @@ -520,6 +532,12 @@ export NO_BRP_STRIP_DEBUG=true %endif %makeinstall udevrulesdir=%{udevrulesdir} rm -rfv $RPM_BUILD_ROOT%{_libdir}/guestfs/supermin.d +# +mkdir -p $RPM_BUILD_ROOT%{_datadir}/guestfs +cp -avLt $RPM_BUILD_ROOT%{_datadir}/guestfs \ + %{S:10002} \ + %{S:10001} +chmod 0755 $RPM_BUILD_ROOT%{_datadir}/guestfs/* #remove ocaml bindings files if they are disable via rpm macro %if !%{with ocaml_bindings} rm -rfv $RPM_BUILD_ROOT%{_libdir}/ocaml @@ -704,6 +722,10 @@ rm -rf $RPM_BUILD_ROOT %post -n libguestfs0 -p /sbin/ldconfig %postun -n libguestfs0 -p /sbin/ldconfig +%files test +%defattr(-,root,root) +%{_datadir}/guestfs + %files -n guestfs-data %defattr(-,root,root) %{_libdir}/guestfs diff --git a/libguestfs.test.simple.create-opensuse-guest.sh b/libguestfs.test.simple.create-opensuse-guest.sh new file mode 100644 index 0000000..90c2e2c --- /dev/null +++ b/libguestfs.test.simple.create-opensuse-guest.sh @@ -0,0 +1,229 @@ +#!/bin/bash +# Create an openSUSE image with just enough packages to allow boot to login prompt +# +# Theory of operation: +# This script uses zypper from the host to resolve dependencies +# for zypper which runs within the appliance. If zypper on the host +# is too old, it will be unable to handle repo data from 13.1: +# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html +# "[zypp-devel] Package conflicting with itself" +# For this reason zypper from 12.3 can be used to install the pattern +# of the final repo. +# First the dependencies of zypper are resolved, the required packages +# are downloaded and extracted with unrpm. Now the guest is started and +# the partitions in the diskimage are prepared. Then the extracted +# package content is copied into the guest. Once that is done zypper +# inside the guest will install the base pattern and a few extra packages. +# Finally the bootloader grub is configured. Once all that is done +# kvm is started. If all goes well a login prompt appears. +# The password for root is "root". +# The guest has also network access to the outside. +# +# Expected runtime: ca. 120 seconds +# +# Expected output: +# guest should start +# no "obvious" errors should be shown during the disk operation +# at the end kvm is started with the generated disk image +# login should be possible +# +set -e +unset LANG +unset ${!LC_*} +cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1` + +output_diskimage=/dev/shm/$LOGNAME/testcase.img +final_repo=http://download.opensuse.org/distribution/12.3/repo/oss/ +initial_repo=http://download.opensuse.org/distribution/13.1/repo/oss/ +force=false +guest_zypper_in__pattern_name="base" +guest_zypper_in__package_list="less vim grub master-boot-code parted nfs-utils" +guest_root_password="root" +diskname_inside_vm=/dev/sda + +_exit() { + echo "Exiting '$0 $*'." + exit 1 +} +until test $# -lt 1 +do + case "$1" in + -n) diskname_inside_vm="$2" ; shift ;; + -o) output_diskimage="$2" ; shift ;; + -R) initial_repo="$2" ; shift ;; + -r) final_repo="$2" ; shift ;; + -f) force=true ;; + -x) set -x ;; + *) echo "Unknown option '$1'" exit 1 ;; + esac + shift +done +if test -z "${initial_repo}" +then + echo "URL to initial repo required. Wrong -R option." + _exit +fi +if test -z "${final_repo}" +then + echo "URL to final repo required. Wrong -r option." + _exit +fi +if test -z "${output_diskimage}" +then + echo "Filename for temporary disk image required. Wrong -o option." + _exit +fi +if test -e "${output_diskimage}" +then + if test "${force}" = "false" + then + echo "Output diskimage '${output_diskimage}' exists." + echo "It will not be overwritten. Option '-f' exists to force overwrite." + _exit + fi +fi +mkdir -vp "${output_diskimage%/*}" +td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}` +tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}` +_exit() { +rm -rf "$tf" +rm -rf "$td" +} +trap _exit EXIT +dir_repo=${td}/repos.d +dir_root=${td}/root +dir_cache=${td}/cache +mkdir -vp \ + ${dir_root} \ + ${dir_cache} \ + ${dir_repo} +cat > ${tf} < ${dir_repo}/tmp.repo <> etc/resolv.conf +echo nameserver 169.254.2.3 >> etc/resolv.conf +grep -w root /etc/passwd > etc/passwd +grep -w root /etc/group > etc/group +echo 'root::15209::::::' > etc/shadow +cat > etc/fstab < etc/grub.conf < boot/grub/device.map +cat > boot/grub/menu.lst <&1 " : \ +sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \ +sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \ +sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/grub /usr/lib/grub/*" : \ +sh "grub --batch --verbose < /etc/grub.conf" : \ +sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \ +sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \ +sh "echo 'Password for root is ${guest_root_password}' >> /etc/issue" : \ +cat /etc/fstab : \ +quit +ls -lhsS "${output_diskimage}" + +qemu-kvm \ + -global virtio-blk-pci.scsi=off \ + -enable-fips \ + -machine accel=kvm:tcg \ + -cpu host,+kvmclock \ + -m 500 \ + -no-reboot \ + -no-hpet \ + -drive file=${output_diskimage},cache=writeback,id=hd0,if=none \ + -device virtio-blk-pci,drive=hd0 \ + -device virtio-serial-pci \ + -serial stdio \ + -device sga \ + -netdev user,id=usernet,net=169.254.0.0/16 \ + -device virtio-net-pci,netdev=usernet + +exit 0 diff --git a/libguestfs.test.simple.run-libugestfs-test-tool.sh b/libguestfs.test.simple.run-libugestfs-test-tool.sh new file mode 100644 index 0000000..2c37ea4 --- /dev/null +++ b/libguestfs.test.simple.run-libugestfs-test-tool.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# libguestfs-test-tool starts its temporary guest using a dummy disk image +# It creates a partition, a filesystem, mounts it and touches a file +# Once it is done the dummy image is removed again +# Per default it runs in --verbose mode, and our version trace the API calls +# +# Expected runtime: ca. 10 seconds +# +# Expected output: +# guest should start +# no "obvious" errors should be shown during the disk operation +# Somewhere at the end of the verbose output lines like this are expected: +# ... +# libguestfs: trace: touch "/hello" +# ... +# libguestfs: trace: touch = 0 +# +# +set -x +set -e +unset LANG +unset ${!LC_*} +cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1` + +libguestfs-test-tool -V +time libguestfs-test-tool From 7792574f1eddd9a80b231a4ccefb3a7ccaf40abd223f9e7d6f46f6d5aa7be7d6 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 11:32:55 +0000 Subject: [PATCH 3/8] fix libguestfs.test.simple.create-opensuse-guest.sh OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=259 --- ...estfs.test.simple.create-opensuse-guest.sh | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/libguestfs.test.simple.create-opensuse-guest.sh b/libguestfs.test.simple.create-opensuse-guest.sh index 90c2e2c..5213e5d 100644 --- a/libguestfs.test.simple.create-opensuse-guest.sh +++ b/libguestfs.test.simple.create-opensuse-guest.sh @@ -33,28 +33,44 @@ unset ${!LC_*} cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1` output_diskimage=/dev/shm/$LOGNAME/testcase.img -final_repo=http://download.opensuse.org/distribution/12.3/repo/oss/ -initial_repo=http://download.opensuse.org/distribution/13.1/repo/oss/ +final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/ +initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/ force=false guest_zypper_in__pattern_name="base" guest_zypper_in__package_list="less vim grub master-boot-code parted nfs-utils" guest_root_password="root" diskname_inside_vm=/dev/sda +case "$0" in + /*) progname="$0" ;; + *) progname="$PWD/$0" ;; +esac + _exit() { echo "Exiting '$0 $*'." exit 1 } + +_unrpm() { + CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories" + FILES="$@" + for f in $FILES; do + echo -ne "$f:\t" + rpm2cpio $f | cpio ${CPIO_OPTS} + done +} + until test $# -lt 1 do case "$1" in + --unrpm) shift ; _unrpm "$@" ; exit 0 ;; -n) diskname_inside_vm="$2" ; shift ;; -o) output_diskimage="$2" ; shift ;; -R) initial_repo="$2" ; shift ;; -r) final_repo="$2" ; shift ;; -f) force=true ;; -x) set -x ;; - *) echo "Unknown option '$1'" exit 1 ;; + *) echo "Unknown option '$1'" ; exit 1 ;; esac shift done @@ -82,6 +98,11 @@ then _exit fi fi +zypper --version +cpio --version +guestfish --version +qemu-system-`uname -m` --version + mkdir -vp "${output_diskimage%/*}" td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}` tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}` @@ -142,7 +163,7 @@ zypper \ --download-only \ ${packages} cd ${dir_root} -find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} unrpm +find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm mkdir -vp etc/zypp/repos.d grep -w search /etc/resolv.conf >> etc/resolv.conf echo nameserver 169.254.2.3 >> etc/resolv.conf @@ -205,12 +226,31 @@ sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/gr sh "grub --batch --verbose < /etc/grub.conf" : \ sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \ sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \ -sh "echo 'Password for root is ${guest_root_password}' >> /etc/issue" : \ +sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \ cat /etc/fstab : \ quit ls -lhsS "${output_diskimage}" -qemu-kvm \ +: ${diskname_inside_vm} +case "${diskname_inside_vm}" in + *vda*) + qemu_drive_options=" + -drive file=${output_diskimage},cache=writeback,id=hd0,if=none \ + -device virtio-blk-pci,drive=hd0 \ + " + ;; + *sda*) + qemu_drive_options=" + -device virtio-scsi-pci,id=scsi \ + -drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \ + -device scsi-hd,drive=hd0 \ + " + ;; + *) + echo "${diskname_inside_vm} not handled" + _exit +esac +qemu-system-`uname -m` -enable-kvm \ -global virtio-blk-pci.scsi=off \ -enable-fips \ -machine accel=kvm:tcg \ @@ -218,8 +258,7 @@ qemu-kvm \ -m 500 \ -no-reboot \ -no-hpet \ - -drive file=${output_diskimage},cache=writeback,id=hd0,if=none \ - -device virtio-blk-pci,drive=hd0 \ + ${qemu_drive_options} \ -device virtio-serial-pci \ -serial stdio \ -device sga \ From a630773766aff0e507b15396297755b9835ebfc4813a8fc972c0d0b3dc3e5cfd Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 11:46:30 +0000 Subject: [PATCH 4/8] Update kvm handling for sles11sp3 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=260 --- libguestfs.test.simple.create-opensuse-guest.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libguestfs.test.simple.create-opensuse-guest.sh b/libguestfs.test.simple.create-opensuse-guest.sh index 5213e5d..628b1a8 100644 --- a/libguestfs.test.simple.create-opensuse-guest.sh +++ b/libguestfs.test.simple.create-opensuse-guest.sh @@ -101,7 +101,20 @@ fi zypper --version cpio --version guestfish --version -qemu-system-`uname -m` --version +kvm="qemu-system-`uname -m`" +if $kvm --version +then + : good +else + kvm="qemu-kvm" + if $kvm --version + then + : + else + echo "No qemu-kvm found." + _exit + fi +fi mkdir -vp "${output_diskimage%/*}" td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}` @@ -250,7 +263,7 @@ case "${diskname_inside_vm}" in echo "${diskname_inside_vm} not handled" _exit esac -qemu-system-`uname -m` -enable-kvm \ +$kvm -enable-kvm \ -global virtio-blk-pci.scsi=off \ -enable-fips \ -machine accel=kvm:tcg \ From 940e40701316c5cb536c57703226602f6d0ea3024cc3452ea48dc3b8704aed3e Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Wed, 22 Jan 2014 12:53:05 +0000 Subject: [PATCH 5/8] Updating link to change in openSUSE:Factory/libguestfs revision 12.0 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=4db1bc592423dc794ba2bad43e814521 --- libguestfs.changes | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libguestfs.changes b/libguestfs.changes index 2277cc3..561c543 100644 --- a/libguestfs.changes +++ b/libguestfs.changes @@ -8,6 +8,18 @@ Wed Jan 22 10:13:00 UTC 2014 - ohering@suse.com ------------------------------------------------------------------- Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de +- Update to version 1.24.4 + * launch: Allow backend = "appliance" for backwards compatibility (RHBZ#1055452). + * daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option. + * init: Display clocksource (only when debugging is enabled). + * launch: direct: Make sure we pass lpj= parameter when using TCG. + * Use recommended timer settings for KVM (RHBZ#1053847). + * fuse: clear stat structs (RHBZ#660687). + * fuse: remove extra trailing \n in debug messages + +------------------------------------------------------------------- +Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de + - Update to version 1.24.5 * launch: Allow backend = "appliance" for backwards compatibility (RHBZ#1055452). * daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option. From 0b13391d24d13784a928e93bdb96e56ee44f94c2ec0dcdec296be529dda76cc9 Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Wed, 22 Jan 2014 12:53:06 +0000 Subject: [PATCH 6/8] Accepting request 214552 from Virtualization baserev update by copy to link target OBS-URL: https://build.opensuse.org/request/show/214552 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=261 --- libguestfs.changes | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libguestfs.changes b/libguestfs.changes index 561c543..2277cc3 100644 --- a/libguestfs.changes +++ b/libguestfs.changes @@ -8,18 +8,6 @@ Wed Jan 22 10:13:00 UTC 2014 - ohering@suse.com ------------------------------------------------------------------- Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de -- Update to version 1.24.4 - * launch: Allow backend = "appliance" for backwards compatibility (RHBZ#1055452). - * daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option. - * init: Display clocksource (only when debugging is enabled). - * launch: direct: Make sure we pass lpj= parameter when using TCG. - * Use recommended timer settings for KVM (RHBZ#1053847). - * fuse: clear stat structs (RHBZ#660687). - * fuse: remove extra trailing \n in debug messages - -------------------------------------------------------------------- -Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de - - Update to version 1.24.5 * launch: Allow backend = "appliance" for backwards compatibility (RHBZ#1055452). * daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option. From 2e1800ed22706e485171cb059a850430ca549faf0f0ed31f438600c5e09a57b2 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 16:38:31 +0000 Subject: [PATCH 7/8] libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=262 --- libguestfs.changes | 1 + ...mple.create-opensuse-guest-crypt-on-lvm.sh | 333 ++++++++++++++++++ ...estfs.test.simple.create-opensuse-guest.sh | 13 +- 3 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh diff --git a/libguestfs.changes b/libguestfs.changes index 2277cc3..77a53d7 100644 --- a/libguestfs.changes +++ b/libguestfs.changes @@ -4,6 +4,7 @@ Wed Jan 22 10:13:00 UTC 2014 - ohering@suse.com - add libguestfs-test subpackage, /usr/share/guestfs (fate#316275) libguestfs.test.simple.run-libugestfs-test-tool.sh libguestfs.test.simple.create-opensuse-guest.sh + libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh ------------------------------------------------------------------- Mon Jan 20 23:09:24 CET 2014 - ohering@suse.de diff --git a/libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh b/libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh new file mode 100644 index 0000000..0bb635d --- /dev/null +++ b/libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh @@ -0,0 +1,333 @@ +#!/bin/bash +# Create an openSUSE image with lvm on dm-crypt partition +# +# Theory of operation: +# This script uses zypper from the host to resolve dependencies +# for zypper which runs within the appliance. If zypper on the host +# is too old, it will be unable to handle repo data from 13.1: +# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html +# "[zypp-devel] Package conflicting with itself" +# For this reason zypper from 12.3 can be used to install the pattern +# of the final repo. +# First the dependencies of zypper are resolved, the required packages +# are downloaded and extracted with unrpm. Now the guest is started and +# the partitions in the diskimage are prepared. Then the extracted +# package content is copied into the guest. Once that is done zypper +# inside the guest will install the base pattern and a few extra packages. +# Finally the bootloader grub is configured. Once all that is done +# kvm is started. If all goes well a login prompt appears. +# The password for the crypted partition is "123456". +# The password for root is "root". +# The guest has also network access to the outside. +# +# Expected runtime: ca. 200 seconds +# Requires at least 1.24.5 because this includes the required crypt modules +# +# Expected output: +# guest should start +# no "obvious" errors should be shown during the disk operation +# at the end kvm is started with the generated disk image +# login should be possible +# +set -e +unset LANG +unset ${!LC_*} +cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1` + +output_diskimage=/dev/shm/$LOGNAME/testcase.img +final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/ +initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/ +force=false +guest_zypper_in__pattern_name="base" +guest_zypper_in__package_list=" +grub +less +master-boot-code +nfs-utils +parted +vim +" +guest_root_password="root" +guest_crypt_password="123456" +diskname_inside_vm=/dev/sda + +case "$0" in + /*) progname="$0" ;; + *) progname="$PWD/$0" ;; +esac + +_exit() { + echo "Exiting '$0 $*'." + exit 1 +} + +_unrpm() { + CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories" + FILES="$@" + for f in $FILES; do + echo -ne "$f:\t" + rpm2cpio $f | cpio ${CPIO_OPTS} + done +} + +until test $# -lt 1 +do + case "$1" in + --unrpm) shift ; _unrpm "$@" ; exit 0 ;; + -n) diskname_inside_vm="$2" ; shift ;; + -o) output_diskimage="$2" ; shift ;; + -R) initial_repo="$2" ; shift ;; + -r) final_repo="$2" ; shift ;; + -f) force=true ;; + -x) set -x ;; + *) echo "Unknown option '$1'" ; exit 1 ;; + esac + shift +done +if test -z "${initial_repo}" +then + echo "URL to initial repo required. Wrong -R option." + _exit +fi +if test -z "${final_repo}" +then + echo "URL to final repo required. Wrong -r option." + _exit +fi +if test -z "${output_diskimage}" +then + echo "Filename for temporary disk image required. Wrong -o option." + _exit +fi +if test -e "${output_diskimage}" +then + if test "${force}" = "false" + then + echo "Output diskimage '${output_diskimage}' exists." + echo "It will not be overwritten. Option '-f' exists to force overwrite." + _exit + fi +fi +zypper --version +cpio --version +guestfish --version +kvm="qemu-system-`uname -m`" +if $kvm --version +then + : good +else + kvm="qemu-kvm" + if $kvm --version + then + : + else + echo "No qemu-kvm found." + _exit + fi +fi +guestfish_version="`guestfish --version | awk '{print \$2}'`" +case "${guestfish_version}" in + 1.20*) _exit ;; + 1.21*) _exit ;; + 1.22*) _exit ;; + 1.23*) _exit ;; + 1.24.[0-4]) _exit ;; + *) ;; +esac + +mkdir -vp "${output_diskimage%/*}" +td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}` +tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}` +_exit() { +rm -rf "$tf" +rm -rf "$td" +} +trap _exit EXIT +dir_repo=${td}/repos.d +dir_root=${td}/root +dir_cache=${td}/cache +mkdir -vp \ + ${dir_root} \ + ${dir_cache} \ + ${dir_repo} +cat > ${tf} < ${dir_repo}/tmp.repo <> etc/resolv.conf +echo nameserver 169.254.2.3 >> etc/resolv.conf +grep -w root /etc/passwd > etc/passwd +grep -w root /etc/group > etc/group +echo 'root::15209::::::' > etc/shadow +cat > etc/fstab < etc/grub.conf < boot/grub/device.map +cat > boot/grub/menu.lst <&1 " : \ +sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \ +sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \ +sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/grub /usr/lib/grub/*" : \ +sh "grub --batch --verbose < /etc/grub.conf" : \ +sh "echo crypt_part4 ${diskname_inside_vm}4 none luks,timeout=0 >> /etc/crypttab" : \ +mkdir /LV_ROOT : \ +sh "echo LABEL=LV_ROOT /LV_ROOT ext4 noatime 1 2 >> /etc/fstab" : \ +mkdir /LV_WORK : \ +sh "echo LABEL=LV_WORK /LV_WORK ext4 noatime 1 2 >> /etc/fstab" : \ +mkdir /LV_HOME : \ +sh "echo LABEL=LV_HOME /LV_HOME ext4 noatime 1 2 >> /etc/fstab" : \ +mkdir /LV_MAIL : \ +sh "echo LABEL=LV_MAIL /LV_MAIL ext4 noatime 1 2 >> /etc/fstab" : \ +sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \ +sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \ +sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \ +cat /etc/fstab : \ +quit +ls -lhsS "${output_diskimage}" + +: ${diskname_inside_vm} +case "${diskname_inside_vm}" in + *vda*) + qemu_drive_options=" + -drive file=${output_diskimage},cache=writeback,id=hd0,if=none \ + -device virtio-blk-pci,drive=hd0 \ + " + ;; + *sda*) + qemu_drive_options=" + -device virtio-scsi-pci,id=scsi \ + -drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \ + -device scsi-hd,drive=hd0 \ + " + ;; + *) + echo "${diskname_inside_vm} not handled" + _exit +esac +$kvm -enable-kvm \ + -global virtio-blk-pci.scsi=off \ + -enable-fips \ + -machine accel=kvm:tcg \ + -cpu host,+kvmclock \ + -m 500 \ + -no-reboot \ + -no-hpet \ + ${qemu_drive_options} \ + -device virtio-serial-pci \ + -serial stdio \ + -device sga \ + -netdev user,id=usernet,net=169.254.0.0/16 \ + -device virtio-net-pci,netdev=usernet + +exit 0 diff --git a/libguestfs.test.simple.create-opensuse-guest.sh b/libguestfs.test.simple.create-opensuse-guest.sh index 628b1a8..3da3c15 100644 --- a/libguestfs.test.simple.create-opensuse-guest.sh +++ b/libguestfs.test.simple.create-opensuse-guest.sh @@ -19,7 +19,7 @@ # The password for root is "root". # The guest has also network access to the outside. # -# Expected runtime: ca. 120 seconds +# Expected runtime: ca. 180 seconds # # Expected output: # guest should start @@ -37,7 +37,14 @@ final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/ initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/ force=false guest_zypper_in__pattern_name="base" -guest_zypper_in__package_list="less vim grub master-boot-code parted nfs-utils" +guest_zypper_in__package_list=" +grub +less +master-boot-code +nfs-utils +parted +vim +" guest_root_password="root" diskname_inside_vm=/dev/sda @@ -232,7 +239,7 @@ command "ip a" : \ command "curl google.com" : \ command "zypper help" : \ command "zypper -v -v ar -c -K -f ${final_repo} tmp" : \ -sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in ${guest_zypper_in__package_list} ) 2>&1 " : \ +sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in `eval echo ${guest_zypper_in__package_list}` ) 2>&1 " : \ sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \ sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \ sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/grub /usr/lib/grub/*" : \ From 660c9127dfb3419b63d664ba04fefa22ef4487d420373536768ea93cd0092e9c Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 22 Jan 2014 16:49:58 +0000 Subject: [PATCH 8/8] Install new test OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=263 --- libguestfs.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libguestfs.spec b/libguestfs.spec index ca140ae..1f77c1c 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -163,6 +163,7 @@ Source1110: libguestfs.mkinitrd.1110.patch # Source10001: libguestfs.test.simple.run-libugestfs-test-tool.sh Source10002: libguestfs.test.simple.create-opensuse-guest.sh +Source10003: libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh # Requires: guestfs-tools @@ -535,6 +536,7 @@ rm -rfv $RPM_BUILD_ROOT%{_libdir}/guestfs/supermin.d # mkdir -p $RPM_BUILD_ROOT%{_datadir}/guestfs cp -avLt $RPM_BUILD_ROOT%{_datadir}/guestfs \ + %{S:10003} \ %{S:10002} \ %{S:10001} chmod 0755 $RPM_BUILD_ROOT%{_datadir}/guestfs/*