KVM VM Start/Stop - which script to modify?

spdriver

New Member
May 25, 2010
17
1
1
dear Proxmox Team,

came across this HACK posting:
http://forum.proxmox.com/threads/5575-HACK-KVM-only-Control-order-and-delay-starting-VMs-in-proxmox


I want to add some network host routes for my KVM VMs, as I have a routed configuration with my ISP.

Which script is a good target to add this modifications?


at KVM start: add host route, then start KVM VM
at KVM stop: stop KVM VM, then delete/cleanup host route.

And it has to work with online & offline migration of KVM VM (Logical Volumes on DRBD).

(The IP(s) of KVM VM is of course activated only at one physical host at a time.
IP subnet is available to both physical hosts...)



start example: "ip route add 200.x.x.100/32 dev vmbr0" , then start VM

"200.x.x.100" ist the IP of the KVM VM, used with default gateway for the KVM VM.
"/32" is the network mask for the host route, same as "255.255.255.255"
"dev vmbr0" points to the device which is to be used for this network route/path,
the KVM VM is connected to bridge "vmbr0".

stop example: stop VM, then "ip route del 200.x.x.100"


In the meantime, I thought of writing the KVM VM IP address to the "Notes" field of the VM in the WebUI.
(The WebUI "Notes" field is the "description:" parameter inthe KVM VM config file)

The little script/extension will be able to read the value of the IP address for the "host route".
The device/bridge information can be read from the KVM VM config file, or put in the "Notes" field, too.

Any ideas, improving thoughts?

thanks,
spdriver
 
maybe '/var/lib/qemu-server/bridge-vlan'


OK for START of the KVM VM, I can add a call to my own script there.


but I am missing a point for STOP of VM where the VLAN is removed from the bridge.

i.e. when VM is migrated to other Proxmox host, I have to "destruct" the old route, to have clean network routes...
50% solved, thanks
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!