Lines Matching +full:add +full:- +full:user +full:- +full:device
5 # SPDX-License-Identifier: Apache-2.0
9 CTR_IMAGE_TAG="ghcr.io/cloud-hypervisor/cloud-hypervisor"
11 # Needs to match explicit version in docker-image.yaml workflow
12 CTR_IMAGE_VERSION="20250412-0"
23 CLH_CTR_BUILD_DIR="/tmp/cloud-hypervisor/ctr-build"
27 CTR_CLH_ROOT_DIR="/cloud-hypervisor"
53 [ -t 1 ] && [ -n "$TERM" ] &&
61 [ -t 1 ] && [ -n "$TERM" ] &&
62 echo -n "$(tput setaf 2)[$CLI_NAME]$(tput sgr0) $*" ||
69 [ -t 2 ] && [ -n "$TERM" ] &&
74 # Send a warning-highlighted text to stdout
76 [ -t 1 ] && [ -n "$TERM" ] &&
82 # Usage: die [-c <error code>] <error message>
86 [[ "$1" = "-c" ]] && {
98 [[ $code -eq 0 ]] || die -c $code "$@"
111 mkdir -p "$dir" || die "Error: cannot create dir $dir"
112 [ -x "$dir" ] && [ -w "$dir" ] ||
136 # This fixes that by recursively changing the ownership of /cloud-hypervisor to the
137 # current user.
143 --workdir "$CTR_CLH_ROOT_DIR" \
144 --rm \
145 --volume /dev:/dev \
146 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
149 chown -R "$(id -u):$(id -g)" "$CTR_CLH_ROOT_DIR"
154 # Sample input: --volumes /a:/a#/b:/b
155 # Sample output: --volume /a:/a --volume /b:/b
158 if [ -z "$arg_vols" ]; then
165 if [[ ! -e "${parts[0]}" ]]; then
169 exported_volumes="$exported_volumes --volume $var"
180 echo " --local Set the container image version being used to \"local\"."
184 echo " build [--debug|--release] [--libc musl|gnu] [-- [<cargo args>]]"
186 echo " --debug Build the debug binaries. This is the default."
187 echo " --release Build the release binaries."
188 …echo " --libc Select the C library Cloud Hypervisor will be built against. D…
189 …echo " --volumes Hash separated volumes to be exported. Example --volumes /mnt:…
190 echo " --hypervisor Underlying hypervisor. Options kvm, mshv"
192 …echo " tests [<test type (see below)>] [--libc musl|gnu] [-- [<test scripts args>] [-- [<test b…
194 echo " --unit Run the unit tests."
195 echo " --integration Run the integration tests."
196 echo " --integration-sgx Run the SGX integration tests."
197 echo " --integration-vfio Run the VFIO integration tests."
198 echo " --integration-windows Run the Windows guest integration tests."
199 echo " --integration-live-migration Run the live-migration integration tests."
200 echo " --integration-rate-limiter Run the rate-limiter integration tests."
201 …echo " --libc Select the C library Cloud Hypervisor will be built aga…
202 echo " --metrics Generate performance metrics"
203 echo " --coverage Generate code coverage information"
204 …echo " --volumes Hash separated volumes to be exported. Example --volume…
205 echo " --hypervisor Underlying hypervisor. Options kvm, mshv"
206 echo " --all Run all tests."
208 echo " build-container [--type]"
216 …echo " --volumes Hash separated volumes to be exported. Example --volumes /mnt:…
229 while [ $# -gt 0 ]; do
231 "-h" | "--help") {
235 "--debug") { build="debug"; } ;;
236 "--release") { build="release"; } ;;
237 "--runtime")
242 "--libc")
248 "--volumes")
252 "--hypervisor")
256 "--features")
258 features_build=(--features "$1")
260 "--") {
265 die "Unknown build argument: $1. Please use --help for help."
281 target="$(uname -m)-unknown-linux-${libc}"
284 [ $build = "release" ] && cargo_args+=("--release")
285 cargo_args+=(--target "$target")
290 if [ "$(uname -m)" = "aarch64" ] && [ "$libc" = "musl" ]; then
291 rustflags="$rustflags -C link-args=-Wl,-Bstatic -C link-args=-lc"
295 --user "$(id -u):$(id -g)" \
296 --workdir "$CTR_CLH_ROOT_DIR" \
297 --rm \
298 --volume $exported_device \
299 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
301 --env RUSTFLAGS="$rustflags" \
302 --env TARGET_CC="$target_cc" \
304 cargo build --all "${features_build[@]}" \
305 --target-dir "$CTR_CLH_CARGO_TARGET" \
316 --user "$(id -u):$(id -g)" \
317 --workdir "$CTR_CLH_ROOT_DIR" \
318 --rm \
319 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
323 --target-dir "$CTR_CLH_CARGO_TARGET" \
341 while [ $# -gt 0 ]; do
343 "-h" | "--help") {
347 "--unit") { unit=true; } ;;
348 "--integration") { integration=true; } ;;
349 "--integration-sgx") { integration_sgx=true; } ;;
350 "--integration-vfio") { integration_vfio=true; } ;;
351 "--integration-windows") { integration_windows=true; } ;;
352 "--integration-live-migration") { integration_live_migration=true; } ;;
353 "--integration-rate-limiter") { integration_rate_limiter=true; } ;;
354 "--metrics") { metrics=true; } ;;
355 "--coverage") { coverage=true; } ;;
356 "--libc")
362 "--volumes")
366 "--hypervisor")
370 "--all") {
374 "--") {
379 die "Unknown tests argument: $1. Please use --help for help."
392 if [ ! -e "${exported_device}" ]; then
396 set -- '--hypervisor' "$hypervisor" "$@"
402 target="$(uname -m)-unknown-linux-${libc}"
406 if [ "$(uname -m)" = "aarch64" ] && [ "$libc" = "musl" ]; then
407 rustflags="$rustflags -C link-args=-Wl,-Bstatic -C link-args=-lc"
413 --workdir "$CTR_CLH_ROOT_DIR" \
414 --rm \
415 --device $exported_device \
416 --device /dev/net/tun \
417 --cap-add net_admin \
418 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
420 --env BUILD_TARGET="$target" \
421 --env RUSTFLAGS="$rustflags" \
422 --env TARGET_CC="$target_cc" \
423 --env LLVM_PROFILE_FILE="$LLVM_PROFILE_FILE" \
431 --workdir "$CTR_CLH_ROOT_DIR" \
432 --rm \
433 --privileged \
434 --security-opt seccomp=unconfined \
435 --ipc=host \
436 --net="$CTR_CLH_NET" \
437 --mount type=tmpfs,destination=/tmp \
438 --volume /dev:/dev \
439 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
441 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
442 --env USER="root" \
443 --env BUILD_TARGET="$target" \
444 --env RUSTFLAGS="$rustflags" \
445 --env TARGET_CC="$target_cc" \
446 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
447 --env LLVM_PROFILE_FILE="$LLVM_PROFILE_FILE" \
449 …dbus-run-session ./scripts/run_integration_tests_"$(uname -m)".sh "$@" || fix_dir_perms $? || exit…
455 --workdir "$CTR_CLH_ROOT_DIR" \
456 --rm \
457 --privileged \
458 --security-opt seccomp=unconfined \
459 --ipc=host \
460 --net="$CTR_CLH_NET" \
461 --mount type=tmpfs,destination=/tmp \
462 --volume /dev:/dev \
463 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
465 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
466 --env USER="root" \
467 --env BUILD_TARGET="$target" \
468 --env RUSTFLAGS="$rustflags" \
469 --env TARGET_CC="$target_cc" \
470 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
478 --workdir "$CTR_CLH_ROOT_DIR" \
479 --rm \
480 --privileged \
481 --security-opt seccomp=unconfined \
482 --ipc=host \
483 --net="$CTR_CLH_NET" \
484 --mount type=tmpfs,destination=/tmp \
485 --volume /dev:/dev \
486 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
488 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
489 --env USER="root" \
490 --env BUILD_TARGET="$target" \
491 --env RUSTFLAGS="$rustflags" \
492 --env TARGET_CC="$target_cc" \
493 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
501 --workdir "$CTR_CLH_ROOT_DIR" \
502 --rm \
503 --privileged \
504 --security-opt seccomp=unconfined \
505 --ipc=host \
506 --net="$CTR_CLH_NET" \
507 --mount type=tmpfs,destination=/tmp \
508 --volume /dev:/dev \
509 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
511 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
512 --env USER="root" \
513 --env BUILD_TARGET="$target" \
514 --env RUSTFLAGS="$rustflags" \
515 --env TARGET_CC="$target_cc" \
516 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
518 … ./scripts/run_integration_tests_windows_"$(uname -m)".sh "$@" || fix_dir_perms $? || exit $?
524 --workdir "$CTR_CLH_ROOT_DIR" \
525 --rm \
526 --privileged \
527 --security-opt seccomp=unconfined \
528 --ipc=host \
529 --net="$CTR_CLH_NET" \
530 --mount type=tmpfs,destination=/tmp \
531 --volume /dev:/dev \
532 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
534 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
535 --env USER="root" \
536 --env BUILD_TARGET="$target" \
537 --env RUSTFLAGS="$rustflags" \
538 --env TARGET_CC="$target_cc" \
539 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
540 --env LLVM_PROFILE_FILE="$LLVM_PROFILE_FILE" \
548 --workdir "$CTR_CLH_ROOT_DIR" \
549 --rm \
550 --privileged \
551 --security-opt seccomp=unconfined \
552 --ipc=host \
553 --net="$CTR_CLH_NET" \
554 --mount type=tmpfs,destination=/tmp \
555 --volume /dev:/dev \
556 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
558 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
559 --env USER="root" \
560 --env BUILD_TARGET="$target" \
561 --env RUSTFLAGS="$rustflags" \
562 --env TARGET_CC="$target_cc" \
563 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
571 --workdir "$CTR_CLH_ROOT_DIR" \
572 --rm \
573 --privileged \
574 --security-opt seccomp=unconfined \
575 --ipc=host \
576 --net="$CTR_CLH_NET" \
577 --mount type=tmpfs,destination=/tmp \
578 --volume /dev:/dev \
579 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
581 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
582 --env USER="root" \
583 --env BUILD_TARGET="$target" \
584 --env RUSTFLAGS="$rustflags" \
585 --env TARGET_CC="$target_cc" \
586 --env RUST_BACKTRACE="${RUST_BACKTRACE}" \
587 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
595 --workdir "$CTR_CLH_ROOT_DIR" \
596 --rm \
597 --privileged \
598 --security-opt seccomp=unconfined \
599 --ipc=host \
600 --net="$CTR_CLH_NET" \
601 --mount type=tmpfs,destination=/tmp \
602 --volume /dev:/dev \
603 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
605 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
606 --env USER="root" \
607 --env BUILD_TARGET="$target" \
608 --env RUSTFLAGS="$rustflags" \
609 --env TARGET_CC="$target_cc" \
610 --env AUTH_DOWNLOAD_TOKEN="$AUTH_DOWNLOAD_TOKEN" \
612 dbus-run-session ./scripts/run_coverage.sh "$@" || fix_dir_perms $? || exit $?
621 BUILD_DIR=/tmp/cloud-hypervisor/container/
623 mkdir -p $BUILD_DIR
626 [ "$(uname -m)" = "aarch64" ] && TARGETARCH="arm64"
627 [ "$(uname -m)" = "x86_64" ] && TARGETARCH="amd64"
630 --target dev \
631 -t "$CTR_IMAGE" \
632 -f $BUILD_DIR/Dockerfile \
633 --build-arg TARGETARCH="$TARGETARCH" \
637 cmd_build-container() {
638 while [ $# -gt 0 ]; do
640 "-h" | "--help") {
644 "--") {
649 die "Unknown build-container argument: $1. Please use --help for help."
659 while [ $# -gt 0 ]; do
661 "-h" | "--help") {
665 "--volumes")
669 "--") {
682 …say_warn "WARNING: Your $CLH_ROOT_DIR folder will be bind-mounted in the container under $CTR_CLH_…
684 -ti \
685 --workdir "$CTR_CLH_ROOT_DIR" \
686 --rm \
687 --privileged \
688 --security-opt seccomp=unconfined \
689 --ipc=host \
690 --net="$CTR_CLH_NET" \
691 --tmpfs /tmp:exec \
692 --volume /dev:/dev \
693 --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
695 --volume "$CLH_INTEGRATION_WORKLOADS:$CTR_CLH_INTEGRATION_WORKLOADS" \
696 --env USER="root" \
697 --entrypoint bash \
711 while [ $# -gt 0 ]; do
713 -h | --help) {
717 --local) {
721 -*)
734 declare -f "cmd_$1" >/dev/null