|
|
9ae3a8 |
From e936dcde086c84c08102f821c99381005acd272a Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 31 Jul 2013 22:15:05 +0200
|
|
|
9ae3a8 |
Subject: qga fsfreeze main hook: adapt to RHEL-7 (RH only)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1375308906-23405-3-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 52885
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH v3 2/3] qga fsfreeze main hook: adapt to RHEL-7 (RH only)
|
|
|
9ae3a8 |
Bugzilla: 969942
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=969942
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
LOGFILE should look like it does on RHEL-6.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The main fsfreeze script should process hook files like systemd does
|
|
|
9ae3a8 |
[Paolo].
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/scripts/qemu-guest-agent/fsfreeze-hook b/scripts/qemu-guest-agent/fsfreeze-hook
|
|
|
9ae3a8 |
index c27b29f..45514fa 100755
|
|
|
9ae3a8 |
--- a/scripts/qemu-guest-agent/fsfreeze-hook
|
|
|
9ae3a8 |
+++ b/scripts/qemu-guest-agent/fsfreeze-hook
|
|
|
9ae3a8 |
@@ -1,4 +1,4 @@
|
|
|
9ae3a8 |
-#!/bin/sh
|
|
|
9ae3a8 |
+#!/bin/bash
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
# This script is executed when a guest agent receives fsfreeze-freeze and
|
|
|
9ae3a8 |
# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
|
|
|
9ae3a8 |
@@ -7,8 +7,7 @@
|
|
|
9ae3a8 |
# "freeze" argument before the filesystem is frozen. And for fsfreeze-thaw
|
|
|
9ae3a8 |
# request, it is issued with "thaw" argument after filesystem is thawed.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-LOGFILE=/var/log/qga-fsfreeze-hook.log
|
|
|
9ae3a8 |
-FSFREEZE_D=$(dirname -- "$0")/fsfreeze-hook.d
|
|
|
9ae3a8 |
+LOGFILE=/var/log/qemu-ga.fsfreeze-hook.log
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
# Check whether file $1 is a backup or rpm-generated file and should be ignored
|
|
|
9ae3a8 |
is_ignored_file() {
|
|
|
9ae3a8 |
@@ -19,15 +18,26 @@ is_ignored_file() {
|
|
|
9ae3a8 |
return 1
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-# Iterate executables in directory "fsfreeze-hook.d" with the specified args
|
|
|
9ae3a8 |
-[ ! -d "$FSFREEZE_D" ] && exit 0
|
|
|
9ae3a8 |
-for file in "$FSFREEZE_D"/* ; do
|
|
|
9ae3a8 |
- is_ignored_file "$file" && continue
|
|
|
9ae3a8 |
- [ -x "$file" ] || continue
|
|
|
9ae3a8 |
- printf "$(date): execute $file $@\n" >>$LOGFILE
|
|
|
9ae3a8 |
- "$file" "$@" >>$LOGFILE 2>&1
|
|
|
9ae3a8 |
+shopt -s nullglob
|
|
|
9ae3a8 |
+RELPATH=qemu-ga/fsfreeze-hook.d
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+for DIR in lib etc run; do
|
|
|
9ae3a8 |
+ for FILE in /"$DIR/$RELPATH"/*; do
|
|
|
9ae3a8 |
+ if is_ignored_file "$FILE" || ! [ -x "$FILE" ]; then
|
|
|
9ae3a8 |
+ continue
|
|
|
9ae3a8 |
+ fi
|
|
|
9ae3a8 |
+ BNAME=$(basename -- "$FILE")
|
|
|
9ae3a8 |
+ if ( [ lib = "$DIR" ] && ( [ -e /etc/"$RELPATH/$BNAME" ] ||
|
|
|
9ae3a8 |
+ [ -e /run/"$RELPATH/$BNAME" ] ) ) ||
|
|
|
9ae3a8 |
+ ( [ etc = "$DIR" ] && ( [ -e /run/"$RELPATH/$BNAME" ] ) ); then
|
|
|
9ae3a8 |
+ continue
|
|
|
9ae3a8 |
+ fi
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ printf "$(date): execute $FILE $@\n" >>$LOGFILE
|
|
|
9ae3a8 |
+ "$FILE" "$@" >>$LOGFILE 2>&1
|
|
|
9ae3a8 |
STATUS=$?
|
|
|
9ae3a8 |
- printf "$(date): $file finished with status=$STATUS\n" >>$LOGFILE
|
|
|
9ae3a8 |
+ printf "$(date): $FILE finished with status=$STATUS\n" >>$LOGFILE
|
|
|
9ae3a8 |
+ done
|
|
|
9ae3a8 |
done
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
exit 0
|