From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th2lM-0002tl-EB for qemu-devel@nongnu.org; Fri, 07 Dec 2012 13:35:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Th2lJ-0006JN-M8 for qemu-devel@nongnu.org; Fri, 07 Dec 2012 13:35:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th2lJ-0006Hq-EF for qemu-devel@nongnu.org; Fri, 07 Dec 2012 13:35:01 -0500 Message-ID: <50C236CA.5050801@redhat.com> Date: Fri, 07 Dec 2012 11:34:50 -0700 From: Eric Blake MIME-Version: 1.0 References: <20121207083922.10624.97583.stgit@melchior2.sdl.hitachi.co.jp> <20121207083932.10624.8173.stgit@melchior2.sdl.hitachi.co.jp> In-Reply-To: <20121207083932.10624.8173.stgit@melchior2.sdl.hitachi.co.jp> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig185714412FA94693F75F04F2" Subject: Re: [Qemu-devel] [PATCH v7 2/2] qemu-ga: sample fsfreeze hooks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tomoki Sekiyama Cc: lcapitulino@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig185714412FA94693F75F04F2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/07/2012 01:39 AM, Tomoki Sekiyama wrote: > Adds sample hook scripts for --fsfreeze-hook option of qemu-ga. > - fsfreeze-hook : execute scripts in fsfreeze-hook.d/ > - fsfreeze-hook.d/mysql-flush.sh.sample : quiesce MySQL before snapsh= ot >=20 > Signed-off-by: Tomoki Sekiyama > --- > @@ -0,0 +1,33 @@ > +#!/bin/sh > + > +# This script is executed when a guest agent receives fsfreeze-freeze = and > +# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F) > +# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook= ). > +# When the agent receives fsfreeze-freeze request, this script is issu= ed with > +# "freeze" argument before the filesystem is freezed. And for fsfreeze= -thaw s/freezed/frozen/ > + > +# Iterate executables in directory "fsfreeze-hook.d" with the specifie= d args > +[ ! -d "$FSFREEZE_D" ] && exit 1 Do you really want to fail the entire operation if the directory doesn't exist? Shouldn't you instead exit 0 because there is nothing to do? > +for file in "$FSFREEZE_D"/* ; do > + is_ignored_file "$file" && continue > + [ -x "$file" ] || continue > + echo "$(date): execute $file $@" >>$LOGFILE This is unsafe (although the worst that will happen is a poor message to the log file). $file might contain backslash, and echo cannot portably be mixed with backslash. Use printf(1) instead. > + "$file" "$@" >>$LOGFILE 2>&1 > + STATUS=3D$? > + echo "$(date): $file finished with status=3D$STATUS" >>$LOGFILE Again. > @@ -0,0 +1,55 @@ > +#!/bin/sh > + > +# Flush MySQL tables to the disk before the filesystem is freezed. s/freezed/frozen/ > +# At the same time, this keeps a read lock in order to avoid write acc= esses > +# from the other clients until the filesystem is thawed. > + > +MYSQL=3D"/usr/bin/mysql" > +MYSQL_OPTS=3D"-uroot" #"-prootpassword" > +FIFO=3D/tmp/mysql-flush.fifo > +MYSQL_CMD=3D"$MYSQL $MYSQL_OPTS" > + > +# Check mysql is installed and the server running > +[ -x $MYSQL ] && $MYSQL_CMD < /dev/null || exit 0 Safe as written, since you just initialized $MYSQL above; but risky, since the mere use of MYSQL in the initialization might encourage someone to point to an alternate path that includes spaces. Then again, if they do that, then MYSQL_CMD is broken. It might be better to be explicit and write [ -x "$MYSQL" ] && "$MYSQL" $MYSQL_OPTS < /dev/null but I won't insist. > + # for InnoDB, wait until every log is flushed > + INNODB_STATUS=3D$(mktemp /tmp/mysql-flush.XXXXXX) > + [ $? -ne 0 ] && exit 2 > + trap "rm -f $INNODB_STATUS" SIGINT POSIX says that 'trap foo INT' is required to work, but 'trap foo SIGINT' is optional. Also, shouldn't you also worry about HUP, ALRM, and TERM? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig185714412FA94693F75F04F2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBCAAGBQJQwjbKAAoJEKeha0olJ0NqZroH/3SkqdD84MI0HI2otNSUDDTx j+YytMUbCYWVUxhFYciPTPRhWuoGI/xc3WX25UQ2c+VXFE/ocfhQFMGiHw4RDvqD EYWqAaab13hSLILTln8El84nMpqaMUDBmBQjbsBn9avIe786RMYRhkFTcGvQ/5iu 4O7g7kewfDsXzI7b1HD4UEHSCVDK+wMbfM2HF3IvQeM2N+o2O4Wo0E0XwKXisQNF K6A/KpB/tP5zFf+fHTG9UiLVd3ybgEvHWc8jzScUar0wmn7R4TDnqqBcnR/ojiIT VLkVzu+cTRzdPyhA4bULqvhhqxtfF8Z+3zSo5jU6yTFjg/a7JoS/XBQq0IC3byw= =RFQH -----END PGP SIGNATURE----- --------------enig185714412FA94693F75F04F2--