From b339aa6b885cb89880fadc1e2650c75f91565d1c Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Mon, 11 Jan 2021 15:09:02 -0800 Subject: [PATCH] scripts: Export devices(/dev/kvm or /dev/mshv) based on hypervisor Signed-off-by: Muminul Islam --- scripts/dev_cli.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/dev_cli.sh b/scripts/dev_cli.sh index df6f67a34..3188ffe44 100755 --- a/scripts/dev_cli.sh +++ b/scripts/dev_cli.sh @@ -208,7 +208,7 @@ cmd_build() { libc="gnu" hypervisor="kvm" features_build="" - + exported_device="/dev/kvm" while [ $# -gt 0 ]; do case "$1" in "-h"|"--help") { cmd_help; exit 1; } ;; @@ -245,7 +245,9 @@ cmd_build() { if [[ "$hypervisor" != "kvm" ]]; then die "Hypervisor value must be kvm" fi - + if [[ "$hypervisor" = "mshv" ]]; then + exported_device="/dev/mshv" + fi target="$(uname -m)-unknown-linux-${libc}" cargo_args=("$@") @@ -263,7 +265,7 @@ cmd_build() { --user "$(id -u):$(id -g)" \ --workdir "$CTR_CLH_ROOT_DIR" \ --rm \ - --volume /dev:/dev \ + --volume $exported_device \ --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" $exported_volumes \ --env RUSTFLAGS="$rustflags" \ "$CTR_IMAGE" \ @@ -300,6 +302,7 @@ cmd_tests() { libc="gnu" arg_vols="" hypervisor="kvm" + exported_device="/dev/kvm" while [ $# -gt 0 ]; do case "$1" in "-h"|"--help") { cmd_help; exit 1; } ;; @@ -333,6 +336,9 @@ cmd_tests() { if [[ "$hypervisor" != "kvm" ]]; then die "Hypervisor value must be kvm" fi + if [[ "$hypervisor" = "mshv" ]]; then + exported_device="/dev/mshv" + fi set -- "$@" '--hypervisor' $hypervisor ensure_build_dir @@ -354,7 +360,7 @@ cmd_tests() { $DOCKER_RUNTIME run \ --workdir "$CTR_CLH_ROOT_DIR" \ --rm \ - --device /dev/kvm \ + --device $exported_device \ --device /dev/net/tun \ --cap-add net_admin \ --volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" $exported_volumes \