summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@cea.fr>2020-07-14 16:44:41 +0200
committerDominique Martinet <dominique.martinet@cea.fr>2020-07-14 17:01:13 +0200
commit7461a95f67796b1dcb0b3abec154ed149782dae6 (patch)
tree806793563d721c48be01d36611a79b74d45cb5cc
parentf9afbcd7d52d2cf31791aa1527039349b137f6e3 (diff)
disks: use qemu fdset instead of letting qemu open device directlyasmadeus
-rwxr-xr-xkvm-wrapper.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 5028921..da37baf 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -773,7 +773,14 @@ function kvm_start_vm_prep ()
KVM_DISK_IF[0]=${KVM_DISK_IF[0]-$KVM_DRIVE_IF}
for i in ${!KVM_DISK[@]}; do
- KVM_EXEC_CMD+=( -drive "if=none,id=disk${i},file=${KVM_DISK[i]}${KVM_DISK_OPT[i]-${KVM_DISK_OPT[@]:0:1}}" -device "${KVM_DISK_IF[i]:-${KVM_DISK_IF[@]:0:1}},drive=disk${i}" )
+ local DISKFD DISKFD_RO
+ # seems to be a bug, we need to add the file twice (ro mode as well) apparently
+ # because format probe needs ro mode even if we force format=raw,media=disk...
+ exec {DISKFD}<>"${KVM_DISK[i]}"
+ exec {DISKFD_RO}<"${KVM_DISK[i]}"
+ KVM_EXEC_CMD+=( -add-fd "fd=${DISKFD},set=${DISKFD},opaque=rdwr:${KVM_DISK[0]}" )
+ KVM_EXEC_CMD+=( -add-fd "fd=${DISKFD_RO},set=${DISKFD},opaque=ro:${KVM_DISK[0]}" )
+ KVM_EXEC_CMD+=( -drive "if=none,id=disk${i},file=/dev/fdset/${DISKFD}${KVM_DISK_OPT[i]-${KVM_DISK_OPT[@]:0:1}}" -device "${KVM_DISK_IF[i]:-${KVM_DISK_IF[@]:0:1}},drive=disk${i}" )
done
[[ -n "$KVM_CDROM" ]] && KVM_EXEC_CMD+=( -cdrom "$KVM_CDROM" )