Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
scripts: Run QEMU as normal user
Browse files Browse the repository at this point in the history
To run QEMU as normal user, we store the files in the appropriate
user directory (if available).

Signed-off-by: George Hopkins <[email protected]>
  • Loading branch information
george-hopkins committed Jul 28, 2022
1 parent 6d046f4 commit 622e6be
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions scripts/qemu-guest
Original file line number Diff line number Diff line change
Expand Up @@ -353,29 +353,16 @@ _netdev_hwaddr()
$(( $HWADDR % 256 ))
}

##
## ARE WE ROOT?
##
if [ $( id -u ) != 0 ]; then
if [ -x $( which sudo ) ]; then
echo "Trying to get root privileges..." 1>&2
exec sudo "$0" "$@"
exit 2
fi

echo "Please run as root" 1>&2
exit 1
fi

##
## MAIN
##
QEMU_BASE_ARGS=()
QEMU_ARGS=()
QEMU_PID=
SOCK_MONITOR="/run/$( basename "$0" )-$$_monitor.socket"
SOCK_SERIAL="/run/$( basename "$0" )-$$_serial.socket"
PIDFILE="/run/$( basename "$0" )-$$_qemu.pid"
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run}"
SOCK_MONITOR="$RUNTIME_DIR/$( basename "$0" )-$$_monitor.socket"
SOCK_SERIAL="$RUNTIME_DIR/$( basename "$0" )-$$_serial.socket"
PIDFILE="$RUNTIME_DIR/$( basename "$0" )-$$_qemu.pid"
TEMP="/tmp/$( basename "$0" )-$$"

ARG_MACHINETYPE="x86pc"
Expand Down

0 comments on commit 622e6be

Please sign in to comment.