From 36c2129783f7c6e57ca4e1ee21f07852eca86db5 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 14 Jul 2020 16:43:24 +0200 Subject: bootstrap: restore nbd functionality for qcow image --- kvm-wrapper.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh index 15dc8da..5f86cd3 100755 --- a/kvm-wrapper.sh +++ b/kvm-wrapper.sh @@ -1171,18 +1171,18 @@ function kvm_bootstrap_vm () prepare_disks CLEANUP+=("unprepare_disks") -# if ! test_blockdev "${KVM_DISK[0]}" -# then -# require_exec "$KVM_NBD_BIN" -# test_file "${KVM_DISK[0]}" || fail_exit "\"${KVM_DISK[0]}\" appears to be neither a blockdev nor a regular file." -# echo "Attempting to connect the disk image to an nbd device." -# kvm_nbd_connect "${KVM_DISK[0]}" -# CLEANUP+=("kvm_nbd_disconnect \"${KVM_DISK[0]}\"") -# local BOOTSTRAP_DEVICE=$(nbd_img_link "${KVM_DISK[0]}") -# sleep 1 #needed to give time to the nbd to really connect -# else + if ! test_blockdev "${KVM_DISK[0]}" + then + require_exec "$KVM_NBD_BIN" + test_file "${KVM_DISK[0]}" || fail_exit "\"${KVM_DISK[0]}\" appears to be neither a blockdev nor a regular file." + echo "Attempting to connect the disk image to an nbd device." + kvm_nbd_connect "${KVM_DISK[0]}" + CLEANUP+=("kvm_nbd_disconnect \"${KVM_DISK[0]}\"") + local BOOTSTRAP_DEVICE=$(nbd_img_link "${KVM_DISK[0]}") + sleep 1 #needed to give time to the nbd to really connect + else local BOOTSTRAP_DEVICE="${KVM_DISK[0]}" -# fi + fi echo "Starting to bootstrap $VM_NAME as $BOOTSTRAP_DISTRIB on disk $BOOTSTRAP_DEVICE" bootstrap_fs "$BOOTSTRAP_DEVICE" -- cgit v1.2.3-70-g09d2