On Sat, Dec 07, 2013 at 01:51:53PM +0100, Ronny Chevalier wrote: > 2013/12/7 Zbigniew Jędrzejewski-Szmek <[email protected]>: > > On Thu, Dec 05, 2013 at 06:24:58PM +0100, Ronny Chevalier wrote: > >> from Alexander Graf's script: > >> http://www.spinics.net/lists/kvm/msg72389.html > >> --- > >> Hi, > >> > >> It adds a little script which try to find a QEMU binary on the system and > >> enable kvm if it's available. This script is used when running QEMU in the > >> tests. (We can also specify a different kernel and initramfs) > > Hi Ronny, > > since this is code from the kernel, it is implicitly GPLv2 licensed. > > systemd is suppose to be / become LGPLv2+ as a whole, and including this > > make this impossible. But anyway, I think that large parts of are not > > necessary for us: > > - we don't care about old qemu versions, we always assume that > > a person running systemd from git has bleeding edge versions of > > all dependencies updated from the experimental branch each morning, > > - we don't care about insane people who compile qemu from source, > > instead of using the package manager. (I know that this contradicts > > the first point, but who said that developer's life is easy ;) ) > > - if something is missing just say so, no explanation or instructions > > necesary. > Ok, that makes sense > > > > > Otherwise the changes look OK. > > > >> TODO | 1 - > >> test/README.testsuite | 19 ++++- > >> test/TEST-01-BASIC/test.sh | 6 +- > >> test/TEST-02-CRYPTSETUP/test.sh | 6 +- > >> test/TEST-03-JOBS/test.sh | 6 +- > >> test/run-qemu.sh | 150 > >> ++++++++++++++++++++++++++++++++++++++++ > >> test/test-functions | 10 +-- > >> 7 files changed, 170 insertions(+), 28 deletions(-) > >> create mode 100755 test/run-qemu.sh > >> > >> diff --git a/TODO b/TODO > >> index 9698082..f493dbb 100644 > >> --- a/TODO > >> +++ b/TODO > >> @@ -168,7 +168,6 @@ Features: > >> * test/: > >> - add 'set -e' to scripts in test/ > >> - make stuff in test/ work with separate output dir > >> - - qemu wrapper script: http://www.spinics.net/lists/kvm/msg72389.html > >> > >> * systemctl delete x.snapshot leaves no trace in logs (at least at > >> default level). > >> > >> diff --git a/test/README.testsuite b/test/README.testsuite > >> index 54d0eaa..3b841cd 100644 > >> --- a/test/README.testsuite > >> +++ b/test/README.testsuite > >> @@ -25,11 +25,24 @@ $ make all > >> $ cd test/TEST-01-BASIC > >> $ sudo make clean setup run > >> > >> +QEMU > >> +==== > >> + > >> If you want to log in the testsuite virtual machine, you can specify > >> -additional kernel command line parameter with $DEBUGFAIL. > >> +additional kernel command line parameter with $KERNEL_APPEND. > >> > >> -$ sudo make DEBUGFAIL="systemd.unit=multi-user.target" clean setup run > >> +$ sudo make KERNEL_APPEND="systemd.unit=multi-user.target" clean setup run > >> > >> you can even skip the "clean" and "setup" if you want to run the machine > >> again. > >> > >> -$ sudo make DEBUGFAIL="systemd.unit=multi-user.target" run > >> +$ sudo make KERNEL_APPEND="systemd.unit=multi-user.target" run > >> + > >> +You can specify a different kernel and initramfs with $KERNEL_BIN and > >> $INITRD. > >> +(Fedora's default kernel path and initramfs are used by default) > >> + > >> +$ sudo make KERNEL_BIN=/boot/vmlinuz-foo INITRD=/boot/initramfs-bar clean > >> check > >> + > >> +A script will try to find your QEMU binary. If you want to specify a > >> different > >> +one you can use $QEMU_BIN. > >> + > >> +$ sudo make QEMU_BIN=/path/to/qemu/qemu-kvm clean check > >> diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh > >> index aaf63f4..c598af9 100755 > >> --- a/test/TEST-01-BASIC/test.sh > >> +++ b/test/TEST-01-BASIC/test.sh > >> @@ -5,9 +5,6 @@ TEST_DESCRIPTION="Basic systemd setup" > >> > >> . $TEST_BASE_DIR/test-functions > >> > >> -# Uncomment this to debug failures > >> -#DEBUGFAIL="systemd.unit=multi-user.target" > >> - > >> check_result_qemu() { > >> ret=1 > >> mkdir -p $TESTDIR/root > >> @@ -23,8 +20,7 @@ check_result_qemu() { > >> } > >> > >> test_run() { > >> - if check_qemu ; then > >> - run_qemu > >> + if run_qemu; then > >> check_result_qemu || return 1 > >> else > >> dwarn "can't run qemu-kvm, skipping" > >> diff --git a/test/TEST-02-CRYPTSETUP/test.sh > >> b/test/TEST-02-CRYPTSETUP/test.sh > >> index 86617df..b9161e7 100755 > >> --- a/test/TEST-02-CRYPTSETUP/test.sh > >> +++ b/test/TEST-02-CRYPTSETUP/test.sh > >> @@ -5,9 +5,6 @@ TEST_DESCRIPTION="cryptsetup systemd setup" > >> > >> . $TEST_BASE_DIR/test-functions > >> > >> -# Uncomment this to debug failures > >> -#DEBUGFAIL="systemd.unit=multi-user.target" > >> - > >> check_result_qemu() { > >> ret=1 > >> mkdir -p $TESTDIR/root > >> @@ -28,8 +25,7 @@ check_result_qemu() { > >> > >> > >> test_run() { > >> - if check_qemu ; then > >> - run_qemu > >> + if run_qemu; then > >> check_result_qemu || return 1 > >> else > >> dwarn "can't run qemu-kvm, skipping" > >> diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh > >> index 6303258..9190eb0 100755 > >> --- a/test/TEST-03-JOBS/test.sh > >> +++ b/test/TEST-03-JOBS/test.sh > >> @@ -5,9 +5,6 @@ TEST_DESCRIPTION="Job-related tests" > >> > >> . $TEST_BASE_DIR/test-functions > >> > >> -# Uncomment this to debug failures > >> -#DEBUGFAIL="systemd.unit=multi-user.target" > >> - > >> check_result_qemu() { > >> ret=1 > >> mkdir -p $TESTDIR/root > >> @@ -23,8 +20,7 @@ check_result_qemu() { > >> } > >> > >> test_run() { > >> - if check_qemu ; then > >> - run_qemu > >> + if run_qemu; then > >> check_result_qemu || return 1 > >> else > >> dwarn "can't run qemu-kvm, skipping" > >> diff --git a/test/run-qemu.sh b/test/run-qemu.sh > >> new file mode 100755 > >> index 0000000..17708da > >> --- /dev/null > >> +++ b/test/run-qemu.sh > >> @@ -0,0 +1,150 @@ > >> +#!/bin/bash > >> +# > >> +# based on: http://www.spinics.net/lists/kvm/msg72389.html > >> +# > >> + > >> +# Uncomment this to debug failures > >> +#KERNEL_APPEND="systemd.unit=multi-user.target" > >> +KERNEL_VER=${KERNEL_VER-$(uname -r)} > >> +[ "$KERNEL_BIN" ] || KERNEL_BIN=/boot/vmlinuz-$KERNEL_VER > >> +[ "$INITRD" ] || INITRD=/boot/initramfs-${KERNEL_VER}.img > >> +[ "$SMP" ] || SMP=1 > >> +BASENAME=$(basename "$0") > >> +IMAGE= > >> + > >> +function usage() { > >> + echo "$BASENAME IMAGE -- [QEMU_OPTIONS]" > >> +} > >> + > >> +function verify_qemu() { > >> + QEMU="$(which $1 2>/dev/null)" > >> + > >> + # binary exists? > >> + [ -x "$QEMU" ] || exit 1 > >> + > >> + # we need a version that knows -machine > >> + if ! "$QEMU" --help | grep -q -- '-machine'; then > >> + exit 1 > >> + fi > >> + > >> + echo "$QEMU" > >> + exit 0 > >> +} > >> + > >> +function find_qemu_bin() { > >> + # Try to find the KVM accelerated QEMU binary > >> + > >> + # SUSE and Red Hat call the binary qemu-kvm > >> + [ "$QEMU_BIN" ] && return || QEMU_BIN=$(verify_qemu qemu-kvm) > >> + > >> + # Debian and Gentoo call it kvm > >> + [ "$QEMU_BIN" ] && return || QEMU_BIN=$(verify_qemu kvm) > >> + > >> + [ "$ARCH" ] || ARCH=$(uname -m) > >> + case $ARCH in > >> + x86_64) > >> + # QEMU's own build system calls it qemu-system-x86_64 > >> + [ "$QEMU_BIN" ] || QEMU_BIN=$(verify_qemu qemu-system-x86_64) > >> + ;; > >> + i*86) > >> + # new i386 version of QEMU > >> + [ "$QEMU_BIN" ] || QEMU_BIN=$(verify_qemu qemu-system-i386) > >> + > >> + # i386 version of QEMU > >> + [ "$QEMU_BIN" ] || QEMU_BIN=$(verify_qemu qemu) > >> + ;; > >> + esac > > > > I think if you say > > QEMU_BIN=$(LANG=C which qemu qemu-kvm qemu-system-$ARCH | grep '^/' -m1) > > the effect will be similar without all the verbosity. > Not really since in qemu-system-XXXX, the XXXX part is general. For > ARM for instance, there is just arm and not armv7l or others. The same > for i386/i686,... It works for most people if they have common > architecture like x86_64 or i386. > I think the switch can be updated for each architecture someone is aware of. OK.
> So I remove all useless parts in the script, keep the switch to find > the suitable binary and resend the patch ? Because I think this kind > of script is still useful to avoid modifying manually test-functions > and searching which are the options and binary name. And maybe just > leave this in test-functions, because a separate file is not really > useful now. Yes. > But is it still gonna be a problem for the license ? If it is just a few lines of bash switch statements and variable assignments, then I think no. It *is* good to keep the same variable names as the kernel script. Zbyszek _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
