Add option to pass in a nice option to the bitbake command

OpenBMC CI infrastructure has compute nodes that both run
bitbake and run QEMU CI sessions. QEMU only uses a single
core but it is very CPU dependent and so timeouts and
other issues can occur when competing with a bitbake
build. Adding a nice option for the bitbake operations
will allow us to ensure the QEMU session (or anything
else of priority on the shared compute node) gets priority

Signed-off-by: Michael Shepos <shepos@us.ibm.com>
Change-Id: Ide62d4cc7cd984f490bcae7f86eba6a645182b65
diff --git a/build-setup.sh b/build-setup.sh
index 283dffa..5e02f50 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -38,6 +38,12 @@
 #                     Default: "qemu"
 #  no_tar             Set to true if you do not want the debug tar built
 #                     Default: "false"
+#  nice_priority      Set nice priotity for bitbake command.
+#                     Nice:
+#                       Run with an adjusted niceness, which affects process
+#                       scheduling. Nice values range from -20 (most favorable
+#                       to the process) to 19 (least favorable to the process).
+#                     Default: "", nice is not used if nice_priority is not set
 #
 # Deployment Variables:
 #  obmc_dir           Path of the OpenBMC repo directory used as a reference
@@ -74,6 +80,7 @@
 img_tag=${img_tag:-latest}
 target=${target:-qemu}
 no_tar=${no_tar:-false}
+nice_priority=${nice_priority:-}
 
 # Deployment variables
 obmc_dir=${obmc_dir:-${WORKSPACE}/openbmc}
@@ -341,7 +348,11 @@
 EOF_CONF
 
 # Kick off a build
-bitbake ${BITBAKE_OPTS} ${bitbake_image}
+if [[ -n "${nice_priority}" ]]; then
+    nice -${nice_priority} bitbake ${BITBAKE_OPTS} ${bitbake_image}
+else
+    bitbake ${BITBAKE_OPTS} ${bitbake_image}
+fi
 
 # Copy internal build directory into xtrct_path directory
 if [[ ${xtrct_small_copy_dir} ]]; then
@@ -379,6 +390,7 @@
 # Run the Docker container, execute the build.sh script
 docker run \
 --cap-add=sys_admin \
+--cap-add=sys_nice \
 --net=host \
 --rm=true \
 -e WORKSPACE=${WORKSPACE} \