Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using KVM (through libvirt actually) for a research project. We're live-migrating a virtual machine between different subnets, so after the migration the IP address and routing tables have to be updated, else the VM is unreachable in it's new subnet. The goal is to do this as fast as possible.

Currently I'm using ssh over a link-local IPv6 address to connect to the VM after the live migration. Then it runs a script that assigns the new IP address and gateway. But this adds a lot of unnecessary overhead.

What I'd like to have is a way for a daemon on the virtual machine to detect that a live migration just finished. Are there any hooks I can use?

share|improve this question

3 Answers 3

up vote 2 down vote accepted
+50

If you were doing guest vlan tagging you'd see that change and could script it that way. Alternatively you could use a highly-port-assigned DHCP server on both/all VLANs, with the same MAC listed in multiple scopes, you could then just trigger the refresh on vlan change.

share|improve this answer

If I remember correctly, upon completing migration the VM should send a gratuitous packet announcing itself. Anyhow, until the arp tables update, there will always be a bit of lag, not VM -> network, but network -> VM

What you can do is catch an "arriving" VM by polling virsh dominfo A VM migrating to a host will appear as "paused" at first, and as soon as it is "running", you know it has finished migrating. on the target you should get domain started event with details saying it was migrated and on the source you should get stopped/migrated event

The better way would be to use something like http://libvirt.org/git/?p=libvirt.git;a=blob;f=examples/domain-events/events-python/event-test.py on the target you should get domain started event with details saying it was migrated and on the source you should get stopped/migrated event

This is your best bet for catching a libvirt migration event using the proper API.

Catching migrations from within a VM is not possible, because the entire idea of live-migration is that a VM is not aware of it, and shouldn't feel the migration

share|improve this answer
    
Thank you, these are some good ideas too –  Jochen Ritzel Jun 30 '10 at 14:33

I'd think that you'd see something appear in dmesg during such a migration. Can you test and see if you do? If so, that's quite easy to trigger on, either by writing a quick-and-dirty kernel module, or just going the expeditious route of writing a shell-script daemon to watch dmesg.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.