From: Maynard J. <may...@us...> - 2011-04-20 21:24:11
|
As all oprofile users (should) know, if the oprofile daemon is already running, any changes made to oprofile configuration (e.g, a new '--event' value) will not be picked up and actually used until the daemon is restarted. And I'll bet most everyone has been tripped up at least once by the fact that 'opcontrol --status' will show the new configuration information, even though it's not the actual config data being used by the running daemon. The attached patch fixes this problem. Thanks to Reid Kleckner who finally raised a bug over this issue (https://sourceforge.net/tracker/?func=detail&aid=3072766&group_id=16191&atid=116191). *Will*, could you find time to review this? Thanks. -Maynard --------------------------------------------------------------- >From e393309c7cdc6fefe6c0ffb8c47b81de1325ec6c Mon Sep 17 00:00:00 2001 From: Maynard Johnson <may...@us...> Date: Wed, 20 Apr 2011 16:05:02 -0500 Subject: [PATCH] Fix opcontrol --status to show accurate information for running daemon Signed-off-by: Maynard Johnson <may...@us...> --- utils/opcontrol | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/utils/opcontrol b/utils/opcontrol index 3a8a814..12631eb 100644 --- a/utils/opcontrol +++ b/utils/opcontrol @@ -345,6 +345,7 @@ do_init() # location for daemon setup information SETUP_DIR="/root/.oprofile" SETUP_FILE="$SETUP_DIR/daemonrc" + SEC_SETUP_FILE="$SETUP_DIR/.daemonrc" # initialize daemon vars decide_oprofile_device_mount @@ -398,6 +399,15 @@ set_event() do_save_setup() { create_dir "$SETUP_DIR" + SAVE_SETUP_FILE="$SETUP_FILE" + if test -f "$LOCK_FILE"; then +#Daemon is already running, so changes to the daemon config will be +#stored in secondary cache file so that 'opcontrol --status' will +#show actual config data for the running daemon. The next time the +#daemon is restarted, we'll reload the config data from this secondary +#cache file. + SETUP_FILE="$SEC_SETUP_FILE" + fi touch $SETUP_FILE chmod 644 $SETUP_FILE @@ -441,12 +451,25 @@ do_save_setup() if test "$XEN_RANGE"; then echo "XEN_RANGE=$XEN_RANGE" >> $SETUP_FILE fi + SETUP_FILE="$SAVE_SETUP_FILE" } # reload all the setup-related information do_load_setup() { +#If a secondary setup file exists and the daemon is not running, +#then we'll move the data from the secondary file to the actual +#setup file to prepare for daemon startup. + if test -z "$SESSION_DIR"; then + __TMP_SESSION_DIR="/var/lib/oprofile" + else + __TMP_SESSION_DIR="$SESSION_DIR" + fi + + if test -f "$SEC_SETUP_FILE" -a ! -f "$__TMP_SESSION_DIR/lock"; then + mv $SEC_SETUP_FILE $SETUP_FILE + fi if test -f "$SETUP_FILE"; then # load the actual information from file # FIXME this is insecure, arbitrary commands could be added to -- 1.6.2.rc2 |