Last active
August 17, 2022 14:11
-
-
Save silug/8c13cdfa0e50ca6e237333a79594be66 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e | |
remote="${REMOTE_HOST:?'Set REMOTE_HOST environment variable'}" | |
for guest in "$@" ; do | |
xml="$( mktemp XXXXXXXX.xml )" | |
trap "rm -fv '$xml'" EXIT | |
ssh root@"$remote" virsh dumpxml "$guest" | \ | |
xmlstarlet ed \ | |
-u '/domain/os/type[starts-with(@machine, "pc-i440fx")]/@machine' -v pc \ | |
-u '/domain/os/type[starts-with(@machine, "rhel")]/@machine' -v pc \ | |
-u '/domain/devices/video/model[@type="qxl"]/@type' -v virtio \ | |
-d '/domain/devices/video/model[@type="virtio"]/@ram' \ | |
-d '/domain/devices/video/model[@type="virtio"]/@vram' \ | |
-d '/domain/devices/video/model[@type="virtio"]/@vgamem' \ | |
-d '/domain/devices/graphics[@type="spice"]/@port' \ | |
-i '/domain/devices/graphics[@type="spice"]' -t attr -n port -v -1 \ | |
-u '/domain/devices/graphics[@type="spice"]/@type' -v vnc \ | |
-d '/domain/devices/channel[@type="spicevmc"]' \ | |
-d '/domain/devices/redirdev[@type="spicevmc"]' \ | |
> "$xml" | |
virsh define "$xml" | |
rm -fv "$xml" | |
trap - EXIT | |
virsh autostart "$guest" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment