2013-02-23 00:10:48 +00:00
|
|
|
#!/bin/sh
|
2012-09-14 09:08:54 +00:00
|
|
|
# libvirt 'run' programs locally script
|
2013-02-23 00:10:48 +00:00
|
|
|
# Copyright (C) 2012-2013 Red Hat, Inc.
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
2013-02-23 00:10:48 +00:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
2013-02-23 00:10:48 +00:00
|
|
|
# This library is distributed in the hope that it will be useful,
|
2012-09-14 09:08:54 +00:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-02-23 00:10:48 +00:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
2013-02-23 00:10:48 +00:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; If not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
2012-09-14 09:08:54 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# With this script you can run libvirt programs without needing to
|
|
|
|
# install them first. You just have to do for example:
|
|
|
|
#
|
2020-01-16 17:15:42 +00:00
|
|
|
# ./run virsh [args ...]
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
2020-01-16 17:15:42 +00:00
|
|
|
# Note that this runs the locally compiled copy of virsh which
|
|
|
|
# is usually want you want.
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
|
|
|
# You can also run the C programs under valgrind like this:
|
|
|
|
#
|
|
|
|
# ./run valgrind [valgrind opts...] ./program
|
|
|
|
#
|
|
|
|
# or under gdb:
|
|
|
|
#
|
|
|
|
# ./run gdb --args ./program
|
|
|
|
#
|
|
|
|
# This also works with sudo (eg. if you need root access for libvirt):
|
|
|
|
#
|
2020-01-16 17:15:42 +00:00
|
|
|
# sudo ./run virsh list --all
|
2012-09-14 09:08:54 +00:00
|
|
|
#
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2020-01-16 17:15:41 +00:00
|
|
|
# Function to intelligently prepend a path to an environment variable.
|
2020-08-25 22:44:00 +00:00
|
|
|
# See https://stackoverflow.com/a/9631350
|
2020-01-16 17:15:41 +00:00
|
|
|
prepend()
|
|
|
|
{
|
|
|
|
eval $1="$2\${$1:+:\$$1}"
|
|
|
|
}
|
|
|
|
|
2012-09-14 09:08:54 +00:00
|
|
|
# Find this script.
|
|
|
|
b=@abs_builddir@
|
|
|
|
|
2020-05-28 00:40:50 +00:00
|
|
|
prepend LD_LIBRARY_PATH "$b/src"
|
2012-09-14 09:08:54 +00:00
|
|
|
export LD_LIBRARY_PATH
|
|
|
|
|
2020-01-16 17:15:41 +00:00
|
|
|
prepend PKG_CONFIG_PATH "$b/src"
|
2014-06-26 10:53:20 +00:00
|
|
|
export PKG_CONFIG_PATH
|
|
|
|
|
2020-01-16 17:15:42 +00:00
|
|
|
prepend PATH "$b/tools"
|
|
|
|
export PATH
|
|
|
|
|
2019-08-29 10:52:08 +00:00
|
|
|
# Ensure that any 3rd party apps using libvirt.so from the build tree get
|
|
|
|
# files resolved to the build/source tree too. Typically useful for language
|
|
|
|
# bindings running tests against non-installed libvirt.
|
|
|
|
LIBVIRT_DIR_OVERRIDE=1
|
|
|
|
export LIBVIRT_DIR_OVERRIDE
|
|
|
|
|
2012-09-14 09:08:54 +00:00
|
|
|
# This is a cheap way to find some use-after-free and uninitialized
|
|
|
|
# read problems when using glibc.
|
|
|
|
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
|
|
|
|
export MALLOC_PERTURB_=$random_val
|
|
|
|
|
|
|
|
# Run the program.
|
2020-07-01 00:52:45 +00:00
|
|
|
exec "$@"
|