Skip to content

Instantly share code, notes, and snippets.

@kkumar-fk
kkumar-fk / VM_devices.txt
Created November 29, 2021 13:40
List of devices in a VM with teaming and SR-IOV passthrough
4: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
inet 192.168.12.53/24 brd 192.168.12.255 scope global dynamic ens10
valid_lft 42482sec preferred_lft 42482sec
inet6 fe80::97d8:db2:8c10:b6d6/64 scope link
valid_lft forever preferred_lft forever
5: ens10nsby: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master ens10 state DOWN group default qlen 1000
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
7: ens11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens10 state UP group default qlen 1000
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
@kkumar-fk
kkumar-fk / vf.xml
Created November 29, 2021 13:41
VF configuration file used by migration script on the source hypervisor
# cat vf.xml
<interface type='hostdev' managed='yes'>
<mac address='52:54:00:00:12:53'/>
<source>
<address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
</source>
<teaming type='transient' persistent='ua-backup0'/>
</interface>
@kkumar-fk
kkumar-fk / migrate_source.sh
Created November 29, 2021 13:42
Migration script to run on the source hypervisor
#!/bin/bash
DOMAIN=vm-01
PF=ens6np0
VF=ens6v1 # VF attached to the bridge.
VF_NUM=1
TAP_IF=vmtap01 # virtio-net interface in the VM.
VF_XML=vf.xml
MAC=52:54:00:00:12:53
@kkumar-fk
kkumar-fk / reattach_vf.sh
Created November 29, 2021 13:44
Script to run on destination hypervisor to reattach a VF to the migrated VM
#!/bin/bash
bridge fdb del 52:54:00:00:12:53 dev ens36v0
bridge fdb del 52:54:00:00:12:53 dev vmtap01 master
virsh attach-device --config --live vm01 vf.xml
virsh domif-setlink vm01 vmtap01 down
@kkumar-fk
kkumar-fk / crypto_summary.sh
Last active February 11, 2022 03:40
Script to calculate your crypto balance, as well as give (50) historical values. Historical values help in deciding whether to invest or not.
#!/bin/bash
# Number of units of each cryptocurrency.
u_bc=0.73674311
u_eth=0.75795629
u_rip=251.065810
# Get prices of each from https://api.coingecko.com/api/v3/coins/list
bc=`curl "https://api.coingecko.com/api/v3/coins/markets?vs_currency=inr&ids=bitcoin" 2> /dev/null | jq . | grep current_price | awk '{print $NF}' | cut -d, -f1 &`
eth=`curl "https://api.coingecko.com/api/v3/coins/markets?vs_currency=inr&ids=ethereum" 2> /dev/null | jq . | grep current_price | awk '{print $NF}' | cut -d, -f1 &`