Last active
June 15, 2019 20:53
-
-
Save kenyon/aed6cd45a137133feea6508c23d35cd3 to your computer and use it in GitHub Desktop.
get IP addresses of a VM which is running qemu-guest-agent
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
virsh --connect qemu:///system qemu-agent-command VM_NAME '{"execute":"guest-network-get-interfaces"}' | jq --raw-output '.return[] | select(.name != "lo")["ip-addresses"][] | select(."ip-address-type" == "ipv6") | select(."ip-address"|startswith("fe80")|not)."ip-address"' | |
Or, simpler: virsh --connect qemu:///system domifaddr VM_NAME --source agent | awk '$NF ~ /:/ && !/(fe80)|::1/ {print $NF}' | cut --delimiter / --fields 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment