Hi,
Per recent discussion with David, it became clear that the ability to
pass rumprun-bake config directives on the command line is desirable
(IIRC it was already proposed in the discussion last year, but there was
no strong use case back then). The new use case is genfs'd components.
Without command line parameters, you have to create a config file,
assimilate the config you actually want (which, mind you, cannot be
hardcoded since only the user knows what it is), add the fs image, and
pass that config via -c to rumprun-bake, and potentially remove the
config afterwards. With command line directives, it's a oneliner.
After the change, for example:
whatever-genfs out dir1 dir2
rumprun-bake -m "add $(pwd)/out" hw_virtio a.bin a.out
Now, to make the syntax sane, it also required a change to the
rumprun-bake config format. The new format is block-based. For
example, when you previously did:
create hw_myconfig description
add hw_myconfig what ever
In the new version you do:
conf hw_myconfig
create description
add what ever
fnoc
IOW, everything between "conf" and "fnoc" always applies to the same config.
That way, the bake command is simplified and doesn't have to contain
duplicates: rumprun-bake -m 'add hw_virtio ...' hw_virtio ...
Notably, the old command line syntax for rumprun-bake does not change in
backwards-incompatible ways, but the config file format does. I did not
add compat code to deal with the old format. It should be possible if a
large number of people demand it, but I'd much rather just ride the
"experimental" tag we forgot to remove. I doubt there are many (if any)
custom config format deployments at the time.
I pushed the changes to the pooka-rumprun-newconfig branch. The current
diff is at the end of the mail for convenience reasons.
Thoughts? (LGTM is a good one, but others accepted too ;)
- antti
diff --git a/app-tools/rumprun-bake.conf b/app-tools/rumprun-bake.conf
index ed4149a..733a4c8 100644
--- a/app-tools/rumprun-bake.conf
+++ b/app-tools/rumprun-bake.conf
@@ -2,14 +2,14 @@
# rumpbake default configuration file
#
-version 20150930
+version 20160209
#
# First, define internal convenience sets.
#
-create _foundation "basic components for the Rumprun unikernel"
- add _foundation \
- -lrumpvfs \
+conf _foundation
+ create "basic components for the Rumprun unikernel"
+ add -lrumpvfs \
-lrumpkern_bmktc \
-lrumpkern_mman \
-lrumpdev \
@@ -20,112 +20,126 @@ create _foundation "basic components for the
Rumprun unikernel"
-lrumpdev_vnd \
-lrumpdev_rnd \
-lrumprunfs_base
+fnoc
-create _virtio "virtio drivers"
- add _virtio \
- -lrumpdev_virtio_if_vioif \
+conf _virtio
+ create "virtio drivers"
+ add -lrumpdev_virtio_if_vioif \
-lrumpdev_virtio_ld \
-lrumpdev_virtio_viornd \
-lrumpdev_pci_virtio \
-lrumpdev_pci
+fnoc
-create _audio "audio subsystem and some PCI audio device drivers"
- add _audio \
- -lrumpdev_audio \
+conf _audio
+ create "audio subsystem and some PCI audio device drivers"
+ add -lrumpdev_audio \
-lrumpdev_audio_ac97 \
-lrumpdev_pci_auich \
-lrumpdev_pci_eap \
-lrumpdev_pci_hdaudio \
-lrumpdev_hdaudio_hdafg
+fnoc
-create _netinet "TCP/IP (v4)"
- add _netinet \
- -lrumpnet_netinet \
+conf _netinet
+ create "TCP/IP (v4)"
+ add -lrumpnet_netinet \
-lrumpnet_net \
-lrumpnet
+fnoc
-create _netinet6 "TCP/IP (v6)"
- add _netinet6 \
- -lrumpnet_netinet6 \
+conf _netinet6
+ create "TCP/IP (v6)"
+ add -lrumpnet_netinet6 \
-lrumpnet_net \
-lrumpnet
+fnoc
-create _netunix "local domain sockets"
- add _netunix \
- -lrumpnet_local \
+conf _netunix
+ create "local domain sockets"
+ add -lrumpnet_local \
-lrumpnet
+fnoc
-create _stdfs "selection of file system drivers"
- add _stdfs \
- -lrumpfs_ffs \
+conf _stdfs
+ create "selection of file system drivers"
+ add -lrumpfs_ffs \
-lrumpfs_cd9660 \
-lrumpfs_ext2fs \
-lrumpdev_disk \
- -lrumpvfs
+ -lrumpvfs
+fnoc
-create _pciether "PCI Ethernet NIC drivers"
- add _pciether \
- -lrumpdev_pci_if_wm \
+conf _pciether
+ create "PCI Ethernet NIC drivers"
+ add -lrumpdev_pci_if_wm \
-lrumpdev_miiphy \
-lrumpdev_pci
+fnoc
-create _usb "USB stack incl. PCI USB host controllers"
- add _usb \
- -lrumpdev_pci_usbhc \
+conf _usb
+ create "USB stack incl. PCI USB host controllers"
+ add -lrumpdev_pci_usbhc \
-lrumpdev_usb \
-lrumpdev_umass \
-lrumpdev_scsipi \
-lrumpdev_pci
+fnoc
# this is a config so that it can be assimilated
-create _sysproxy "system call proxy support"
- add _sysproxy \
- -lrumpkern_sysproxy
-
-create _miconf "general useful MI/pseudo driver set"
- assimilate _miconf \
- _foundation \
- _netinet \
- _netinet6 \
- _netunix \
- _stdfs \
- _sysproxy
+conf _sysproxy
+ create "system call proxy support"
+ add -lrumpkern_sysproxy
+fnoc
+
+conf _miconf
+ create "general useful MI/pseudo driver set"
+ assimilate _foundation \
+ _netinet \
+ _netinet6 \
+ _netunix \
+ _stdfs \
+ _sysproxy
+fnoc
#
# then, define some end-user configs
#
-create xen_pv "Xen with paravirtualized I/O drivers"
- assimilate xen_pv \
- _miconf
- add xen_pv \
- -lrumpfs_kernfs \
- -lrumpnet_xenif \
- -lrumpxen_xendev
-
-create xen_pci "Xen with paravirtualized and PCI I/O drivers"
- assimilate xen_pci \
- xen_pv \
- _pciether
-
-create hw_virtio "virtio targets (e.g. QEMU/KVM)"
- assimilate hw_virtio \
- _miconf \
- _virtio
-
-create hw_virtio_scsi "virtio targets with SCSI (e.g. QEMU/KVM)"
- assimilate hw_virtio_scsi \
- _miconf \
- _virtio
- add hw_virtio_scsi \
- -lrumpdev_virtio_vioscsi\
- -lrumpdev_scsipi
-
-create hw_generic "generic targets, includes (almost) all drivers"
- assimilate hw_generic \
- _miconf \
- _virtio \
- _audio \
- _pciether \
- _usb
+conf xen_pv
+ create "Xen with paravirtualized I/O drivers"
+ assimilate _miconf
+ add -lrumpfs_kernfs \
+ -lrumpnet_xenif \
+ -lrumpxen_xendev
+fnoc
+
+conf xen_pci
+ create "Xen with paravirtualized and PCI I/O drivers"
+ assimilate xen_pv \
+ _pciether
+fnoc
+
+conf hw_virtio
+ create "virtio targets (e.g. QEMU/KVM)"
+ assimilate _miconf \
+ _virtio
+fnoc
+
+conf hw_virtio_scsi
+ create "virtio targets with SCSI (e.g. QEMU/KVM)"
+ assimilate _miconf \
+ _virtio
+ add -lrumpdev_virtio_vioscsi\
+ -lrumpdev_scsipi
+fnoc
+
+conf hw_generic
+ create "generic targets, includes (almost) all drivers"
+ assimilate _miconf \
+ _virtio \
+ _audio \
+ _pciether \
+ _usb
+fnoc
diff --git a/app-tools/rumprun-bake.in b/app-tools/rumprun-bake.in
index 129e86e..74171bc 100644
--- a/app-tools/rumprun-bake.in
+++ b/app-tools/rumprun-bake.in
@@ -25,7 +25,7 @@
# SUCH DAMAGE.
#
-_RUMPBAKE_VERSION=20150930
+_RUMPBAKE_VERSION=20160209
#
# rumprun-bake: script for final stage linking ("baking") of a
unikernel image
@@ -33,6 +33,8 @@ _RUMPBAKE_VERSION=20150930
: ${READELF:=readelf}
unset runcmd
+unset CONF
+unset CFGFILE
if [ "$(basename $0)" = "rumpbake" ]; then
echo '>>'
@@ -82,7 +84,7 @@ _haveconf ()
for x in ${ALLCONFIGS}; do
[ "${x}" != "${1}" ] || return
done
- _die "config ${1} not found (${CURCONF})"
+ _die "config \"${1}\" not found (${CFGFILE})"
}
_nothaveconf ()
@@ -90,7 +92,7 @@ _nothaveconf ()
for x in ${ALLCONFIGS}; do
[ "${x}" != "${1}" ] \
- || _die "config ${1} already exists (${CURCONF})"
+ || _die "config ${1} already exists (${CFGFILE})"
done
}
@@ -120,71 +122,70 @@ version ()
{
[ "${1}" = "${_RUMPBAKE_VERSION}" ] \
- || _die ${CURCONF} mismatch: expect ${_RUMPBAKE_VERSION}, got \"$1\"
+ || _die ${CFGFILE} mismatch: expect ${_RUMPBAKE_VERSION}, got \"$1\"
_VERSOK=true
}
-create ()
+conf ()
{
- local confname descr
-
- confname=$1
- shift || _die "create: not enough arguments (${CURCONF})"
- [ -n "$*" ] || _die "create: need description (${CURCONF})"
- if ! echo ${confname} | egrep -q '^(xen|hw)?_'; then
- _die "create: invalid conf \"$confname\" (${CURCONF})"
+ if ! echo ${1} | egrep -q '^(xen|hw)?_'; then
+ _die "conf: invalid \"$1\" (${CFGFILE})"
fi
+ CONF=$1
+}
- _nothaveconf ${confname}
+fnoc ()
+{
- ALLCONFIGS="${ALLCONFIGS} ${confname}"
- eval CONFDESCR_${confname}=\"${*}\"
+ unset CONF
+}
+
+create ()
+{
+
+ [ -n "$*" ] || _die "create: need description (${CFGFILE})"
+
+ _nothaveconf ${CONF}
+
+ ALLCONFIGS="${ALLCONFIGS} ${CONF}"
+ eval CONFDESCR_${CONF}=\"${*}\"
}
assimilate ()
{
- local to from
+ local from
- to=$1
- shift || _die not enough arguments to assimilate
- _haveconf ${to}
+ _haveconf ${CONF}
for from; do
_haveconf ${from}
- eval CONFIG_${to}=\"\${CONFIG_${to}} \${CONFIG_${from}}\"
+ eval CONFIG_${CONF}=\"\${CONFIG_${CONF}} \${CONFIG_${from}}\"
done
}
nuke ()
{
- [ $# -eq 1 ] || _die "nuke: wrong number of args (${CURCONF})"
- _haveconf ${1}
- _filter ${1} ALLCONFIGS
+ [ $# -eq 0 ] || _die "nuke: wrong number of args (${CFGFILE})"
+ _haveconf ${CONF}
+ _filter ${CONF} ALLCONFIGS
}
add ()
{
- local confname
-
- confname=$1
- shift || _die "not enough args to add (${CURCONF})"
- _haveconf ${confname}
- eval CONFIG_${confname}=\"\${CONFIG_${confname}} $@\"
+ _haveconf ${CONF}
+ eval CONFIG_${CONF}=\"\${CONFIG_${CONF}} $@\"
}
remove ()
{
- local confname compvar
+ local compvar
- confname=$1
- shift || _die "not enough args to remove (${CURCONF})"
+ _haveconf ${CONF}
- _haveconf ${confname}
-
- compvar=CONFIG_${confname}
+ compvar=CONFIG_${CONF}
for x; do
_filter ${x} ${compvar}
done
@@ -193,15 +194,11 @@ remove ()
# debug routine
debugdump ()
{
- local confname
-
- confname=$1
- shift || _die "not enough args to debugdump (${CURCONF})"
- _haveconf ${confname}
+ _haveconf ${CONF}
- _uniq CONFIG_${confname}
- eval echo \${CONFIG_${confname}}
+ _uniq CONFIG_${CONF}
+ eval echo \${CONFIG_${CONF}}
}
_usage ()
@@ -210,8 +207,8 @@ _usage ()
rumprun-bake version: ${_RUMPBAKE_VERSION}
usage: rumprun-bake [-c conffile ...] list
- rumprun-bake [-c conffile ...] describe config
- rumprun-bake [-c conffile ...] config output input [input ...]
+ rumprun-bake [-c conffile ...] [-m cmd ...] describe config
+ rumprun-bake [-c conffile ...] [-m cmd ...] config out in [in ...]
"list" outputs available configs.
@@ -230,34 +227,34 @@ _nuketmpdir ()
nukeme="${TMPDIR}"
TMPDIR=''
- ${runcmd} rm -rf ${nukeme}
+ rm -rf ${nukeme}
}
_readconfig ()
{
local x
- CURCONF="$1"
- if [ ! -f "${CURCONF}" ]; then
- echo "rumprun-bake: error: Configuration file ${CURCONF} not
found"
+ CFGFILE="$1"
+ if [ ! -f "${CFGFILE}" ]; then
+ echo "rumprun-bake: error: Configuration file ${CFGFILE} not
found"
exit 1
fi
_VERSOK=false
# ". foo" doesn't work everywhere/always, so do a dance here.
- # Note: CURCONF needs to remain as what the user gave.
+ # Note: CFGFILE needs to remain as what the user gave.
case "$1" in
/*)
- . "${CURCONF}"
+ . "${CFGFILE}"
;;
*)
- . "$(pwd)/${CURCONF}"
+ . "$(pwd)/${CFGFILE}"
;;
esac
- ${_VERSOK} || _die "config version not specified (${CURCONF})"
+ ${_VERSOK} || _die "config version not specified (${CFGFILE})"
- unset CURCONF
+ unset CFGFILE
# Publish configs which are not private
for x in ${ALLCONFIGS}; do
@@ -297,13 +294,21 @@ _getbininfo ()
done
}
+# does not respect runcmd. let's not mope and whine over it
+TMPDIR=$(mktemp -d /tmp/rumprun-bake.XXXXXX)
+trap _nuketmpdir 0 INT TERM
+
_readconfig "!DESTDIR!/etc/rumprun-bake.conf"
-while getopts "c:n" opt; do
+while getopts "c:m:n" opt; do
case "${opt}" in
c)
_readconfig "${OPTARG}"
;;
+ m)
+ # save. we have to process them after configs are processed
+ echo "${OPTARG}" >> ${TMPDIR}/manualcmds
+ ;;
n)
runcmd=echo
;;
@@ -312,11 +317,11 @@ while getopts "c:n" opt; do
;;
esac
done
-shift $((${OPTIND}-1))
+shift $((${OPTIND}-1))
TARGET="${1}"
-case ${TARGET} in
-list)
+
+if [ "${TARGET}" = "list" ]; then
for x in ${ALLCONFIGS}; do
eval mydesc="\${CONFDESCR_${x}}"
printf '%-16s' "${x}"
@@ -324,13 +329,29 @@ list)
printf '\n'
done
exit 0
- ;;
-describe)
+fi
+
+if [ "${TARGET}" = "describe" ]; then
+ CONFIG=$2
+else
+ CONFIG=$1
+fi
+
+# process potential manual commands
+if [ -f ${TMPDIR}/manualcmds ]; then
+ printf "version %s\n" ${_RUMPBAKE_VERSION} > ${TMPDIR}/cmdconfig
+ printf "conf %s\n" ${CONFIG} >> ${TMPDIR}/cmdconfig
+ cat ${TMPDIR}/manualcmds >> ${TMPDIR}/cmdconfig
+ printf 'fnoc\n' >> ${TMPDIR}/cmdconfig
+ _readconfig ${TMPDIR}/cmdconfig
+fi
+
+if [ "${TARGET}" = "describe" ]; then
[ $# -eq 2 ] || _die \"describe\" needs exactly one config.
- debugdump $2
+ CONF=$2
+ debugdump
exit 0
- ;;
-esac
+fi
OUTPUT="${2}"
[ $# -gt 2 ] || _usage
@@ -365,11 +386,6 @@ _uniq CONFIG_${config}
PLATFORM=${config%%_*}
eval LIBS="\${CONFIG_${config}}"
-# duh
-TMPDIR=/tmp/rumprun-bake.XXXXXX
-[ -z "${runcmd}" ] && TMPDIR=$(mktemp -d ${TMPDIR})
-trap _nuketmpdir 0 INT TERM
-
# Check if the file is a relocatable object produced by a rumprun
toolchain.
# Create a temporary object with a unique "main"
objnum=1