Last active
November 10, 2024 13:06
-
-
Save hellt/3626a753a74e3e5a950c71e6b294543f to your computer and use it in GitHub Desktop.
Virsh interface move
This file contains hidden or 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 | |
# usage ~/vifmove.sh <virsh_domain_name/id> <interface_name> <new_bridge_name> | |
tmpxml=$(mktemp /tmp/ifcfg.XXX) | |
macaddr="$(virsh domiflist $1 | awk "/$2\s/ {print \$NF}")" | |
cat > "$tmpxml" <<EOF | |
<interface type='bridge'> | |
<mac address='$macaddr'/> | |
<source bridge='$3'/> | |
<model type='virtio'/> | |
</interface> | |
EOF | |
virsh update-device "$1" "$tmpxml" --live --persistent | |
rm "$tmpxml" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A version which finds the
<virsh_domain_name/id>
automatically: