#ubuntu hyperv bash kvp
Explore tagged Tumblr posts
whatwillilearntoday · 4 years ago
Text
Guest to Host Hyper-V KVP exchange from Ubuntu 18.04 using Bash
There is a magical way to communicate with VMs from Hyper-V. You can send 512 bytes worth of a key and 2048 byte long value. To learn more about this, here’s a good resource: https://www.altaro.com/hyper-v/key-value-pair-data-exchange-3-linux/. Oddly, there is no example on the internet (that I could find) of a how to write the key from the VM using bash. So I had to make my own. This is the bash script I used to write the KVP from inside the guest: 
#!/bin/bash filename="/var/lib/hyperv/.kvp_pool_1" echo -n key11 > $filename let N=512-5-1 for c in `seq 0 $N`; do echo -ne "\0" >> $filename done echo -n value11 >> $filename let N=2048-7-1 for c in `seq 0 $N`; do echo -ne "\0" >> $filename done
3 notes · View notes