mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
libvirt_recover_xattrs: Add unsafe operation mode
In some cases you want to fix a certain directory while you don't really care whether there are other VMs running. Add a option to disable the check. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5377177f80
commit
ea6bc0557d
@ -7,7 +7,7 @@ function die {
|
||||
|
||||
function show_help {
|
||||
cat << EOF
|
||||
Usage: ${0##*/} -[hqn] [PATH]
|
||||
Usage: ${0##*/} -[hqnu] [PATH]
|
||||
|
||||
Clear out any XATTRs set by libvirt on all files that have them.
|
||||
The idea is to reset refcounting, should it break.
|
||||
@ -15,6 +15,7 @@ The idea is to reset refcounting, should it break.
|
||||
-h display this help and exit
|
||||
-q quiet (don't print which files are being fixed)
|
||||
-n dry run; don't remove any XATTR just report the file name
|
||||
-u unsafe; don't check whether there are running VMs; PATH must be specified
|
||||
|
||||
PATH can be specified to refine search to only to given path
|
||||
instead of whole root ('/'), which is the default.
|
||||
@ -23,6 +24,7 @@ EOF
|
||||
|
||||
QUIET=0
|
||||
DRY_RUN=0
|
||||
UNSAFE=0
|
||||
DIR="/"
|
||||
|
||||
# So far only qemu and lxc drivers use security driver.
|
||||
@ -33,7 +35,7 @@ if [ $(whoami) != "root" ]; then
|
||||
die "Must be run as root"
|
||||
fi
|
||||
|
||||
while getopts hqn opt; do
|
||||
while getopts hqnu opt; do
|
||||
case $opt in
|
||||
h)
|
||||
show_help
|
||||
@ -45,6 +47,9 @@ while getopts hqn opt; do
|
||||
n)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
u)
|
||||
UNSAFE=1
|
||||
;;
|
||||
*)
|
||||
show_help >&2
|
||||
exit 1
|
||||
@ -55,6 +60,10 @@ done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -gt 0 ]; then
|
||||
DIR=$1
|
||||
else
|
||||
if [ ${UNSAFE} -eq 1 ]; then
|
||||
die "Unsafe mode (-u) requires explicit 'PATH' argument"
|
||||
fi
|
||||
fi
|
||||
|
||||
case $(uname -s) in
|
||||
@ -72,7 +81,7 @@ case $(uname -s) in
|
||||
esac
|
||||
|
||||
|
||||
if [ ${DRY_RUN} -eq 0 ]; then
|
||||
if [ ${DRY_RUN} -eq 0 ] && [ ${UNSAFE} -eq 0 ]; then
|
||||
for u in ${URI[*]} ; do
|
||||
if [ -n "`virsh -q -c $u list 2>/dev/null`" ]; then
|
||||
die "There are still some domains running for $u"
|
||||
|
Loading…
x
Reference in New Issue
Block a user