This patch series reworks mounting of persistent config to use STATE_MOUNT in rc.sysinit so configs take effect early enough e.g. /etc/fstab
workaround for bind-mounted files see https://fedorahosted.org/augeas/ticket/32 requires augeas 0.3.5 augtool [tmpaugscript] script MUST NOT include save, it is added by the wrapper with copy_if_rename_fails flag set 'tmpaugscript' is removed after successfull execution without a parameter, augtool commands are expected on standard input Signed-off-by: Alan Pevec <apevec at redhat.com> --- ovirt-node.spec.in | 2 +- scripts/ovirt-config-hostname | 10 +++----- scripts/ovirt-config-networking | 4 +- scripts/ovirt-config-storage | 3 +- scripts/ovirt-early | 7 +----- scripts/ovirt-functions | 46 +++++++++++++++++++++----------------- scripts/ovirt-process-config | 9 +++---- 7 files changed, 38 insertions(+), 43 deletions(-) diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in index 501bf4f..ddccc2d 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -18,7 +18,7 @@ Requires(preun): /sbin/chkconfig BuildRequires: libvirt-devel >= 0.5.1 BuildRequires: dbus-devel hal-devel Requires: libvirt >= 0.5.1 -Requires: augeas +Requires: augeas >= 0.3.5 Requires: libvirt-qpid >= 0.2.3 Requires: hal Requires: collectd-virt diff --git a/scripts/ovirt-config-hostname b/scripts/ovirt-config-hostname index 8530843..f609b38 100755 --- a/scripts/ovirt-config-hostname +++ b/scripts/ovirt-config-hostname @@ -8,16 +8,14 @@ HOSTNAME_FILE="/etc/sysconfig/network" function set_hostname { - augtool > /dev/null <<EOF - set /files$HOSTNAME_FILE/HOSTNAME "$1" - save + augtool <<EOF +set /files$HOSTNAME_FILE/HOSTNAME "$1" EOF } function remove_hostname { - augtool > /dev/null <<EOF - rm /files$HOSTNAME_FILE/HOSTNAME - save + augtool <<EOF +rm /files$HOSTNAME_FILE/HOSTNAME EOF } diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 52af071..3c22369 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -188,8 +188,8 @@ if [ "$RESTART" == "Y" ]; then { printf "Configuring network.\n" config="$WORKDIR"/config-augtool - { cat "$WORKDIR"/augtool-* && printf "save\n"; } > $config \ - && augtool < $config \ + cat "$WORKDIR"/augtool-* > $config \ + && augtool $config \ && service network restart } 2>&1 | tee $CONFIG_LOG_FILE diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index f68e058..58734f4 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -120,14 +120,13 @@ do_configure() fi done # save input variables - augtool <<EOF > /dev/null + augtool <<EOF set /files$OVIRT_DEFAULTS/OVIRT_INIT $DRIVE set /files$OVIRT_DEFAULTS/OVIRT_VOL_BOOT_SIZE $BOOT_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_SWAP_SIZE $SWAP_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_ROOT_SIZE $ROOT_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_CONFIG_SIZE $CONFIG_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_LOGGING_SIZE $LOGGING_SIZE -save EOF } diff --git a/scripts/ovirt-early b/scripts/ovirt-early index a911b65..f145594 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -300,12 +300,7 @@ start() { echo "set /files$OVIRT_DEFAULTS/OVIRT_$PARAM '\"$value\"'" \ >> $tmpaug done - echo "save" >> $tmpaug - # augtool on bindmounted files fails - umount_config $OVIRT_DEFAULTS - augtool < $tmpaug > /dev/null - ovirt_store_config $OVIRT_DEFAULTS - rm $tmpaug + augtool $tmpaug else echo "initial startup" # dump all ovirt bootparams diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index 9301678..57e6fd1 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -51,12 +51,9 @@ is_firstboot() { disable_firstboot() { if mount_config; then - umount_config $OVIRT_DEFAULTS - augtool > /dev/null <<EOF + augtool <<EOF set /files$OVIRT_DEFAULTS/OVIRT_FIRSTBOOT no -save EOF - ovirt_store_config $OVIRT_DEFAULTS fi } @@ -196,24 +193,31 @@ mount_config() { fi } -# unmount bindmounted config files -# umount_config /etc/config /etc/config2 ... -# -# Use before running sed -i or augeas against the bindmounted file, -# Otherwise save fails: https://fedorahosted.org/augeas/ticket/32 -# After file is replaced, call ovirt_store_config /etc/config /etc/config2 ... -# to bindmount the config file again. -# -umount_config() { - if grep -q " /config " /proc/mounts; then - for f in "$@"; do - if grep -q " $f " /proc/mounts ; then - umount -n $f - # refresh rootfs copy - cp /config$f $f - fi - done +# augtool wrapper +# workaround for bind-mounted files +# see https://fedorahosted.org/augeas/ticket/32 +# augtool [tmpaugscript] +# script MUST NOT include save, it is added by the wrapper +# with copy_if_rename_fails flag set +# 'tmpaugscript' is removed after successfull execution +# without a parameter, augtool commands are expected on standard input +augtool() { + local tmpaug=$1 + if [ -z "$1" ]; then + # read from stdin + tmpaug=$(mktemp) + cat > $tmpaug fi + cat >> $tmpaug <<EOF +clear /augeas/save/copy_if_rename_fails +save +EOF + /usr/bin/augtool < $tmpaug > /dev/null + rc=$? + if [ $rc -eq 0 ]; then + rm $tmpaug + fi + return $rc } # persist configuration to /config diff --git a/scripts/ovirt-process-config b/scripts/ovirt-process-config index 8641fa0..dd1b7e5 100755 --- a/scripts/ovirt-process-config +++ b/scripts/ovirt-process-config @@ -5,6 +5,8 @@ # configuration file. It then restarts the networking service # and saves the configuration files. +. /etc/init.d/ovirt-functions + ME=$(basename "$0") warn() { printf '%s: %s\n' "$ME" "$*" >&2; } try_h() { printf "Try \`$ME -h' for more information.\n" >&2; exit 1;} @@ -57,17 +59,14 @@ networking=$(awk '/^[ \t]*ifcfg=/ { } } - - printf("save\n") - }' $CONFIG) echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE if [ -f $OVIRT_CONFIG_OUTPUT_FILE ]; then - umount_config /etc/sysconfig/network-scripts/ifcfg* - augtool < $OVIRT_CONFIG_OUTPUT_FILE \ + augtool $OVIRT_CONFIG_OUTPUT_FILE \ && RESULT=0 || RESULT=1 + # FIXME do not store ifcfg-lo if ls /etc/sysconfig/network-scripts/ifcfg* > /dev/null >2&1; then ovirt_store_config /etc/sysconfig/network-scripts/ifcfg* fi -- 1.6.0.6
Alan Pevec
2009-Jan-15 14:20 UTC
[Ovirt-devel] [PATCH node] register persisted configs in /config/files
used by STATE_MOUNT in rc.sysinit Signed-off-by: Alan Pevec <apevec at redhat.com> --- scripts/ovirt-functions | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index 57e6fd1..26dc556 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -230,12 +230,18 @@ ovirt_store_config() { printf " $f" # skip if already bind-mounted if grep -q " $f " /proc/mounts ; then - printf " already persisted\n" + printf "" else mkdir -p /config$(dirname $f) cp -a $f /config$f \ && mount -n --bind /config$f $f \ - || printf " failed to persist\n" + || printf " failed to persist" + fi + # register in /config/files used by rc.sysinit + if grep -q "^$f" /config/files 2> /dev/null ; then + printf "" + else + printf "$f\n" >> /config/files fi done echo -- 1.6.0.6
Alan Pevec
2009-Jan-15 14:20 UTC
[Ovirt-devel] [PATCH node] register created local filesystems in fstab
also persist /etc/fstab so that local filesystems are mounted early in boot process by in rc.sysinit Signed-off-by: Alan Pevec <apevec at redhat.com> --- scripts/ovirt-config-storage | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 58734f4..3b1b947 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -218,6 +218,7 @@ perform_partitioning() if [ "$SWAP_SIZE" -gt 0 ]; then lvcreate --name Swap --size ${SWAP_SIZE}M /dev/HostVG mkswap -L "SWAP" /dev/HostVG/Swap + echo "/dev/HostVG/Swap swap swap defaults 0 0" >> /etc/fstab fi if [ "$ROOT_SIZE" -gt 0 ]; then lvcreate --name Root --size ${ROOT_SIZE}M /dev/HostVG @@ -233,10 +234,15 @@ perform_partitioning() lvcreate --name Logging --size ${LOGGING_SIZE}M /dev/HostVG mke2fs -T ext3 /dev/HostVG/Logging -L "LOGGING" tune2fs -c 0 -i 0 /dev/HostVG/Logging + echo "/dev/HostVG/Logging /var/log ext3 defaults 0 0" >> /etc/fstab fi lvcreate --name Data -l 100%FREE /dev/HostVG mke2fs -T ext3 /dev/HostVG/Data -L "DATA" tune2fs -c 0 -i 0 /dev/HostVG/Data + echo "/dev/HostVG/Data /data ext3 defaults 0 0" >> /etc/fstab + if mount_config; then + ovirt_store_config /etc/fstab + fi } 2>&1 | tee $LOG if [ $? -eq 0 ]; then -- 1.6.0.6
Darryl L. Pierce
2009-Jan-15 15:59 UTC
[Ovirt-devel] [PATCH node] mounting of persistent config
On Thu, Jan 15, 2009 at 03:20:25PM +0100, Alan Pevec wrote:> This patch series reworks mounting of persistent config > to use STATE_MOUNT in rc.sysinit so configs take effect early enough > e.g. /etc/fstabACK to the series, it appears to work for me. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Virtual Machine Management - http://www.ovirt.org/ "What do you care what other people think, Mr. Feynman?" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090115/5e298067/attachment.sig>
Bryan Kearney
2009-Jan-16 01:49 UTC
[Ovirt-devel] [PATCH node] mounting of persistent config
Alan Pevec wrote:> This patch series reworks mounting of persistent config > to use STATE_MOUNT in rc.sysinit so configs take effect early enough > e.g. /etc/fstab > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-develBTW... Ack on all these as well. -- bk