-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refresh vmm/(pre)reconfigure patches
Change-Id: I3d35c2bfe91cf199809ac31b40bd37a758d87b77
- Loading branch information
1 parent
b147c5c
commit d8cda08
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- remotes/vmm/kvm/prereconfigure.~2~ 2022-02-22 18:47:17.649648643 +0200 | ||
+++ remotes/vmm/kvm/prereconfigure 2022-02-22 18:54:59.407952982 +0200 | ||
@@ -24,7 +24,42 @@ | ||
|
||
if [[ -n "$DOMAIN" ]] && [[ -n "$TARGET_DEVICE" ]] | ||
then | ||
- DISK="$(virsh --connect $LIBVIRT_URI domblklist $DOMAIN | awk "/^\s*$TARGET_DEVICE/ {print \$2; exit}")" | ||
+ qemu_json=$(virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-version"}') | ||
+ qemu_version_arr=($(echo "$qemu_json"|jq -r '.return|(.qemu.major|tostring)+" "+(.qemu.minor|tostring)+" "+(.qemu.micro|tostring)+" "+.package')) | ||
+ qemu_version_int=$((qemu_version_arr[0]*10000 + qemu_version_arr[1]*100 + qemu_version_arr[2])) | ||
+ logger -t "vmm_sp_pre" -- "${qemu_version_arr[3]} ($qemu_version_int) libvirt:$(virsh --version)" | ||
+ | ||
+ DISK="$(virsh --connect $LIBVIRT_URI domblklist $DOMAIN | awk "/^\s*$TARGET_DEVICE/ {print \$2; exit}")" | ||
+ | ||
+ while read -u ${fdh} qdev tray_open inserted_file locked; do | ||
+ logger -t "vmm_sp_pre" -- "$qdev locked:$locked tray_open:$tray_open file:$inserted_file //loop" | ||
+ if [ "${inserted_file##*/}" == "${DISK##*/}" ]; then | ||
+ QDEV="$qdev" | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"eject\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_pre" -- "qemu-monitor-command $DOMAIN --cmd '{\"execute\":\"eject\",\"arguments\":{\"id\":\"$qdev\"}}' ($?)" | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_pre" -- "qemu-monitor-command $DOMAIN --cmd {\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}} ($?)" | ||
+ devid=$qdev | ||
+ fi | ||
+ if [ "$inserted_file" == "null" ] && [ "$tray_open" == "false" ]; then | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_pre" -- "qemu-monitor-command $DOMAIN --cmd {\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}} ($?) tray_open" | ||
+ devid=$qdev | ||
+ fi | ||
+ done {fdh}< <(virsh --connect $LIBVIRT_URI \ | ||
+ qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r '.return[]|select(.removable)|.qdev+" "+(.tray_open|tostring)+" "+(.inserted.file|tostring)+" "+(.locked|tostring)' || true) | ||
+ cnt=0 | ||
+ [ -z "$devid" ] || while : ; do | ||
+ tray_open=$(virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r --arg qdev "$devid" '.return[]|select(.qdev==$qdev)|.tray_open') | ||
+ logger -t "vmm_sp_pre" -- "$devid tray_open:$tray_open //wait $((cnt*100))ms" | ||
+ cnt=$((cnt + 1)) | ||
+ if [ "$tray_open" == "true" ] || [ $cnt -gt 20 ]; then | ||
+ break | ||
+ fi | ||
+ sleep 0.1 | ||
+ done | ||
if [[ "$DISK" = "-" ]]; then | ||
log_debug "CDROM already ejected" | ||
exit 0 | ||
@@ -33,6 +68,12 @@ | ||
CMD="virsh --connect $LIBVIRT_URI change-media $DOMAIN $TARGET_DEVICE \ | ||
--eject --force" | ||
|
||
+ logger -t "vmm_sp_pre" -- "$CMD # DISK:$DISK" | ||
exec_and_log "$CMD" "Could not eject CDROM $TARGET_DEVICE" | ||
fi | ||
|
||
+while read -u ${fdh} q t f l; do | ||
+ logger -t "vmm_sp_pre" -- "$q locked:$l tray_open:$t file:$f //END" | ||
+done {fdh}< <(virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r '.return[]|select(.removable)|.qdev+" "+(.tray_open|tostring)+" "+(.inserted.file|tostring)+" "+(.locked|tostring)') | ||
+ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff -ur remotes.orig/vmm/kvm/reconfigure remotes/vmm/kvm/reconfigure | ||
--- remotes.orig/vmm/kvm/reconfigure 2024-11-06 19:34:11.000000000 +0200 | ||
+++ remotes/vmm/kvm/reconfigure 2024-11-07 16:27:23.855972531 +0200 | ||
@@ -25,10 +25,45 @@ | ||
|
||
if [[ -n "$DOMAIN" ]] && [[ -n "$TARGET_DEVICE" ]] && [[ -n "$ISO_PATH" ]] | ||
then | ||
+ while read -u ${fdh} qdev tray_open inserted_file locked; do | ||
+ logger -t "vmm_sp_rec" -- "$qdev locked:$locked tray_open:$tray_open file:$inserted_file //loop" | ||
+ if [ "${inserted_file##*/}" == "${ISO_PATH##*/}" ]; then | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"eject\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_rec" -- "qemu-monitor-command $DOMAIN --cmd '{\"execute\":\"eject\",\"arguments\":{\"id\":\"$qdev\"}}' ($?)" | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_rec" -- "qemu-monitor-command $DOMAIN --cmd {\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}} ($?)" | ||
+ devid="$qdev" | ||
+ fi | ||
+ if [ "$inserted_file" == "null" ] && [ "$tray_open" == "false" ]; then | ||
+ virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd "{\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}}" | ||
+ logger -t "vmm_sp_rec" -- "qemu-monitor-command $DOMAIN --cmd {\"execute\":\"blockdev-open-tray\",\"arguments\":{\"id\":\"$qdev\"}} ($?)" | ||
+ devid="$qdev" | ||
+ fi | ||
+ done {fdh}< <(virsh --connect $LIBVIRT_URI \ | ||
+ qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r '.return[]|select(.removable)|.qdev+" "+(.tray_open|tostring)+" "+(.inserted.file|tostring)+" "+(.locked|tostring)' || true) | ||
+ | ||
+ cnt=0 | ||
+ [ -z "$devid" ] || while : ; do | ||
+ tray_open=$(virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r --arg qdev "$devid" '.return[]|select(.qdev==$qdev)|.tray_open') | ||
+ logger -t "vmm_sp_rec" -- "$devid tray_open:$tray_open //wait $((cnt*100))ms" | ||
+ cnt=$((cnt + 1)) | ||
+ if [ "$tray_open" == "true" ] || [ $cnt -gt 20 ]; then | ||
+ break | ||
+ fi | ||
+ sleep 0.1 | ||
+ done | ||
+ | ||
test -b "$ISO_PATH" && EXTRA_ARGS="--block" || EXTRA_ARGS="" | ||
CMD="virsh --connect $LIBVIRT_URI \ | ||
change-media $DOMAIN $TARGET_DEVICE $ISO_PATH --insert $EXTRA_ARGS" | ||
|
||
exec_and_log "$CMD" "Could not insert CDROM $ISO_PATH to $TARGET_DEVICE" | ||
+ | ||
+ while read -u ${fdh} q t f l; do | ||
+ logger -t "vmm_sp_rec" -- "$q locked:$l tray_open:$t file:$f //END" | ||
+ done {fdh}< <(virsh --connect $LIBVIRT_URI qemu-monitor-command "$DOMAIN" --cmd '{"execute":"query-block"}' |\ | ||
+ jq -r '.return[]|select(.removable)|.qdev+" "+(.tray_open|tostring)+" "+(.inserted.file|tostring)+" "+(.locked|tostring)') | ||
fi | ||
|