[libvirt-users] VM migration upon shutdown in centos 7

Michal Privoznik mprivozn at redhat.com
Wed Jan 10 15:16:37 UTC 2018


On 01/05/2018 12:00 PM, Raman Gupta wrote:
> Hi,
> 
> I have CentOS 7,  two node system which allows live VM migration between
> them. Live migration triggered from virsh is happily happening. I am using
> GlusterFS for replicating VM disk files.
> 
> Now I want to automatically do the live migration at the time of
> reboot/shutdown/halt of the host node and for this I have written a systemd
> service unit [vPreShutdownHook.service] and placed the live migration
> command in a migrate script which is invoked from this service unit. The
> migrate script is invoked but migration does not happen.
> If someone has some idea please help me to migrate VM upon shutdown.
> 
> 
> ######## vPreShutdownHook.service ###############
> 
> [Unit]
> Description=vPreShutdownHook
> Requires=network.target
> Requires=libvirtd.service
> Requires=dbus.service
> Requires=glusterd.service
> Requires=glusterfsd.service
> DefaultDependencies=no
> Before=shutdown.target reboot.target
> 
> [Service]
> Type=oneshot
> RemainAfterExit=true
> ExecStart=/bin/true
> ExecStop=/root/vm_migrate.sh
> 
> [Install]
> WantedBy=multi-user.target
> 
> 
> ########## Command to migrate ############
> /usr/bin/virsh migrate --verbose --p2p --tunneled --live  --compressed
> --comp-methods "mt"  --comp-mt-level 5 --comp-mt-threads 5
> --comp-mt-dthreads 5   MY_VM qemu+ssh://root@$node2/system

Does this command alone succeed?
BTW: unless really needed --live will only make the migration take longer.

I don't know enough about systemd but maybe it's not waiting for virsh
to finish? Can you try to get any logs to see what is going on actually?

Michal




More information about the libvirt-users mailing list